diff --git a/yoRadio/data/www/script.js.gz b/yoRadio/data/www/script.js.gz
index e12541b..f1b23ed 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/settings.html b/yoRadio/data/www/settings.html
index 4d6618e..d388dec 100644
--- a/yoRadio/data/www/settings.html
+++ b/yoRadio/data/www/settings.html
@@ -39,7 +39,8 @@
-
Firmware update
+
Firmware
+
Board
diff --git a/yoRadio/src/core/config.cpp b/yoRadio/src/core/config.cpp
index c1495fc..b650d44 100644
--- a/yoRadio/src/core/config.cpp
+++ b/yoRadio/src/core/config.cpp
@@ -15,8 +15,20 @@ void u8fix(char *src){
if ((uint8_t)last >= 0xC2) src[strlen(src)-1]='\0';
}
+bool Config::_isFSempty() {
+ const char* reqiredFiles[] = {"dragpl.js.gz","elogo.png","elogo84.png","index.html","ir.css.gz","ir.html","ir.js.gz","script.js.gz","settings.css.gz","settings.html","style.css.gz","update.html"};
+ const uint8_t reqiredFilesSize = 12;
+ char fullpath[28];
+ for (uint8_t i=0; i 0) {
store.lastStation = 1;
@@ -50,18 +66,23 @@ void Config::init() {
}
loadStation(store.lastStation);
-#if IR_PIN!=255
+
+ bootInfo();
+}
+
+void Config::_initHW(){
+ loadTheme();
+ #if IR_PIN!=255
eepromRead(EEPROM_START_IR, ircodes);
if(ircodes.ir_set!=4224){
ircodes.ir_set=4224;
memset(ircodes.irVals, 0, sizeof(ircodes.irVals));
}
-#endif
-#if BRIGHTNESS_PIN!=255
- pinMode(BRIGHTNESS_PIN, OUTPUT);
- setBrightness(false);
-#endif
- bootInfo();
+ #endif
+ #if BRIGHTNESS_PIN!=255
+ pinMode(BRIGHTNESS_PIN, OUTPUT);
+ setBrightness(false);
+ #endif
}
uint16_t Config::color565(uint8_t r, uint8_t g, uint8_t b)
diff --git a/yoRadio/src/core/config.h b/yoRadio/src/core/config.h
index c84b861..79c526e 100644
--- a/yoRadio/src/core/config.h
+++ b/yoRadio/src/core/config.h
@@ -157,6 +157,7 @@ class Config {
uint32_t sdResumePos;
uint16_t backupLastStation;
bool sdSnuffle;
+ bool emptyFS;
public:
Config() {};
void save();
@@ -206,6 +207,8 @@ class Config {
void initSDPlaylist();
void indexSDPlaylist();
bool checkNoMedia(const char* path);
+ void _initHW();
+ bool _isFSempty();
};
extern Config config;
diff --git a/yoRadio/src/core/netserver.cpp b/yoRadio/src/core/netserver.cpp
index 706e0dc..ff91ff8 100644
--- a/yoRadio/src/core/netserver.cpp
+++ b/yoRadio/src/core/netserver.cpp
@@ -25,6 +25,7 @@ AsyncUDP udp;
String processor(const String& var);
void handleUpload(AsyncWebServerRequest *request, String filename, size_t index, uint8_t *data, size_t len, bool final);
+void handleUploadWeb(AsyncWebServerRequest *request, String filename, size_t index, uint8_t *data, size_t len, bool final);
void handleUpdate(AsyncWebServerRequest *request, String filename, size_t index, uint8_t *data, size_t len, bool final);
void handleHTTPArgs(AsyncWebServerRequest * request);
void onWsEvent(AsyncWebSocket *server, AsyncWebSocketClient *client, AwsEventType type, void *arg, uint8_t *data, size_t len);
@@ -53,12 +54,21 @@ bool NetServer::begin() {
irRecordEnable = false;
nsQueue = xQueueCreate( 20, sizeof( nsRequestParams_t ) );
while(nsQueue==NULL){;}
- webserver.on("/", HTTP_ANY, handleHTTPArgs);
+ 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);
+ }else{
+ webserver.on("/", HTTP_ANY, handleHTTPArgs);
+ webserver.on("/webboard", HTTP_GET, [](AsyncWebServerRequest * request) { request->send_P(200, "text/html", emptyfs_html, processor); });
+ webserver.on("/webboard", HTTP_POST, [](AsyncWebServerRequest *request) { request->redirect("/"); }, handleUploadWeb);
+ }
+
webserver.on(PLAYLIST_PATH, HTTP_GET, handleHTTPArgs);
webserver.on(INDEX_PATH, HTTP_GET, handleHTTPArgs);
webserver.on(PLAYLIST_SD_PATH, HTTP_GET, handleHTTPArgs);
webserver.on(INDEX_SD_PATH, HTTP_GET, handleHTTPArgs);
webserver.on(SSIDS_PATH, HTTP_GET, handleHTTPArgs);
+
webserver.on("/upload", HTTP_POST, beginUpload, handleUpload);
webserver.on("/update", HTTP_GET, handleHTTPArgs);
webserver.on("/update", HTTP_POST, beginUpdate, handleUpdate);
@@ -640,6 +650,7 @@ 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 == "VERSION") return YOVERSION;
if (var == "MODE") {
if(config.store.play_mode==PM_SDCARD) {
@@ -653,6 +664,9 @@ String processor(const String& var) { // %Templates%
void handleUpload(AsyncWebServerRequest *request, String filename, size_t index, uint8_t *data, size_t len, bool final) {
if (!index) {
+ //String spath = "/www/";
+ //if(filename=="playlist.csv" || filename=="wifi.csv") spath = "/data/";
+ //request->_tempFile = SPIFFS.open(config.emptyFS?spath + filename:TMP_PATH , "w");
request->_tempFile = SPIFFS.open(TMP_PATH , "w");
}
if (len) {
@@ -664,6 +678,21 @@ void handleUpload(AsyncWebServerRequest *request, String filename, size_t index,
}
}
+void handleUploadWeb(AsyncWebServerRequest *request, String filename, size_t index, uint8_t *data, size_t len, bool final) {
+ DBGVB("File: %s, size:%u bytes, index: %u, final: %s\n", filename.c_str(), len, index, final?"true":"false");
+ if (!index) {
+ String spath = "/www/";
+ if(filename=="playlist.csv" || filename=="wifi.csv") spath = "/data/";
+ request->_tempFile = SPIFFS.open(spath + filename , "w");
+ }
+ if (len) {
+ request->_tempFile.write(data, len);
+ }
+ if (final) {
+ request->_tempFile.close();
+ }
+}
+
void onWsEvent(AsyncWebSocket *server, AsyncWebSocketClient *client, AwsEventType type, void *arg, uint8_t *data, size_t len) {
switch (type) {
case WS_EVT_CONNECT: if (config.store.audioinfo) Serial.printf("[WEBSOCKET] client #%u connected from %s\n", client->id(), client->remoteIP().toString().c_str()); break;
diff --git a/yoRadio/src/core/netserver.h b/yoRadio/src/core/netserver.h
index 9a73b43..38b4055 100644
--- a/yoRadio/src/core/netserver.h
+++ b/yoRadio/src/core/netserver.h
@@ -7,6 +7,27 @@
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
+
+Please select ALL files from yoRadio/data/www/ and upload them using the form below
+
+
+
+
+)";
struct nsRequestParams_t
{