diff --git a/ESP32_AP-Flasher/data/www/index.html.gz b/ESP32_AP-Flasher/data/www/index.html.gz index be72d2d9..ae4cc3cc 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.css.gz b/ESP32_AP-Flasher/data/www/main.css.gz index 9f1639be..098183c1 100644 Binary files a/ESP32_AP-Flasher/data/www/main.css.gz and b/ESP32_AP-Flasher/data/www/main.css.gz differ diff --git a/ESP32_AP-Flasher/data/www/main.js.gz b/ESP32_AP-Flasher/data/www/main.js.gz index cf128d0c..e8631961 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/data/www/ota.js.gz b/ESP32_AP-Flasher/data/www/ota.js.gz index 39e25f46..ed81cfbf 100644 Binary files a/ESP32_AP-Flasher/data/www/ota.js.gz and b/ESP32_AP-Flasher/data/www/ota.js.gz differ diff --git a/ESP32_AP-Flasher/include/tag_db.h b/ESP32_AP-Flasher/include/tag_db.h index c7653cab..7534b741 100644 --- a/ESP32_AP-Flasher/include/tag_db.h +++ b/ESP32_AP-Flasher/include/tag_db.h @@ -71,6 +71,8 @@ struct Config { char timeZone[52]; uint8_t sleepTime1; uint8_t sleepTime2; + String repo; + String env; }; struct HwType { @@ -90,7 +92,6 @@ extern Config config; extern std::vector tagDB; extern std::unordered_map hwtype; extern std::unordered_map varDB; -extern DynamicJsonDocument APconfig; extern String tagDBtoJson(const uint8_t mac[8] = nullptr, uint8_t startPos = 0); extern bool deleteRecord(const uint8_t mac[8]); extern void fillNode(JsonObject& tag, const tagRecord* taginfo); diff --git a/ESP32_AP-Flasher/src/espflasher.cpp b/ESP32_AP-Flasher/src/espflasher.cpp index db19d9d0..15fe7f72 100644 --- a/ESP32_AP-Flasher/src/espflasher.cpp +++ b/ESP32_AP-Flasher/src/espflasher.cpp @@ -7,6 +7,7 @@ #include "esp32_port.h" #include "esp_littlefs.h" #include "storage.h" +#include "tag_db.h" #include "web.h" esp_loader_error_t connect_to_target(uint32_t higher_transmission_rate) { @@ -163,8 +164,7 @@ bool downloadAndWriteBinary(String &filename, const char *url) { } bool doC6flash(uint8_t doDownload) { - const char *githubUrl = "https://raw.githubusercontent.com/jjwbruijn/OpenEPaperLink/master/binaries/ESP32-C6/firmware.json"; - + const String githubUrl = "https://raw.githubusercontent.com/" + config.repo + "/master/binaries/ESP32-C6/firmware.json"; HTTPClient http; Serial.println(githubUrl); http.begin(githubUrl); @@ -181,7 +181,7 @@ bool doC6flash(uint8_t doDownload) { JsonArray jsonArray = jsonDoc.as(); for (JsonObject obj : jsonArray) { String filename = "/" + obj["filename"].as(); - String binaryUrl = "https://raw.githubusercontent.com/jjwbruijn/OpenEPaperLink/master/binaries/ESP32-C6" + String(filename); + String binaryUrl = "https://raw.githubusercontent.com/" + config.repo + "/master/binaries/ESP32-C6" + String(filename); for (int retry = 0; retry < 10; retry++) { if (downloadAndWriteBinary(filename, binaryUrl.c_str())) { break; diff --git a/ESP32_AP-Flasher/src/flasher.cpp b/ESP32_AP-Flasher/src/flasher.cpp index 1c99dd96..6c88c5d4 100644 --- a/ESP32_AP-Flasher/src/flasher.cpp +++ b/ESP32_AP-Flasher/src/flasher.cpp @@ -176,7 +176,6 @@ bool flasher::getInfoBlockType() { bool flasher::findTagByMD5() { DynamicJsonDocument doc(3000); - DynamicJsonDocument APconfig(600); fs::File readfile = contentFS->open("/tag_md5_db.json", "r"); DeserializationError err = deserializeJson(doc, readfile); if (!err) { @@ -206,7 +205,6 @@ bool flasher::findTagByMD5() { bool flasher::findTagByType(uint8_t type) { DynamicJsonDocument doc(3000); - DynamicJsonDocument APconfig(600); fs::File readfile = contentFS->open("/tag_md5_db.json", "r"); DeserializationError err = deserializeJson(doc, readfile); if (!err) { @@ -446,7 +444,6 @@ bool flasher::writeFlashFromPackOffset(fs::File *file, uint16_t length) { bool flasher::writeFlashFromPack(String filename, uint8_t type) { StaticJsonDocument<512> doc; - DynamicJsonDocument APconfig(512); fs::File readfile = contentFS->open(filename, "r"); DeserializationError err = deserializeJson(doc, readfile); if (!err) { @@ -505,7 +502,6 @@ bool flasher::writeBlock(uint16_t offset, uint8_t *data, uint16_t len, bool info uint16_t getAPUpdateVersion(uint8_t type) { StaticJsonDocument<512> doc; - DynamicJsonDocument APconfig(512); fs::File readfile = contentFS->open("/AP_FW_Pack.bin", "r"); DeserializationError err = deserializeJson(doc, readfile); if (!err) { diff --git a/ESP32_AP-Flasher/src/tag_db.cpp b/ESP32_AP-Flasher/src/tag_db.cpp index 2ce32340..a510c099 100644 --- a/ESP32_AP-Flasher/src/tag_db.cpp +++ b/ESP32_AP-Flasher/src/tag_db.cpp @@ -11,6 +11,9 @@ #include "storage.h" #include "util.h" +#define STR_IMPL(x) #x +#define STR(x) STR_IMPL(x) + std::vector tagDB; std::unordered_map varDB; std::unordered_map hwdata = { @@ -309,6 +312,8 @@ void initAPconfig() { // default wifi power 8.5 dbM // see https://github.com/espressif/arduino-esp32/blob/master/libraries/WiFi/src/WiFiGeneric.h#L111 config.wifiPower = APconfig["wifipower"] | 34; + config.repo = APconfig["repo"] | "jjwbruijn/OpenEPaperLink"; + config.env = APconfig["env"] | STR(BUILD_ENV_NAME); if (APconfig["timezone"]) { strlcpy(config.timeZone, APconfig["timezone"], sizeof(config.timeZone)); } else { @@ -331,6 +336,8 @@ void saveAPconfig() { APconfig["timezone"] = config.timeZone; APconfig["sleeptime1"] = config.sleepTime1; APconfig["sleeptime2"] = config.sleepTime2; + APconfig["repo"] = config.repo; + APconfig["env"] = config.env; serializeJsonPretty(APconfig, configFile); configFile.close(); xSemaphoreGive(fsMutex); diff --git a/ESP32_AP-Flasher/src/web.cpp b/ESP32_AP-Flasher/src/web.cpp index f4d6504a..98bd878c 100644 --- a/ESP32_AP-Flasher/src/web.cpp +++ b/ESP32_AP-Flasher/src/web.cpp @@ -26,8 +26,6 @@ extern uint8_t data_to_send[]; -// const char *http_username = "admin"; -// const char *http_password = "admin"; AsyncWebServer server(80); AsyncWebSocket ws("/ws"); WifiManager wm; @@ -189,7 +187,6 @@ void init_web() { wm.connectToWifi(); - // server.addHandler(new SPIFFSEditor(*contentFS, http_username, http_password)); server.addHandler(new SPIFFSEditor(*contentFS)); server.addHandler(&ws); @@ -424,48 +421,55 @@ void init_web() { }); server.on("/save_apcfg", HTTP_POST, [](AsyncWebServerRequest *request) { - if (request->hasParam("alias", true) && request->hasParam("channel", true)) { + if (request->hasParam("alias", true)) { String aliasValue = request->getParam("alias", true)->value(); size_t aliasLength = aliasValue.length(); if (aliasLength > 31) aliasLength = 31; aliasValue.toCharArray(config.alias, aliasLength + 1); config.alias[aliasLength] = '\0'; - - config.channel = static_cast(request->getParam("channel", true)->value().toInt()); - if (request->hasParam("led", true)) { - config.led = static_cast(request->getParam("led", true)->value().toInt()); - updateBrightnessFromConfig(); - } - if (request->hasParam("language", true)) { - config.language = static_cast(request->getParam("language", true)->value().toInt()); - updateLanguageFromConfig(); - } - if (request->hasParam("maxsleep", true)) { - config.maxsleep = static_cast(request->getParam("maxsleep", true)->value().toInt()); - } - if (request->hasParam("stopsleep", true)) { - config.stopsleep = static_cast(request->getParam("stopsleep", true)->value().toInt()); - } - if (request->hasParam("preview", true)) { - config.preview = static_cast(request->getParam("preview", true)->value().toInt()); - } - if (request->hasParam("sleeptime1", true)) { - config.sleepTime1 = static_cast(request->getParam("sleeptime1", true)->value().toInt()); - config.sleepTime2 = static_cast(request->getParam("sleeptime2", true)->value().toInt()); - } - if (request->hasParam("wifipower", true)) { - config.wifiPower = static_cast(request->getParam("wifipower", true)->value().toInt()); - WiFi.setTxPower(static_cast(config.wifiPower)); - } - if (request->hasParam("timezone", true)) { - strncpy(config.timeZone, request->getParam("timezone", true)->value().c_str(), sizeof(config.timeZone) - 1); - config.timeZone[sizeof(config.timeZone) - 1] = '\0'; - setenv("TZ", config.timeZone, 1); - tzset(); - } - saveAPconfig(); - setAPchannel(); } + if (request->hasParam("channel", true)) { + config.channel = static_cast(request->getParam("channel", true)->value().toInt()); + } + if (request->hasParam("led", true)) { + config.led = static_cast(request->getParam("led", true)->value().toInt()); + updateBrightnessFromConfig(); + } + if (request->hasParam("language", true)) { + config.language = static_cast(request->getParam("language", true)->value().toInt()); + updateLanguageFromConfig(); + } + if (request->hasParam("maxsleep", true)) { + config.maxsleep = static_cast(request->getParam("maxsleep", true)->value().toInt()); + } + if (request->hasParam("stopsleep", true)) { + config.stopsleep = static_cast(request->getParam("stopsleep", true)->value().toInt()); + } + if (request->hasParam("preview", true)) { + config.preview = static_cast(request->getParam("preview", true)->value().toInt()); + } + if (request->hasParam("sleeptime1", true)) { + config.sleepTime1 = static_cast(request->getParam("sleeptime1", true)->value().toInt()); + config.sleepTime2 = static_cast(request->getParam("sleeptime2", true)->value().toInt()); + } + if (request->hasParam("wifipower", true)) { + config.wifiPower = static_cast(request->getParam("wifipower", true)->value().toInt()); + WiFi.setTxPower(static_cast(config.wifiPower)); + } + if (request->hasParam("timezone", true)) { + strncpy(config.timeZone, request->getParam("timezone", true)->value().c_str(), sizeof(config.timeZone) - 1); + config.timeZone[sizeof(config.timeZone) - 1] = '\0'; + setenv("TZ", config.timeZone, 1); + tzset(); + } + if (request->hasParam("repo", true)) { + config.repo = request->getParam("repo", true)->value(); + } + if (request->hasParam("env", true)) { + config.env = request->getParam("env", true)->value(); + } + saveAPconfig(); + setAPchannel(); request->send(200, "text/plain", "Ok, saved"); }); diff --git a/ESP32_AP-Flasher/wwwroot/index.html b/ESP32_AP-Flasher/wwwroot/index.html index 9bd39e77..7116c90a 100644 --- a/ESP32_AP-Flasher/wwwroot/index.html +++ b/ESP32_AP-Flasher/wwwroot/index.html @@ -39,376 +39,409 @@ -
-
+
-
+
-
- - - - - - - - - - - - - - - - - - - - - - - - - - -
- check_circle - - initialising... -
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
+ check_circle + + initialising... +
+ sell + + tags + + 0 +
+ hourglass_empty + + pending data + + 0 +
+ battery_low + + low battery + + 0 +
+ signal_disconnected + + timeout + + 0 +
+
+ +
+
+

Currently active tags

+
+
+
+
+
group by
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+
sort by
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+
filter
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ↻
+
⚠ +
+
+
+
+
+ +
+
+
+
+
+
    +
+
+ +
+

Active access points

+ +
+
+

194.109.6.66

+

AP kitchen

+
+ sell -
- tags - - 0 -
- hourglass_empty - - pending data - - 0 -
- battery_low - - low battery - - 0 -
- signal_disconnected - - timeout - - 0 -
-
- -
-
-

Currently active tags

-
-
-
-
-
group by
-
- -
-
- -
-
- -
-
- -
-
-
-
sort by
-
- -
-
- -
-
- -
-
- -
-
-
-
filter
-
- -
-
- -
-
- -
-
- -
-
- -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ↻
-
⚠ -
-
+ + 25
+

+ fetching software version... +

+
-
-
-
-
-
-
    -
-
+
+ Work in progress... +
-
-

Active access points

+
+

Access Point config

+

+ + +

+

+ + +

+

+ + +

+

+ + +

+

+ + +

+

+ + +

+

+ + + and + +

+

+ + +

+

+ + +

+

+ + +

+

+ +

+

Manage

+

+ Saves the tagDB and instantly reboots the Access + Point +

+

+ Download tagDB +

+

+ Manage firmware of the ESP32 +

+

+ WiFi config Opens a new window with WiFi + config options +

+

+
+ Github + OpenEPaperLink
+ OpenEPaperLink + Wiki
+

+
-
-
-

194.109.6.66

-

AP kitchen

-
- - sell +
+

Firmware Updates

+
+
+
+

Repository

+
+ +
+ + + +
+

Releases

+
+

Other actions

+
+

+

+

+

+ +

download latest version
- 13 - - cell_tower - - 25 -
-

- fetching software version...

+
- -
- Work in progress... -
- -
-

Access Point config

-

- - -

-

- - -

-

- - -

-

- - -

-

- - -

-

- - -

-

- - - and - -

-

- - -

-

- - -

-

- - -

-

- -

-

Manage

-

- Saves the tagDB and instantly reboots the Access - Point -

-

- Download tagDB -

-

- Manage firmware of the ESP32 -

-

- WiFi config Opens a new window with WiFi - config options -

-

-
- Github - OpenEPaperLink
- OpenEPaperLink - Wiki
-

-
-
-
- + + +