diff --git a/ESP32_AP-Flasher/data/www/index.html.gz b/ESP32_AP-Flasher/data/www/index.html.gz
index e76fb1fa..b825a477 100644
Binary files a/ESP32_AP-Flasher/data/www/index.html.gz and b/ESP32_AP-Flasher/data/www/index.html.gz differ
diff --git a/ESP32_AP-Flasher/data/www/main.js.gz b/ESP32_AP-Flasher/data/www/main.js.gz
index 5f56f52c..47a53f8c 100644
Binary files a/ESP32_AP-Flasher/data/www/main.js.gz and b/ESP32_AP-Flasher/data/www/main.js.gz differ
diff --git a/ESP32_AP-Flasher/include/tag_db.h b/ESP32_AP-Flasher/include/tag_db.h
index 4cbd85e1..47615a8a 100644
--- a/ESP32_AP-Flasher/include/tag_db.h
+++ b/ESP32_AP-Flasher/include/tag_db.h
@@ -69,6 +69,7 @@ struct Config {
uint8_t stopsleep;
uint8_t runStatus;
uint8_t preview;
+ uint8_t lock;
uint8_t wifiPower;
char timeZone[52];
uint8_t sleepTime1;
diff --git a/ESP32_AP-Flasher/src/newproto.cpp b/ESP32_AP-Flasher/src/newproto.cpp
index ca1d6823..ec28d665 100644
--- a/ESP32_AP-Flasher/src/newproto.cpp
+++ b/ESP32_AP-Flasher/src/newproto.cpp
@@ -56,6 +56,7 @@ void prepareCancelPending(const uint8_t dst[8]) {
tagRecord* taginfo = tagRecord::findByMAC(dst);
if (taginfo == nullptr) {
+ if (config.lock) return;
wsErr("Tag not found, this shouldn't happen.");
return;
}
@@ -80,6 +81,7 @@ void prepareIdleReq(const uint8_t* dst, uint16_t nextCheckin) {
void prepareDataAvail(uint8_t* data, uint16_t len, uint8_t dataType, const uint8_t* dst) {
tagRecord* taginfo = tagRecord::findByMAC(dst);
if (taginfo == nullptr) {
+ if (config.lock) return;
wsErr("Tag not found, this shouldn't happen.");
return;
}
@@ -129,6 +131,7 @@ bool prepareDataAvail(String& filename, uint8_t dataType, uint8_t dataTypeArgume
tagRecord* taginfo = tagRecord::findByMAC(dst);
if (taginfo == nullptr) {
+ if (config.lock) return true;
wsErr("Tag not found, this shouldn't happen.");
return true;
}
@@ -345,6 +348,7 @@ void processBlockRequest(struct espBlockRequest* br) {
tagRecord* taginfo = tagRecord::findByMAC(br->src);
if (taginfo == nullptr) {
+ if (config.lock) return;
prepareCancelPending(br->src);
Serial.printf("blockrequest: couldn't find taginfo %02X%02X%02X%02X%02X%02X%02X%02X\n", br->src[7], br->src[6], br->src[5], br->src[4], br->src[3], br->src[2], br->src[1], br->src[0]);
return;
@@ -458,6 +462,7 @@ void processDataReq(struct espAvailDataReq* eadr, bool local, IPAddress remoteIP
tagRecord* taginfo = tagRecord::findByMAC(eadr->src);
if (taginfo == nullptr) {
+ if (config.lock) return;
taginfo = new tagRecord;
memcpy(taginfo->mac, eadr->src, sizeof(taginfo->mac));
taginfo->pending = false;
@@ -657,6 +662,7 @@ void updateTaginfoitem(struct TagInfo* taginfoitem, IPAddress remoteIP) {
tagRecord* taginfo = tagRecord::findByMAC(taginfoitem->mac);
if (taginfo == nullptr) {
+ if (config.lock) return;
taginfo = new tagRecord;
memcpy(taginfo->mac, taginfoitem->mac, sizeof(taginfo->mac));
taginfo->pending = false;
diff --git a/ESP32_AP-Flasher/src/tag_db.cpp b/ESP32_AP-Flasher/src/tag_db.cpp
index 553c2b47..b9ed81bb 100644
--- a/ESP32_AP-Flasher/src/tag_db.cpp
+++ b/ESP32_AP-Flasher/src/tag_db.cpp
@@ -130,9 +130,17 @@ void saveDB(const String& filename) {
Storage.begin();
xSemaphoreTake(fsMutex, portMAX_DELAY);
+
+ fs::File existingFile = contentFS->open(filename, "r");
+ if (existingFile) {
+ existingFile.close();
+ String backupFilename = filename + ".bak";
+ contentFS->rename(filename.c_str(), backupFilename.c_str());
+ }
+
fs::File file = contentFS->open(filename, "w");
if (!file) {
- Serial.println("saveDB: Failed to open file");
+ Serial.println("saveDB: Failed to open file for writing");
xSemaphoreGive(fsMutex);
return;
}
@@ -307,6 +315,7 @@ void initAPconfig() {
config.maxsleep = APconfig["maxsleep"] | 10;
config.stopsleep = APconfig["stopsleep"] | 1;
config.preview = APconfig["preview"] | 1;
+ config.lock = APconfig["lock"] | 0;
config.sleepTime1 = APconfig["sleeptime1"] | 0;
config.sleepTime2 = APconfig["sleeptime2"] | 0;
// default wifi power 8.5 dbM
@@ -333,6 +342,7 @@ void saveAPconfig() {
APconfig["maxsleep"] = config.maxsleep;
APconfig["stopsleep"] = config.stopsleep;
APconfig["preview"] = config.preview;
+ APconfig["lock"] = config.lock;
APconfig["wifipower"] = config.wifiPower;
APconfig["timezone"] = config.timeZone;
APconfig["sleeptime1"] = config.sleepTime1;
diff --git a/ESP32_AP-Flasher/src/web.cpp b/ESP32_AP-Flasher/src/web.cpp
index cf0d3d2b..fd0fef67 100644
--- a/ESP32_AP-Flasher/src/web.cpp
+++ b/ESP32_AP-Flasher/src/web.cpp
@@ -471,6 +471,9 @@ void init_web() {
if (request->hasParam("preview", true)) {
config.preview = static_cast
+ + +