mirror of
https://github.com/OpenEPaperLink/OpenEPaperLink.git
synced 2026-03-21 14:06:31 +01:00
bugfix: too long pending filenames after a few hours of uptime
This commit is contained in:
@@ -179,9 +179,8 @@ void drawNew(const uint8_t mac[8], tagRecord *&taginfo) {
|
||||
|
||||
char hexmac[17];
|
||||
mac2hex(mac, hexmac);
|
||||
String filename = "/" + String(hexmac) + ".raw";
|
||||
#ifdef YELLOW_IPS_AP
|
||||
if (isAp) {
|
||||
String filename = "/temp/" + String(hexmac) + ".raw";
|
||||
#ifdef YELLOW_IPS_AP if (isAp) {
|
||||
filename = "direct";
|
||||
}
|
||||
#endif
|
||||
@@ -543,8 +542,6 @@ bool updateTagImage(String &filename, const uint8_t *dst, uint16_t nextCheckin,
|
||||
} else if (imageParams.hasRed) {
|
||||
imageParams.dataType = DATATYPE_IMG_RAW_2BPP;
|
||||
Serial.println("datatype: DATATYPE_IMG_RAW_2BPP");
|
||||
} else {
|
||||
Serial.println("datatype: DATATYPE_IMG_RAW_1BPP");
|
||||
}
|
||||
prepareDataAvail(filename, imageParams.dataType, imageParams.lut, dst, nextCheckin);
|
||||
}
|
||||
|
||||
@@ -153,8 +153,10 @@ bool prepareDataAvail(String& filename, uint8_t dataType, uint8_t dataTypeArgume
|
||||
return true;
|
||||
}
|
||||
|
||||
filename = "/" + filename;
|
||||
|
||||
if (!filename.startsWith("/")) {
|
||||
filename = "/" + filename;
|
||||
}
|
||||
|
||||
if (!contentFS->exists(filename)) {
|
||||
wsErr("File not found. " + filename);
|
||||
return false;
|
||||
@@ -182,7 +184,7 @@ bool prepareDataAvail(String& filename, uint8_t dataType, uint8_t dataTypeArgume
|
||||
|
||||
if (dataType != DATATYPE_FW_UPDATE) {
|
||||
char dst_path[64];
|
||||
sprintf(dst_path, "/current/%02X%02X%02X%02X%02X%02X%02X%02X_%lu.pending\0", dst[7], dst[6], dst[5], dst[4], dst[3], dst[2], dst[1], dst[0], millis());
|
||||
sprintf(dst_path, "/current/%02X%02X%02X%02X%02X%02X%02X%02X_%lu.pending", dst[7], dst[6], dst[5], dst[4], dst[3], dst[2], dst[1], dst[0], millis() % 1000000);
|
||||
if (contentFS->exists(dst_path)) {
|
||||
contentFS->remove(dst_path);
|
||||
}
|
||||
@@ -238,7 +240,7 @@ void prepareExternalDataAvail(struct pendingData* pending, IPAddress remoteIP) {
|
||||
case DATATYPE_IMG_RAW_2BPP: {
|
||||
char hexmac[17];
|
||||
mac2hex(pending->targetMac, hexmac);
|
||||
String filename = "/current/" + String(hexmac) + "_" + String(millis()) + ".pending";
|
||||
String filename = "/current/" + String(hexmac) + "_" + String(millis() % 1000000) + ".pending";
|
||||
String imageUrl = "http://" + remoteIP.toString() + "/getdata?mac=" + String(hexmac);
|
||||
wsLog("prepareExternalDataAvail GET " + imageUrl);
|
||||
HTTPClient http;
|
||||
@@ -348,7 +350,7 @@ void processBlockRequest(struct espBlockRequest* br) {
|
||||
if (queueItem->data == nullptr) {
|
||||
fs::File file = contentFS->open(queueItem->filename);
|
||||
if (!file) {
|
||||
Serial.print("No current file. Canceling request\n");
|
||||
Serial.print("No current file. " + String(queueItem->filename) + " Canceling request\n");
|
||||
prepareCancelPending(br->src);
|
||||
return;
|
||||
}
|
||||
@@ -756,7 +758,7 @@ bool checkMirror(struct tagRecord* taginfo, struct pendingData* pending) {
|
||||
queueDataAvail(&pending2);
|
||||
} else {
|
||||
char dst_path[64];
|
||||
sprintf(dst_path, "/current/%02X%02X%02X%02X%02X%02X%02X%02X_%lu.pending", taginfo2->mac[7], taginfo2->mac[6], taginfo2->mac[5], taginfo2->mac[4], taginfo2->mac[3], taginfo2->mac[2], taginfo2->mac[1], taginfo2->mac[0], millis());
|
||||
sprintf(dst_path, "/current/%02X%02X%02X%02X%02X%02X%02X%02X_%lu.pending", taginfo2->mac[7], taginfo2->mac[6], taginfo2->mac[5], taginfo2->mac[4], taginfo2->mac[3], taginfo2->mac[2], taginfo2->mac[1], taginfo2->mac[0], millis() % 1000000);
|
||||
xSemaphoreTake(fsMutex, portMAX_DELAY);
|
||||
File file = contentFS->open(dst_path, "w");
|
||||
if (file) {
|
||||
@@ -879,6 +881,8 @@ bool queueDataAvail(struct pendingData* pending) {
|
||||
newPending.data = getDataForFile(file);
|
||||
Serial.println("Reading file " + String(newPending.filename));
|
||||
file.close();
|
||||
} else {
|
||||
Serial.println("Something's wrong... not found: " + String(newPending.filename));
|
||||
}
|
||||
}
|
||||
newPending.len = taginfo->len;
|
||||
|
||||
@@ -295,14 +295,14 @@
|
||||
"options": {
|
||||
"AT": "Austria",
|
||||
"BE": "Belgium",
|
||||
"CH": "Switzerland",
|
||||
"CZ": "Czech Republic",
|
||||
"EE": "Estonia",
|
||||
"ES": "Spain",
|
||||
"FI": "Finland",
|
||||
"FR": "France",
|
||||
"LT": "Lithuania",
|
||||
"DE": "Germany",
|
||||
"LV": "Latvia",
|
||||
"LT": "Lithuania",
|
||||
"LU": "Luxembourg",
|
||||
"NL": "Netherlands",
|
||||
"NO1": "Norway NO1",
|
||||
"NO2": "Norway NO2",
|
||||
@@ -311,8 +311,10 @@
|
||||
"NO5": "Norway NO5",
|
||||
"PL": "Poland",
|
||||
"RO": "Romania",
|
||||
"SK": "Slovakia",
|
||||
"SI": "Slovenia",
|
||||
"SK": "Slovakia"
|
||||
"ES": "Spain",
|
||||
"CH": "Switzerland"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user