diff --git a/esp32_fw/data/index.html b/esp32_fw/data/index.html index 022390a9..8a65efa4 100644 --- a/esp32_fw/data/index.html +++ b/esp32_fw/data/index.html @@ -26,6 +26,7 @@
DST: Filename: + Next check-in: min
diff --git a/esp32_fw/include/commstructs.h b/esp32_fw/include/commstructs.h index 3cac0a35..b9b6a5d6 100644 --- a/esp32_fw/include/commstructs.h +++ b/esp32_fw/include/commstructs.h @@ -45,15 +45,14 @@ struct AvailDataInfo { uint64_t dataVer; uint32_t dataSize; uint8_t dataType; + uint16_t nextCheckIn; } __packed; struct pendingData { struct AvailDataInfo availdatainfo; - uint8_t attemptsLeft; + uint16_t attemptsLeft; uint8_t targetMac[8]; } __packed; - - #define BLOCK_DATA_SIZE 4096 #define BLOCK_XFER_BUFFER_SIZE BLOCK_DATA_SIZE + sizeof(struct blockData) \ No newline at end of file diff --git a/esp32_fw/include/newproto.h b/esp32_fw/include/newproto.h index 84922d25..54ffe327 100644 --- a/esp32_fw/include/newproto.h +++ b/esp32_fw/include/newproto.h @@ -4,7 +4,7 @@ extern void addCRC(void* p, uint8_t len); extern bool checkCRC(void* p, uint8_t len); extern void processBlockRequest(struct espBlockRequest* br); -extern bool prepareDataAvail(String* filename, uint8_t dataType, uint8_t* dst); +extern bool prepareDataAvail(String* filename, uint8_t dataType, uint8_t* dst, uint16_t nextCheckin); extern void processJoinNetwork(struct espJoinNetwork* xjn); extern void processXferComplete(struct espXferComplete* xfc); extern void processDataReq(struct espAvailDataReq* adr); \ No newline at end of file diff --git a/esp32_fw/src/newproto.cpp b/esp32_fw/src/newproto.cpp index 1f28f6a8..44900621 100644 --- a/esp32_fw/src/newproto.cpp +++ b/esp32_fw/src/newproto.cpp @@ -47,7 +47,7 @@ void prepareCancelPending(uint64_t ver) { sendCancelPending(&pending); } -bool prepareDataAvail(String* filename, uint8_t dataType, uint8_t* dst) { +bool prepareDataAvail(String* filename, uint8_t dataType, uint8_t* dst, uint16_t nextCheckin) { *filename = "/" + *filename; if (!LittleFS.exists(*filename)) return false; File file = LittleFS.open(*filename); @@ -72,6 +72,7 @@ bool prepareDataAvail(String* filename, uint8_t dataType, uint8_t* dst) { pending.availdatainfo.dataType = dataType; pending.availdatainfo.dataVer = *((uint64_t*)md5bytes); pending.availdatainfo.dataSize = file.size(); + pending.availdatainfo.nextCheckIn = nextCheckin; pending.attemptsLeft = 10; sendDataAvail(&pending); diff --git a/esp32_fw/src/web.cpp b/esp32_fw/src/web.cpp index 7b31c934..35c5297a 100644 --- a/esp32_fw/src/web.cpp +++ b/esp32_fw/src/web.cpp @@ -234,9 +234,11 @@ void init_web() { server.on("/send_image", HTTP_POST, [](AsyncWebServerRequest *request) { String filename; String dst; + uint16_t nextCheckin; if (request->hasParam("filename", true) && request->hasParam("dst", true)) { filename = request->getParam("filename", true)->value(); dst = request->getParam("dst", true)->value(); + nextCheckin = request->getParam("ttl",true)->value().toInt(); uint8_t mac_addr[12]; // I expected this to return like 8 values, but if I make the array 8 bytes long, things die. mac_addr[0] = 0x00; mac_addr[1] = 0x00; @@ -250,7 +252,7 @@ void init_web() { request->send(200, "text/plain", "Something went wrong trying to parse the mac address"); } else { *((uint64_t *)mac_addr) = swap64(*((uint64_t *)mac_addr)); - if (prepareDataAvail(&filename, DATATYPE_IMGRAW, mac_addr)) { + if (prepareDataAvail(&filename, DATATYPE_IMGRAW, mac_addr, nextCheckin)) { request->send(200, "text/plain", "Sending to " + dst); } else { request->send(200, "text/plain", "Couldn't find filename :("); @@ -281,7 +283,7 @@ void init_web() { request->send(200, "text/plain", "Something went wrong trying to parse the mac address"); } else { *((uint64_t *)mac_addr) = swap64(*((uint64_t *)mac_addr)); - if (prepareDataAvail(&filename, DATATYPE_UPDATE, mac_addr)) { + if (prepareDataAvail(&filename, DATATYPE_UPDATE, mac_addr, 0)) { request->send(200, "text/plain", "Sending FW to " + dst); } else { request->send(200, "text/plain", "Couldn't find filename :("); @@ -311,7 +313,7 @@ void init_web() { request->send(200, "text/plain", "Something went wrong trying to parse the mac address"); } else { *((uint64_t *)mac_addr) = swap64(*((uint64_t *)mac_addr)); - if (prepareDataAvail(&filename, DATATYPE_NOUPDATE, mac_addr)) { + if (prepareDataAvail(&filename, DATATYPE_NOUPDATE, mac_addr,0)) { request->send(200, "text/plain", "Sending check-in request to " + dst); } }