diff --git a/README.md b/README.md index 486541a..be12dd7 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,7 @@ - [Hardware setup](#hardware-setup) - [Quick start](#quick-start) - [Update](#update) +- [Update over web-interface](#update-over-web-interface) - [Controls](Controls.md) - [MQTT](#mqtt) - [Home Assistant](#home-assistant) @@ -209,6 +210,16 @@ download _http://\/data/playlist.csv_ and _http://\/data 4. Go to page _http://\/_ in the browser and press Ctrl+F5 to update the scripts. 5. Well done! +## Update over web-interface +1. Backup your settings: \ +download _http://\/data/playlist.csv_ and _http://\/data/wifi.csv_ and place them in the yoRadio/data/data/ folder +2. Get firmware binary: Sketch → Export compiled binary +3. Get SPIFFS binary: disconnect ESP32 from your computer, click on **ESP32 Data Sketch Upload**. \ + You will get an error and file path + +4. Go to page _http://\/update_ and upload yoRadio.ino.esp32.bin and yoRadio.spiffs.bin in turn, checking the appropriate upload options. +5. Well done! + --- ## MQTT 1. Copy file exsamples/mqttoptions.h to yoRadio/ directory @@ -278,6 +289,11 @@ Work is in progress... --- ## Version history +#### v0.6.250 +- added update via web-interface \ + **Attention! Full firmware with chip re-partitioning is required!** see [board setup example](#quick-start) +- fixed choppy when switching stations via Home Assistant + #### v0.6.220 - new option PLAYER_FORCE_MONO (with i2S DAC only) - change default scroll speed in DSP_NOKIA5110 diff --git a/images/board3.jpg b/images/board3.jpg index 6ffe094..02399c1 100644 Binary files a/images/board3.jpg and b/images/board3.jpg differ diff --git a/images/getspiffs.jpg b/images/getspiffs.jpg new file mode 100644 index 0000000..fc17968 Binary files /dev/null and b/images/getspiffs.jpg differ diff --git a/yoRadio/controls.cpp b/yoRadio/controls.cpp index f9984b6..1c97d36 100644 --- a/yoRadio/controls.cpp +++ b/yoRadio/controls.cpp @@ -103,7 +103,7 @@ void initControls() { } void loopControls() { - if(display.mode==LOST) return; + if(display.mode==LOST || display.mode==UPDATING) return; #if ENC_BTNL!=255 encoderLoop(); #endif diff --git a/yoRadio/data/www/index.html b/yoRadio/data/www/index.html index 99695d6..9819375 100644 --- a/yoRadio/data/www/index.html +++ b/yoRadio/data/www/index.html @@ -15,7 +15,11 @@
diff --git a/yoRadio/data/www/script.js.gz b/yoRadio/data/www/script.js.gz index 84bc399..eaf2965 100644 Binary files a/yoRadio/data/www/script.js.gz and b/yoRadio/data/www/script.js.gz differ diff --git a/yoRadio/data/www/style.css.gz b/yoRadio/data/www/style.css.gz index 1c6937d..b56b91a 100644 Binary files a/yoRadio/data/www/style.css.gz and b/yoRadio/data/www/style.css.gz differ diff --git a/yoRadio/data/www/update.html b/yoRadio/data/www/update.html new file mode 100644 index 0000000..8ceecae --- /dev/null +++ b/yoRadio/data/www/update.html @@ -0,0 +1,38 @@ + + + + + + + + + + ёRadio-update + + + +
+ +
+
+
Please choose firmware or SPIFFS *.bin file
+
+
+ + +
+
+ + +
+
+ + Cancel +
+
+
powered by ёRadio | v%VERSION%
+
+ + + diff --git a/yoRadio/display.cpp b/yoRadio/display.cpp index 8a07b1d..2a1844a 100644 --- a/yoRadio/display.cpp +++ b/yoRadio/display.cpp @@ -328,6 +328,9 @@ void Display::swichMode(displayMode_e newmode) { if (newmode == LOST) { dsp.frameTitle("* LOST *"); } + if (newmode == UPDATING) { + dsp.frameTitle("* UPDATING *"); + } if (newmode == NUMBERS) { //dsp.frameTitle("STATION"); meta.reset(); diff --git a/yoRadio/display.h b/yoRadio/display.h index d66acef..a3a2c1a 100644 --- a/yoRadio/display.h +++ b/yoRadio/display.h @@ -36,7 +36,7 @@ #include "src/displays/displayCustom.h" #endif -enum displayMode_e { PLAYER, VOL, STATIONS, NUMBERS, LOST }; +enum displayMode_e { PLAYER, VOL, STATIONS, NUMBERS, LOST, UPDATING }; enum displayRequestType_e { NEWMODE, CLOCK, NEWTITLE, RETURNTITLE, NEWSTATION, NEXTSTATION, DRAWPLAYLIST, DRAWVOL }; struct requestParams_t diff --git a/yoRadio/mqtt.cpp b/yoRadio/mqtt.cpp index d95cc1e..91d42d7 100644 --- a/yoRadio/mqtt.cpp +++ b/yoRadio/mqtt.cpp @@ -88,7 +88,8 @@ void onMqttMessage(char* topic, char* payload, AsyncMqttClientMessageProperties return; } if (strcmp(buf, "start") == 0 || strcmp(buf, "play") == 0) { - player.play(config.store.lastStation); + //player.play(config.store.lastStation); + player.request.station = config.store.lastStation; return; } if (strcmp(buf, "boot") == 0 || strcmp(buf, "reboot") == 0) { @@ -114,7 +115,9 @@ void onMqttMessage(char* topic, char* payload, AsyncMqttClientMessageProperties if (sscanf(buf, "play %d", &sb) == 1 ) { if (sb < 1) sb = 1; if (sb >= config.store.countStation) sb = config.store.countStation; - player.play(sb); + //player.play(sb); + player.request.station = sb; + player.request.doSave = true; return; } } diff --git a/yoRadio/netserver.cpp b/yoRadio/netserver.cpp index cb337ab..03542ef 100644 --- a/yoRadio/netserver.cpp +++ b/yoRadio/netserver.cpp @@ -8,6 +8,7 @@ #include "options.h" #include "network.h" #include "mqtt.h" +#include #ifndef MIN_MALLOC #define MIN_MALLOC 24112 @@ -24,7 +25,14 @@ void handleUpload(AsyncWebServerRequest *request, String filename, size_t index, void onWsEvent(AsyncWebSocket *server, AsyncWebSocketClient *client, AwsEventType type, void *arg, uint8_t *data, size_t len); void handleHTTPPost(AsyncWebServerRequest * request); -byte ssidCount; +byte ssidCount; +bool shouldReboot = false; + +char* updateError(){ + static char ret[140] = {0}; + sprintf(ret, "Update failed with error (%d)
%s", (int)Update.getError(), Update.errorString()); + return ret; +} bool NetServer::begin() { importRequest = false; @@ -62,6 +70,40 @@ bool NetServer::begin() { webserver.on("/upload", HTTP_POST, [](AsyncWebServerRequest * request) { //request->send(200); }, handleUpload); + webserver.on("/update", HTTP_GET, [](AsyncWebServerRequest *request){ + request->send(SPIFFS, "/www/update.html", String(), false, processor); + }); + webserver.on("/update", HTTP_POST, [](AsyncWebServerRequest *request){ + shouldReboot = !Update.hasError(); + AsyncWebServerResponse *response = request->beginResponse(200, "text/plain", shouldReboot?"OK": updateError()); + response->addHeader("Connection", "close"); + request->send(response); + },[](AsyncWebServerRequest *request, String filename, size_t index, uint8_t *data, size_t len, bool final){ + if(!index){ + int target = (request->getParam("updatetarget", true)->value() == "spiffs") ? U_SPIFFS : U_FLASH; + Serial.printf("Update Start: %s\n", filename.c_str()); + player.mode = STOPPED; + display.putRequest({NEWMODE, UPDATING}); + if(!Update.begin(UPDATE_SIZE_UNKNOWN, target)){ + Update.printError(Serial); + request->send(200, "text/html", updateError()); + } + } + if(!Update.hasError()){ + if(Update.write(data, len) != len){ + Update.printError(Serial); + request->send(200, "text/html", updateError()); + } + } + if(final){ + if(Update.end(true)){ + Serial.printf("Update Success: %uB\n", index+len); + } else { + Update.printError(Serial); + request->send(200, "text/html", updateError()); + } + } + }); webserver.begin(); websocket.onEvent(onWsEvent); webserver.addHandler(&websocket); @@ -77,6 +119,11 @@ bool NetServer::begin() { } void NetServer::loop() { + if(shouldReboot){ + Serial.println("Rebooting..."); + delay(100); + ESP.restart(); + } websocket.cleanupClients(); if (playlistrequest > 0) { requestOnChange(PLAYLIST, playlistrequest); diff --git a/yoRadio/options.h b/yoRadio/options.h index db30ebf..a76852f 100644 --- a/yoRadio/options.h +++ b/yoRadio/options.h @@ -1,7 +1,7 @@ #ifndef options_h #define options_h -#define VERSION "0.6.220" +#define VERSION "0.6.250" /******************************************************* DO NOT EDIT THIS FILE. diff --git a/yoRadio/player.cpp b/yoRadio/player.cpp index 4f1cc01..8d5236c 100644 --- a/yoRadio/player.cpp +++ b/yoRadio/player.cpp @@ -59,7 +59,7 @@ void Player::loop() { if (isRunning()) { //digitalWrite(LED_BUILTIN, LOW); setOutputPins(false); - config.setTitle(display.mode==LOST?"":"[stopped]"); + config.setTitle((display.mode==LOST || display.mode==UPDATING)?"":"[stopped]"); netserver.requestOnChange(TITLE, 0); //stopSong(); setDefaults();