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:
+9
-10
@@ -26,7 +26,7 @@
|
||||
#include <fetchOTA.h>
|
||||
#include "time.h"
|
||||
#include "tools/log.h"
|
||||
#include "tools/ota_handler.h"
|
||||
#include "tools/ota.h"
|
||||
#include <LittleFS.h>
|
||||
|
||||
#include "esp_heap_caps.h"
|
||||
@@ -35,8 +35,6 @@
|
||||
|
||||
Preferences prefs;
|
||||
|
||||
extern AsyncWebSocket webSocket;
|
||||
|
||||
Version current_spiffs_version;
|
||||
|
||||
// Variable to store the current state of the system
|
||||
@@ -65,10 +63,6 @@ void setup()
|
||||
prefs.begin("waterlevel", false);
|
||||
Serial.begin(115200);
|
||||
|
||||
delay(500);
|
||||
LOG(ELOG_LEVEL_DEBUG, "Init Sensor");
|
||||
init_sensor();
|
||||
|
||||
LOG(ELOG_LEVEL_DEBUG, "Beginning LittleFS");
|
||||
LittleFS.begin(FORMAT_LITTLEFS_IF_FAILED);
|
||||
|
||||
@@ -95,9 +89,7 @@ void setup()
|
||||
xTaskCreate(collect_internal_telemetry_task, "InternalTelemetryTask", 1024 * 2, dataQueue, 1, NULL);
|
||||
xTaskCreate(display_task, "DisplayTask", 1024 * 2, NULL, 1, NULL);
|
||||
xTaskCreate(get_time_task, "GetTimeTask", 1024 * 2, NULL, 1, NULL);
|
||||
|
||||
delay(5000);
|
||||
xTaskCreate(check_update_task, "CheckUpdateTask", 1024 * 6, NULL, 1, NULL);
|
||||
xTaskCreate(check_update_task, "CheckUpdateTask", 1024 * 6, dataQueue, 1, NULL);
|
||||
xTaskCreate(webserver_task, "WebServerTask", 1024 * 4, stateForWebserverQueue, 1, NULL);
|
||||
xTaskCreate(ota_handler_task, "OTAHandlerTask", 1024 * 4, NULL, 3, NULL);
|
||||
}
|
||||
@@ -141,6 +133,13 @@ void loop()
|
||||
current_state.telemetryData.heap_used_percent, current_state.telemetryData.uptime_seconds,
|
||||
current_state.telemetryData.temperature);
|
||||
break;
|
||||
case DATA_TYPE_OTA:
|
||||
current_state.otaStatus = dataMessage.data.otaStatus;
|
||||
LOG(ELOG_LEVEL_DEBUG, "Received OTA status: update_available=%d, current=%d.%d.%d, latest=%d.%d.%d",
|
||||
current_state.otaStatus.update_available,
|
||||
current_state.otaStatus.current_version.major, current_state.otaStatus.current_version.minor, current_state.otaStatus.current_version.patch,
|
||||
current_state.otaStatus.latest_version.major, current_state.otaStatus.latest_version.minor, current_state.otaStatus.latest_version.patch);
|
||||
break;
|
||||
default:
|
||||
LOG(ELOG_LEVEL_ERROR, "Unknown data type received");
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user