Skip to content

Commit 82f9ee7

Browse files
author
darkpoet78
committed
2025.08.20
1 parent 55d249e commit 82f9ee7

7 files changed

Lines changed: 31 additions & 30 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Documentation will be slowly improved.
1717

1818

1919
### 2025.08.20
20-
- Fixes to Online updater
20+
- Major fixes to online updater (if running an older version, need to manually flash)
2121
- WebUI fixed for mobile displays
2222
- MQTT added to WebUI options / defaults set by adding defines to `myoptions.h`
2323
- `#define MQTT_ENABLE` to enable (will not be available otherwise)

builds/trip5/myoptions.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@
254254

255255
//#define ROTATE_90 /* rotates 90 degrees? */
256256

257-
//#define ESPFILEUPDATER_DEBUG
257+
#define ESPFILEUPDATER_DEBUG
258258

259259
/* Extras: unused in all */
260260
//#define L10N_LANGUAGE EN

data/www/script.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ function onMessage(event) {
7070
const btn = getId('check_online_update');
7171
if(btn) {
7272
if(data.onlineupdateavailable) {
73-
btn.value = "Update to v" + data.remoteVersion;
73+
btn.value = "Update to " + data.remoteVersion;
7474
btn.disabled = false;
7575
} else {
7676
btn.value = "No Update Available";

src/core/config.cpp

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,7 @@ void Config::init() {
8686
BOOTLOG("SPIFFS is empty!");
8787
#else
8888
BOOTLOG("SPIFFS is missing files. Will attempt to get files from online...");
89-
config.deleteMainDatawwwFile();
90-
getRequiredFiles();
91-
delay(200);
92-
ESP.restart();
89+
deleteMainDatawwwFile();
9390
#endif
9491
}
9592
ssidsCount = 0;
@@ -1174,12 +1171,12 @@ void Config::deleteMainDatawwwFile() {
11741171
if (requiredFilesCount > 0) {
11751172
const char* lastFile = requiredFiles[requiredFilesCount - 1];
11761173
char mainfile[64];
1177-
snprintf(mainfile, sizeof(mainfile), "www/%s", lastFile);
1174+
snprintf(mainfile, sizeof(mainfile), "/www/%s", lastFile);
11781175
if (SPIFFS.exists(mainfile)) {
11791176
SPIFFS.remove(mainfile);
11801177
Serial.printf("[Config] Deleted main www file: %s\n", mainfile);
11811178
}
1182-
snprintf(mainfile, sizeof(mainfile), "www/%s.gz", lastFile);
1179+
snprintf(mainfile, sizeof(mainfile), "/www/%s.gz", lastFile);
11831180
if (SPIFFS.exists(mainfile)) {
11841181
SPIFFS.remove(mainfile);
11851182
Serial.printf("[Config] Deleted main www file: %s\n", mainfile);
@@ -1188,7 +1185,7 @@ void Config::deleteMainDatawwwFile() {
11881185
}
11891186

11901187
void cleanStaleSearchResults() {
1191-
const char* metaPath = "/data/searchresults.json.meta";
1188+
const char* metaPath = "/www/searchresults.json.meta";
11921189
if (SPIFFS.exists(metaPath)) {
11931190
File metaFile = SPIFFS.open(metaPath, "r");
11941191
metaFile.readStringUntil('\n'); // 1st line query
@@ -1200,8 +1197,8 @@ void cleanStaleSearchResults() {
12001197
if (now < 100000000 || (now - fileTime) > 86400) {
12011198
Serial.print("Cleaning stale search results.\n");
12021199
SPIFFS.remove(metaPath);
1203-
SPIFFS.remove("/data/searchresults.json");
1204-
SPIFFS.remove("/data/search.txt");
1200+
SPIFFS.remove("/www/searchresults.json");
1201+
SPIFFS.remove("/www/search.txt");
12051202
}
12061203
}
12071204
}
@@ -1225,14 +1222,14 @@ void fixPlaylistFileEnding() {
12251222
}
12261223

12271224
#ifdef UPDATEURL
1228-
void Config::getRequiredFiles() {
1225+
void getRequiredFiles(void* param) {
12291226
player.sendCommand({PR_STOP, 0});
1230-
display.putRequest(NEWMODE, UPDATING);
12311227
char localFileGz[64];
12321228
char localFile[64];
12331229
char tryFile[64];
12341230
char tryUrl[128];
12351231
for (size_t i = 0; i < requiredFilesCount; i++) {
1232+
display.putRequest(NEWMODE, UPDATING);
12361233
const char* fname = requiredFiles[i];
12371234
snprintf(localFileGz, sizeof(localFileGz), "/www/%s.gz", fname);
12381235
snprintf(localFile, sizeof(localFile), "/www/%s", fname);
@@ -1247,9 +1244,8 @@ void fixPlaylistFileEnding() {
12471244
snprintf(tryUrl, sizeof(tryUrl), "%s%s", UPDATEURL, fname);
12481245
}
12491246
Serial.printf("[ESPFileUpdater: %s] Updating required file.\n", tryFile);
1250-
ESPFileUpdater updater(SPIFFS);
1251-
updater.setTimeout(5000);
1252-
ESPFileUpdater::UpdateStatus result = updater.checkAndUpdate(
1247+
ESPFileUpdater* getfile = (ESPFileUpdater*)param;
1248+
ESPFileUpdater::UpdateStatus result = getfile->checkAndUpdate(
12531249
tryFile,
12541250
tryUrl,
12551251
"",
@@ -1291,15 +1287,16 @@ void fixPlaylistFileEnding() {
12911287
file = root.openNextFile();
12921288
}
12931289
}
1290+
delay(200);
1291+
ESP.restart();
1292+
vTaskDelete(NULL);
12941293
}
12951294
#endif //#ifdef UPDATEURL
12961295

12971296
void Config::updateFile(void* param, const char* localFile, const char* onlineFile, const char* updatePeriod, const char* simpleName) {
1298-
char startMsg[128];
1299-
snprintf(startMsg, sizeof(startMsg), "[ESPFileUpdater: %s] Started update.", simpleName);
1300-
Serial.println(startMsg);
1301-
ESPFileUpdater* updater = (ESPFileUpdater*)param;
1302-
ESPFileUpdater::UpdateStatus result = updater->checkAndUpdate(
1297+
Serial.printf("[ESPFileUpdater: %s] Started update.\n", simpleName);
1298+
ESPFileUpdater* updatefile = (ESPFileUpdater*)param;
1299+
ESPFileUpdater::UpdateStatus result = updatefile->checkAndUpdate(
13031300
localFile,
13041301
onlineFile,
13051302
updatePeriod,
@@ -1314,7 +1311,7 @@ void Config::updateFile(void* param, const char* localFile, const char* onlineFi
13141311
}
13151312
}
13161313

1317-
void startAsyncServices(void* param){
1314+
void startAsyncServices(void* param) {
13181315
fixPlaylistFileEnding();
13191316
config.updateFile(param, "/www/timezones.json.gz", TIMEZONES_JSON_URL, "1 week", "Timezones database file");
13201317
config.updateFile(param, "/www/rb_srvrs.json", RADIO_BROWSER_SERVERS_URL, "4 weeks", "Radio Browser Servers list");
@@ -1328,7 +1325,13 @@ void Config::startAsyncServicesButWait() {
13281325
updater = new ESPFileUpdater(SPIFFS);
13291326
updater->setMaxSize(1024);
13301327
updater->setUserAgent(ESPFILEUPDATER_USERAGENT);
1331-
xTaskCreate(startAsyncServices, "startAsyncServices", 8192, updater, 2, NULL);
1328+
if (emptyFS) {
1329+
#ifdef UPDATEURL
1330+
xTaskCreate(getRequiredFiles, "getRequiredFiles", 8192, updater, 2, NULL);
1331+
#endif
1332+
} else {
1333+
xTaskCreate(startAsyncServices, "startAsyncServices", 8192, updater, 2, NULL);
1334+
}
13321335
}
13331336

13341337
void Config::bootInfo() {

src/core/config.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,6 @@ class Config {
228228
void initPlaylist();
229229
void indexPlaylist();
230230
void deleteMainDatawwwFile();
231-
void getRequiredFiles();
232231
void startAsyncServicesButWait();
233232
void updateFile(void* param, const char* localFile, const char* onlineFile, const char* updatePeriod, const char* simpleName);
234233
#ifdef USE_SD

src/core/netserver.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,15 +1041,14 @@ void launchPlaybackTask(const String& url, const String& name) {
10411041
websocket.textAll(progMsg);
10421042
}
10431043
}
1044-
bool ended = Update.end();
1045-
Serial.printf("[Online Update] Written %u bytes, expected %d, end() returned %s\n", written, contentLength, ended?"true":"false");
1046-
if (written == contentLength && ended) {
1044+
if (Update.end(true)) { // end(true) will finish and commit the update
1045+
Serial.println("[Online Update] Update successful, rebooting...");
10471046
config.deleteMainDatawwwFile();
10481047
websocket.textAll("{\"onlineupdatestatus\": \"Update successful, rebooting...\"}");
10491048
delay(1000);
10501049
ESP.restart();
10511050
} else {
1052-
websocket.textAll("{\"onlineupdateerror\": \"Update failed or incomplete\"}");
1051+
websocket.textAll(String("{\"onlineupdateerror\": \"Update failed on end(): ") + String(Update.errorString()) + "\"}");
10531052
}
10541053
} else {
10551054
websocket.textAll("{\"onlineupdateerror\": \"Cannot begin update (reboot then try again)\"}");

src/core/options.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#ifndef options_h
22
#define options_h
33

4-
#define RADIOVERSION "2025.08.20"
4+
#define RADIOVERSION "2025.08.20a"
55

66
/*******************************************************
77
DO NOT EDIT THIS FILE.

0 commit comments

Comments
 (0)