diff --git a/.gitignore b/.gitignore index 2b16c31..3903eaa 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,10 @@ .vscode/c_cpp_properties.json .vscode/launch.json .vscode/ipch -.DS_Store \ No newline at end of file +.DS_Store +.idea/ +CMakeLists.txt +CMakeListsPrivate.txt +cmake-build-az-delivery-devkit-v4/ +cmake-build-debug/ +venv/ \ No newline at end of file diff --git a/html/website.html b/html/website.html index e3c9216..1a1f442 100644 --- a/html/website.html +++ b/html/website.html @@ -1,13 +1,13 @@ - + ESPuino-Konfiguration - + - + @@ -15,430 +15,513 @@ - - - -
-
-

WLAN-Konfiguration

-
+
+ +
+
+

WLAN-Konfiguration

+
- - -
- Bitte SSID des WLANs eintragen. -
- - - - + + +
+ Bitte SSID des WLANs eintragen. +
+ + + +
- -
-
-
-

RFID-Zuweisungen

-
-
- - - - + +
+
+
+

RFID-Zuweisungen

+
+
+ + + + +
-
- +
+ Dateien suchen
- - -
- - - -
-
-
-

RFID-Modifkationen

-
-
- - -
- Bitte eine 12-stellige Zahl eingeben. +
+
+



Der Prozess kann mehrere Minuten dauern...

+
- - -
- - - -
-
-
-

MQTT-Konfiguration

-
-
- -
-
- - - - - - + + +
+ + +
+
+
+
+

RFID-Modifkationen

+
+
+ + +
+ Bitte eine 12-stellige Zahl eingeben.
- - - -
-
-
-

FTP-Konfiguration

-
-
+ + +
+ + +
+
+
+
+

MQTT-Konfiguration

+
+
+ + +
+
+ + + + + + +
+ + +
+
+
+
+

FTP-Konfiguration

+
+
- + - -
- - -
-
-
-
-

Allgemeine Konfiguration

-
-
- - - - - - -
-
- - - - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
- - -
-
-
-
-

NVS-Importer

-
-
+ +
+ + +
+
+
+
+

Allgemeine Konfiguration

+
+
+ + + + + + +
+
+ + + + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+ + +
+
+
+
+

NVS-Importer

+
+
-
- -
-
-
- - + } + }; + var myJSON = JSON.stringify(myObj); + socket.send(myJSON); + } + + $(document).ready(function () { + connect(); + renderFileTree(); + + $(function () { + $('[data-toggle="tooltip"]').tooltip(); + }); + }); + + diff --git a/html/websiteMgmt.h b/html/websiteMgmt.h deleted file mode 100644 index f5bc9e7..0000000 --- a/html/websiteMgmt.h +++ /dev/null @@ -1,263 +0,0 @@ -static const char mgtWebsite[] PROGMEM = "\ -\ - \ - ESPuino-Konfiguration\ - \ - \ - \ - \ - \ - \ - \ - \ - \ -
\ -
\ -

WLAN-Konfiguration

\ -
\ -
\ - \ - \ -
\ - Bitte SSID des WLANs eintragen.\ -
\ - \ - \ -
\ - \ - \ -
\ -
\ -
\ -

RFID-Zuweisungen

\ -
\ -
\ - \ - \ - \ - \ - \ - \ -
\ - \ - \ -
\ -
\ -
\ -

RFID-Modifkationen

\ -
\ -
\ - \ - \ -
\ - Bitte eine 12-stellige Zahl eingeben.\ -
\ - \ - \ -
\ - \ - \ -
\ -
\ -
\ -

MQTT-Konfiguration

\ -
\ -
\ - \ - \ -
\ -
\ - \ - \ -
\ - Bitte eine gültige IPv4-Adresse eingeben, z.B. 192.168.2.89.\ -
\ -
\ - \ - \ -
\ -
\ -
\ -

FTP-Konfiguration

\ -
\ -
\ - \ - \ - \ - \ -
\ - \ - \ -
\ -
\ -
\ -

Allgemeine Konfiguration

\ -
\ -
\ - \ - \ - \ - \ -
\ -
\ - \ - \ - \ - \ -
\ -
\ - \ - \ -
\ - \ - \ -
\ - \ -
\ - \ -\ -"; \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index 09908a7..05dc830 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -553,6 +553,14 @@ void createFile(fs::FS &fs, const char * path, const char * message){ file.close(); } +bool fileExists(fs::FS &fs, const char *file){ + if (fs.exists(file)) { + return true; + } else { + return false; + } +} + /** * Appends raw input to a file * @param fs @@ -610,6 +618,7 @@ void appendNodeToJSONFile(fs::FS &fs, const char * path, const char *filename, c file.print("\"\n }"); // i/o is timing critical keep all stuff running esp_task_wdt_reset(); + yield(); file.close(); if(isFirstJSONtNode){ @@ -638,11 +647,16 @@ bool pathValid(const char *_fileItem) { * @param parent * @param levels */ +char fileNameBuf[255]; +bool notifyOverWebsocket = true; + +//FIXME: This function blocks the websocket connection void parseSDFileList(fs::FS &fs, const char * dirname, const char * parent, uint8_t levels){ - char fileNameBuf[255]; + // i/o is timing critical keep all stuff running esp_task_wdt_reset(); + yield(); File root = fs.open(dirname); if(!root){ @@ -672,9 +686,10 @@ void parseSDFileList(fs::FS &fs, const char * dirname, const char * parent, uint } strncpy(fileNameBuf, (char *) file.name(), sizeof(fileNameBuf) / sizeof(fileNameBuf[0])); - // we have a folder if(file.isDirectory()){ + + esp_task_wdt_reset(); if (pathValid(fileNameBuf)){ appendNodeToJSONFile(SD, DIRECTORY_INDEX_FILE, fileNameBuf, parent, "folder" ); @@ -704,16 +719,12 @@ bool indexingIsRunning = false; * is done. */ void createJSONFileList(){ - - if(!indexingIsRunning){ - indexingIsRunning = true; - createFile(SD, DIRECTORY_INDEX_FILE, "[\n"); - parseSDFileList(SD, "/", NULL, FS_DEPTH); - appendToFile(SD, DIRECTORY_INDEX_FILE, "]"); - isFirstJSONtNode = true; - sendWebsocketData(0, 30); - indexingIsRunning = false; - } + createFile(SD, DIRECTORY_INDEX_FILE, "[\n"); + parseSDFileList(SD, "/", NULL, FS_DEPTH); + appendToFile(SD, DIRECTORY_INDEX_FILE, "]"); + isFirstJSONtNode = true; + sendWebsocketData(0, 30); + indexingIsRunning = false; } // Measures voltage of a battery as per interval or after bootup (after allowing a few seconds to settle down) @@ -3002,7 +3013,6 @@ bool getWifiEnableStatusFromNVS(void) { prefsSettings.putUInt("enableWifi", 1); wifiStatus = 1; } - return wifiStatus; } @@ -3313,8 +3323,12 @@ void sendWebsocketData(uint32_t client, uint8_t code) { object["pong"] = "pong"; } else if (code == 30){ object["refreshFileList"] = "ready"; + }else if (code == 31){ + object["indexingState"] = fileNameBuf; + esp_task_wdt_reset(); } - char jBuf[50]; + + char jBuf[255]; serializeJson(doc, jBuf, sizeof(jBuf) / sizeof(jBuf[0])); if (client == 0) { @@ -3322,6 +3336,7 @@ void sendWebsocketData(uint32_t client, uint8_t code) { } else { ws.printf(client, jBuf); } + notifyOverWebsocket = true; } @@ -3924,10 +3939,18 @@ void setup() { lastTimeActiveTimestamp = millis(); // initial set after boot + /** + * Create empty Index json file when no file exists. + */ + if(!fileExists(SD,DIRECTORY_INDEX_FILE)){ + createFile(SD,DIRECTORY_INDEX_FILE,"[]"); + ESP.restart(); + } bootComplete = true; Serial.print(F("Free heap: ")); Serial.println(ESP.getFreeHeap()); + } @@ -3965,6 +3988,7 @@ void loop() { #ifdef PLAY_LAST_RFID_AFTER_REBOOT recoverLastRfidPlayed(); #endif + ws.cleanupClients(); } diff --git a/src/websiteMgmt.h b/src/websiteMgmt.h deleted file mode 100644 index 9fe3f05..0000000 --- a/src/websiteMgmt.h +++ /dev/null @@ -1,509 +0,0 @@ -static const char mgtWebsite[] PROGMEM = "\ -\ - \ - ESPuino-Konfiguration\ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ -
\ -
\ -

WLAN-Konfiguration

\ -
\ -
\ - \ - \ -
\ - Bitte SSID des WLANs eintragen.\ -
\ - \ - \ - \ - \ -
\ - \ - \ -
\ -
\ -
\ -
\ -

RFID-Zuweisungen

\ -
\ -
\ - \ - \ - \ - \ -
\ -
\ -
\ - \ -
\ -
\ - \ - \ -
\ - \ - \ -
\ -
\ -
\ -
\ -

RFID-Modifkationen

\ -
\ -
\ - \ - \ -
\ - Bitte eine 12-stellige Zahl eingeben.\ -
\ - \ - \ -
\ - \ - \ -
\ -
\ -
\ -
\ -

MQTT-Konfiguration

\ -
\ -
\ - \ - \ -
\ -
\ - \ - \ - \ - \ - \ - \ -
\ - \ - \ -
\ -
\ -
\ -
\ -

FTP-Konfiguration

\ -
\ -
\ - \ - \ - \ - \ -
\ - \ - \ -
\ -
\ -
\ -
\ -

Allgemeine Konfiguration

\ -
\ -
\ - \ - \ - \ - \ - \ - \ -
\ -
\ - \ - \ - \ - \ -
\ -
\ - \ - \ -
\ -
\ - \ - \ -
\ -
\ - \ - \ -
\ -
\ - \ - \ -
\ -
\ - \ - \ -
\ - \ - \ -
\ -
\ -
\ -
\ -

NVS-Importer

\ -
\ -
\ - \ - \ -
\ - \ -
\ -
\ -
\ - \ - \ -\ -"; \ No newline at end of file