From ba04f463860d42a028c457f308ef27471f45876d Mon Sep 17 00:00:00 2001 From: Torsten Stauder Date: Sun, 23 Feb 2020 23:19:34 +0100 Subject: [PATCH] Restart added --- README.md | 1 + html/website.html | 3 +++ platformio.ini | 4 ++-- src/main.cpp | 56 +++++++++-------------------------------------- src/websiteMgmt.h | 3 +++ 5 files changed, 19 insertions(+), 48 deletions(-) diff --git a/README.md b/README.md index 54b62be..66afb45 100644 --- a/README.md +++ b/README.md @@ -80,6 +80,7 @@ Optionally, GPIO 17 can be used to drive a NPN-transistor (BC337-40) that pulls * in setup() RFID-cards can be statically linked to an action/file. Everything is stored in uC's NVS. * if Neopixel enabled: set NUM_LEDS to the LED-number of your Neopixel-ring and define the Neopixel-type using `#define CHIPSET` * please note: by using audiobook-mode any playlist-savings will be overwritten with every start unless the RFID-cards in setup() are commented out. Main way to link RFID to an action will be a webservice (still under development) +* If you're using Arduino-IDE please make sure to change ESP32's partition-layout to `No OTA (2MB APP/2MB Spiffs)` as otherwise the sketch won't fit into the flash-memory. * compile and upload the sketch ## Starting Tonuino-ESP32 first time diff --git a/html/website.html b/html/website.html index 5748650..1ff99c0 100644 --- a/html/website.html +++ b/html/website.html @@ -38,6 +38,9 @@ + diff --git a/platformio.ini b/platformio.ini index 09a0f65..6bff14b 100644 --- a/platformio.ini +++ b/platformio.ini @@ -27,5 +27,5 @@ lib_deps = https://github.com/bblanchon/ArduinoJson.git ; Don't forget to run this script if you changed the html-files provided in any way -;extra_scripts = -; pre:processHtml.py \ No newline at end of file +extra_scripts = + pre:processHtml.py \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index 8d0c6a9..a91b437 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2511,13 +2511,12 @@ wl_status_t wifiManager(void) { WiFi.begin(_ssid, _pwd); uint8_t tryCount=0; - while (WiFi.status() != WL_CONNECTED && tryCount <= 6) { + while (WiFi.status() != WL_CONNECTED && tryCount <= 4) { delay(500); Serial.print(F(".")); - Serial.print(WiFi.status()); tryCount++; wifiCheckLastTimestamp = millis(); - if (tryCount >= 2 && WiFi.status() == WL_CONNECT_FAILED) { + if (tryCount >= 4 && WiFi.status() == WL_CONNECT_FAILED) { WiFi.begin(_ssid, _pwd); // ESP32-workaround } } @@ -2538,7 +2537,7 @@ wl_status_t wifiManager(void) { } -// Used for substitution of some variables/templates of html-file +// Used for substitution of some variables/templates of html-files String templateProcessor(const String& templ) { if(templ == "FTP_USER") { return prefsSettings.getString("ftpuser", "-1"); @@ -2736,7 +2735,6 @@ void onWebsocketEvent(AsyncWebSocket * server, AsyncWebSocketClient * client, Aw returnCode = 0; } sendWebsocketData(client->id(), 1); - //ws.printf(client->id(), doc); if (info->opcode == WS_TEXT) { data[len] = 0; @@ -2747,26 +2745,6 @@ void onWebsocketEvent(AsyncWebSocket * server, AsyncWebSocketClient * client, Aw } Serial.printf("\n"); } - - if (info->opcode == WS_TEXT) { - //client->text("I got your text message"); - } else { - //client->binary("I got your binary message"); - } - } else { - if (info->message_opcode == WS_TEXT) { - data[len] = 0; - } - - if ((info->index + len) == info->len) { - if (info->final) { - if (info->message_opcode == WS_TEXT) { - //client->text("I got your text message"); - } else { - //client->binary("I got your binary message"); - } - } - } } } } @@ -2797,31 +2775,14 @@ void setup() { // Examples for serialized RFID-actions that are stored in NVS // #### - // Don't forget to comment this section out for regular usage as it probably overwrites saved states in mode audiobook + // Please note: There's no need to do this manually (unless you want to) /*prefsRfid.putString("215123125075", "#/mp3/Kinderlieder#0#6#0"); - prefsRfid.putString("009236075184", "#/Aura - Avoure.mp3#0#3#0"); - prefsRfid.putString("073022077184", "#/kurz#0#7#0"); prefsRfid.putString("169239075184", "#http://radio.koennmer.net/evosonic.mp3#0#8#0"); prefsRfid.putString("244105171042", "#0#0#111#0"); // modification-card (repeat track) - prefsRfid.putString("075081176028", "#0#0#106#0"); // modification-card (sleep at end of playlist) - prefsRfid.putString("212216120042", "#0#0#105#0"); // modification-card (sleep at end of track) - prefsRfid.putString("020059140043", "#0#0#111#0"); // modification-card (repeat current track) prefsRfid.putString("228064156042", "#0#0#110#0"); // modification-card (repeat playlist) prefsRfid.putString("018030087052", "#http://shouthost.com.19.streams.bassdrive.com:8200#0#8#0"); - prefsRfid.putString("182146124043", "#http://ibizaglobalradio.streaming-pro.com:8024#0#8#0"); - prefsRfid.putString("018162219052", "#http://stream2.friskyradio.com:8000/frisky_mp3_hi#0#8#0"); - prefsRfid.putString("160243107050", "#/mp3/Hoerspiele/Sonstige/Dingi und der Containerdieb.mp3#0#3#0"); - prefsRfid.putString("244189084042", "#/mp3/Hoerspiele/Yakari/Yakari und die Pferdediebe#0#3#0"); - prefsRfid.putString("244042007042", "#/mp3/Hoerspiele/Yakari/Der Gesang des Raben#0#3#0"); - prefsRfid.putString("176063100050", "#/mp3/Hoerspiele/Yakari/Best of Lagerfeuergeschichten#0#3#0"); - prefsRfid.putString("004134024043", "#/mp3/Hoerspiele/Yakari/Schneeball in Gefahr#0#3#0"); - prefsRfid.putString("242216118051", "#/mp3/Hoerspiele/Weihnachten mit Astrid Lindgren#0#3#0"); - prefsRfid.putString("176008145050", "#/mp3/Hoerspiele/Janosch/Oh wie schoen ist Panama#0#3#0"); - prefsRfid.putString("036073235043", "#/mp3/Hoerspiele/Paw Patrol/Rettet Weihnachten#0#3#0"); - prefsRfid.putString("020073020043", "#/mp3/Hoerspiele/Yakari/Sammlung1#0#3#0"); prefsRfid.putString("212130160042", "#/mp3/Hoerspiele/Yakari/Sammlung2#0#3#0");*/ - // Init uSD-SPI pinMode(SPISD_CS, OUTPUT); digitalWrite(SPISD_CS, HIGH); @@ -3037,6 +2998,12 @@ void setup() { request->send_P(200, "text/html", mgtWebsite, templateProcessor); }); + wServer.on("/restart", HTTP_GET, [] (AsyncWebServerRequest *request) { + request->send(200, "text/html", "

Der Tonuino wird neu gestartet...
Zur letzten Seite zurückkehren.

"); + Serial.flush(); + ESP.restart(); + }); + wServer.onNotFound(notFound); wServer.begin(); } @@ -3077,9 +3044,6 @@ void loop() { lastTimeActiveTimestamp = millis(); // Re-adjust timer while client is connected to avoid ESP falling asleep } #endif - if (wifiManager() == WL_CONNECTED || accessPointStarted) { - //server.handleClient(); - } } diff --git a/src/websiteMgmt.h b/src/websiteMgmt.h index 7e26f79..212c960 100644 --- a/src/websiteMgmt.h +++ b/src/websiteMgmt.h @@ -38,6 +38,9 @@ static const char mgtWebsite[] PROGMEM = "\
  • \ Allgemein\
  • \ +
  • \ + Neustart Tonuino\ +
  • \ \ \ \