refactor(ota): implement polling-based update system and fix API typo
Test project compilation / test (push) Successful in 3m52s
Test project compilation / test (push) Successful in 3m52s
- Fix typo in OTA update status API endpoint (/ota_udpate_status → /ota_update_status) - Replace WebSocket-based update progress with polling mechanism - Add OTA lifecycle callbacks (started, finished, progress, error) - Implement check_update_task with internet connectivity verification - Add LittleFS/SPIFFS update support - Simplify update progress page to use 90-second delay and polling instead of real-time WebSocket updates This refactor improves reliability by checking internet connectivity before attempting updates and simplifies the frontend by removing WebSocket complexity in favor of a timeout-based polling approach.
This commit is contained in:
@@ -17,12 +17,12 @@
|
||||
#include "../global_data/global_data.h"
|
||||
#include "../tools/tools.h"
|
||||
#include "../tools/readers_writer_lock.h"
|
||||
#include "../tools/ota.h"
|
||||
#include "../global_data/defines.h"
|
||||
#include "json_builder.h"
|
||||
|
||||
extern Preferences prefs;
|
||||
|
||||
AsyncWebSocket webSocket("/webSocket");
|
||||
AsyncWebServer server(80);
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ ReadersWriterLock otaStatusLock;
|
||||
* @brief Sets up all routes for the webserver.
|
||||
*
|
||||
* Configures routes for serving HTML pages, handling form submissions,
|
||||
* REST API endpoints, WebSocket connections, and static assets.
|
||||
* REST API endpoints and static assets.
|
||||
*
|
||||
* @note Calls setup_api_endpoints() to configure API-specific routes.
|
||||
*/
|
||||
@@ -74,8 +74,6 @@ void setup_routes() {
|
||||
});
|
||||
|
||||
setup_api_endpoints();
|
||||
webSocket.onEvent(onWsEvent);
|
||||
server.addHandler(&webSocket);
|
||||
|
||||
server.on("/chota.css", HTTP_GET, [](AsyncWebServerRequest* request) { request->send(LittleFS, "/chota.css", "text/css", false); });
|
||||
server.on("/gauge.js", HTTP_GET, [](AsyncWebServerRequest* request) { request->send(LittleFS, "/gauge.js", "application/javascript", false); });
|
||||
@@ -331,7 +329,8 @@ void webserver_task(void *pvParameters) {
|
||||
local_ota_status.current_version = {0, 0, 0};
|
||||
local_ota_status.latest_version = {0, 0, 0};
|
||||
local_ota_status.update_progress = -1;
|
||||
local_ota_status.update_url = "UNKNOWN";
|
||||
strncpy(local_ota_status.update_url, "UNKNOWN", sizeof(local_ota_status.update_url) - 1);
|
||||
local_ota_status.update_url[sizeof(local_ota_status.update_url) - 1] = '\0';
|
||||
rwLockReleaseWrite(&otaStatusLock);
|
||||
|
||||
LOG(ELOG_LEVEL_DEBUG, "Starting webserver");
|
||||
|
||||
Reference in New Issue
Block a user