diff --git a/yoRadio/data/www/settings.css.gz b/yoRadio/data/www/settings.css.gz index 0b0e20d..40da547 100644 Binary files a/yoRadio/data/www/settings.css.gz and b/yoRadio/data/www/settings.css.gz differ diff --git a/yoRadio/data/www/settings.html b/yoRadio/data/www/settings.html index d388dec..ea4d647 100644 --- a/yoRadio/data/www/settings.html +++ b/yoRadio/data/www/settings.html @@ -38,6 +38,7 @@ +
update
Firmware
Board
diff --git a/yoRadio/src/core/netserver.cpp b/yoRadio/src/core/netserver.cpp index ff91ff8..96d1600 100644 --- a/yoRadio/src/core/netserver.cpp +++ b/yoRadio/src/core/netserver.cpp @@ -56,7 +56,18 @@ bool NetServer::begin() { while(nsQueue==NULL){;} if(config.emptyFS){ webserver.on("/", HTTP_GET, [](AsyncWebServerRequest * request) { request->send_P(200, "text/html", emptyfs_html, processor); }); - webserver.on("/", HTTP_POST, [](AsyncWebServerRequest *request) { request->redirect("/"); ESP.restart(); }, handleUploadWeb); + webserver.on("/", HTTP_POST, [](AsyncWebServerRequest *request) { + if(request->arg("ssid")!="" && request->arg("pass")!=""){ + char buf[BUFLEN]; + memset(buf, 0, BUFLEN); + snprintf(buf, BUFLEN, "%s\t%s", request->arg("ssid"), request->arg("pass")); + request->redirect("/"); + config.saveWifiFromNextion(buf); + return; + } + request->redirect("/"); + ESP.restart(); + }, handleUploadWeb); }else{ webserver.on("/", HTTP_ANY, handleHTTPArgs); webserver.on("/webboard", HTTP_GET, [](AsyncWebServerRequest * request) { request->send_P(200, "text/html", emptyfs_html, processor); }); @@ -650,7 +661,8 @@ void NetServer::requestOnChange(requestType_e request, uint8_t clientId) { } String processor(const String& var) { // %Templates% - if (var == "ACTION") return network.status == CONNECTED?"webboard":""; + if (var == "ACTION") return (network.status == CONNECTED && !config.emptyFS)?"webboard":""; + if (var == "UPLOADWIFI") return (network.status == CONNECTED || SPIFFS.exists("/data/wifi.csv"))?" hidden":""; if (var == "VERSION") return YOVERSION; if (var == "MODE") { if(config.store.play_mode==PM_SDCARD) { @@ -690,6 +702,7 @@ void handleUploadWeb(AsyncWebServerRequest *request, String filename, size_t ind } if (final) { request->_tempFile.close(); + if(filename=="playlist.csv") config.indexPlaylist(); } } diff --git a/yoRadio/src/core/netserver.h b/yoRadio/src/core/netserver.h index 38b4055..036f79a 100644 --- a/yoRadio/src/core/netserver.h +++ b/yoRadio/src/core/netserver.h @@ -8,23 +8,35 @@ enum requestType_e : uint8_t { PLAYLIST=1, STATION=2, STATIONNAME=3, ITEM=4, TITLE=5, VOLUME=6, NRSSI=7, BITRATE=8, MODE=9, EQUALIZER=10, BALANCE=11, PLAYLISTSAVED=12, GETMODE=13, GETINDEX=14, GETACTIVE=15, GETSYSTEM=16, GETSCREEN=17, GETTIMEZONE=18, GETWEATHER=19, GETCONTROLS=20, DSPON=21, SDPOS=22, SDLEN=23, SDSNUFFLE=24 }; enum import_e : uint8_t { IMDONE=0, IMPL=1, IMWIFI=2 }; const char emptyfs_html[] PROGMEM = R"( -ёRadio - WEB Board Uploader +ёRadio - WEB Board Uploader

ёRadio - WEB Board Uploader


-Please select ALL files from yoRadio/data/www/ and upload them using the form below +Select ALL files from yoRadio/data/www/
and upload them using the form below


-Optional, you can also upload playlist.csv and wifi.csv files from backup +-= OPTIONAL =-
You can also upload playlist.csv
and wifi.csv files from your backup


-

+

+
+
+
+-= OPTIONAL =-
If you can't connect from PC to 192.168.4.1 address
setup WiFi connection first
+
+
+
+

+
+
)"; diff --git a/yoRadio/src/core/network.cpp b/yoRadio/src/core/network.cpp index da0e5b4..bcbc596 100644 --- a/yoRadio/src/core/network.cpp +++ b/yoRadio/src/core/network.cpp @@ -261,6 +261,15 @@ bool getWeather(char *wstr) { cursor = tmpe + 2; float tempfl = atof(temp); (void)tempfl; + tmps = strstr(cursor, "\"pressure\":"); + if (tmps == NULL) { Serial.println("## OPENWEATHERMAP ###: pressure not found !"); return false;} + tmps += 11; + tmpe = strstr(tmps, ",\""); + if (tmpe == NULL) { Serial.println("## OPENWEATHERMAP ###: pressure not found !"); return false;} + strlcpy(press, tmps, tmpe - tmps + 1); + cursor = tmpe + 2; + int pressi = (float)atoi(press) / 1.333; + tmps = strstr(cursor, "humidity\":"); if (tmps == NULL) { Serial.println("## OPENWEATHERMAP ###: humidity not found !"); return false;} tmps += 10; @@ -270,13 +279,15 @@ bool getWeather(char *wstr) { strlcpy(hum, tmps, tmpe - tmps + (tmpc>tmpe?1:0)); tmps = strstr(cursor, "\"grnd_level\":"); - if (tmps == NULL) { Serial.println("## OPENWEATHERMAP ###: pressure not found !"); return false;} - tmps += 13; - tmpe = strstr(tmps, ",\""); - if (tmpe == NULL) { Serial.println("## OPENWEATHERMAP ###: pressure not found !"); return false;} - strlcpy(press, tmps, tmpe - tmps + 1); - cursor = tmpe + 2; - int pressi = (float)atoi(press) / 1.333; + bool grnd_level_pr = (tmps != NULL); + if(grnd_level_pr){ + tmps += 13; + tmpe = strstr(tmps, ",\""); + if (tmpe == NULL) { Serial.println("## OPENWEATHERMAP ###: grnd_level not found !"); return false;} + strlcpy(press, tmps, tmpe - tmps + 1); + cursor = tmpe + 2; + pressi = (float)atoi(press) / 1.333; + } tmps = strstr(cursor, "\"speed\":"); if (tmps == NULL) { Serial.println("## OPENWEATHERMAP ###: wind speed not found !"); return false;}