chore: update version to 1.5.1 and improve OTA update handling with task management
This commit is contained in:
parent
a450d4bd1a
commit
f73306f0b9
@ -9,8 +9,8 @@
|
|||||||
; https://docs.platformio.org/page/projectconf.html
|
; https://docs.platformio.org/page/projectconf.html
|
||||||
|
|
||||||
[common]
|
[common]
|
||||||
version = "1.4.14"
|
version = "1.5.1"
|
||||||
to_old_version = "1.4.0"
|
to_old_version = "1.5.0"
|
||||||
|
|
||||||
##
|
##
|
||||||
[env:esp32dev]
|
[env:esp32dev]
|
||||||
|
33
src/ota.cpp
33
src/ota.cpp
@ -1,6 +1,10 @@
|
|||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include <website.h>
|
#include <website.h>
|
||||||
#include <commonFS.h>
|
#include <commonFS.h>
|
||||||
|
#include "scale.h"
|
||||||
|
#include "bambu.h"
|
||||||
|
#include "nfc.h"
|
||||||
|
|
||||||
|
|
||||||
// Globale Variablen für Config Backups hinzufügen
|
// Globale Variablen für Config Backups hinzufügen
|
||||||
String bambuCredentialsBackup;
|
String bambuCredentialsBackup;
|
||||||
@ -151,6 +155,25 @@ void handleUpdate(AsyncWebServer &server) {
|
|||||||
|
|
||||||
updateHandler->onUpload([](AsyncWebServerRequest *request, String filename,
|
updateHandler->onUpload([](AsyncWebServerRequest *request, String filename,
|
||||||
size_t index, uint8_t *data, size_t len, bool final) {
|
size_t index, uint8_t *data, size_t len, bool final) {
|
||||||
|
|
||||||
|
// Disable all Tasks
|
||||||
|
if (BambuMqttTask != NULL)
|
||||||
|
{
|
||||||
|
Serial.println("Delete BambuMqttTask");
|
||||||
|
vTaskDelete(BambuMqttTask);
|
||||||
|
BambuMqttTask = NULL;
|
||||||
|
}
|
||||||
|
if (ScaleTask) {
|
||||||
|
Serial.println("Delete ScaleTask");
|
||||||
|
vTaskDelete(ScaleTask);
|
||||||
|
ScaleTask = NULL;
|
||||||
|
}
|
||||||
|
if (RfidReaderTask) {
|
||||||
|
Serial.println("Delete RfidReaderTask");
|
||||||
|
vTaskDelete(RfidReaderTask);
|
||||||
|
RfidReaderTask = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (!index) {
|
if (!index) {
|
||||||
updateTotalSize = request->contentLength();
|
updateTotalSize = request->contentLength();
|
||||||
updateWritten = 0;
|
updateWritten = 0;
|
||||||
@ -159,9 +182,9 @@ void handleUpdate(AsyncWebServer &server) {
|
|||||||
if (isSpiffsUpdate) {
|
if (isSpiffsUpdate) {
|
||||||
// Backup vor dem Update
|
// Backup vor dem Update
|
||||||
sendUpdateProgress(0, "backup", "Backing up configurations...");
|
sendUpdateProgress(0, "backup", "Backing up configurations...");
|
||||||
delay(200);
|
vTaskDelay(200 / portTICK_PERIOD_MS);
|
||||||
backupJsonConfigs();
|
backupJsonConfigs();
|
||||||
delay(200);
|
vTaskDelay(200 / portTICK_PERIOD_MS);
|
||||||
|
|
||||||
const esp_partition_t *partition = esp_partition_find_first(ESP_PARTITION_TYPE_DATA, ESP_PARTITION_SUBTYPE_DATA_SPIFFS, NULL);
|
const esp_partition_t *partition = esp_partition_find_first(ESP_PARTITION_TYPE_DATA, ESP_PARTITION_SUBTYPE_DATA_SPIFFS, NULL);
|
||||||
if (!partition || !Update.begin(partition->size, U_SPIFFS)) {
|
if (!partition || !Update.begin(partition->size, U_SPIFFS)) {
|
||||||
@ -169,14 +192,14 @@ void handleUpdate(AsyncWebServer &server) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
sendUpdateProgress(5, "starting", "Starting SPIFFS update...");
|
sendUpdateProgress(5, "starting", "Starting SPIFFS update...");
|
||||||
delay(200);
|
vTaskDelay(200 / portTICK_PERIOD_MS);
|
||||||
} else {
|
} else {
|
||||||
if (!Update.begin(updateTotalSize)) {
|
if (!Update.begin(updateTotalSize)) {
|
||||||
request->send(400, "application/json", "{\"success\":false,\"message\":\"Update initialization failed\"}");
|
request->send(400, "application/json", "{\"success\":false,\"message\":\"Update initialization failed\"}");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
sendUpdateProgress(0, "starting", "Starting firmware update...");
|
sendUpdateProgress(0, "starting", "Starting firmware update...");
|
||||||
delay(200);
|
vTaskDelay(200 / portTICK_PERIOD_MS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -202,7 +225,7 @@ void handleUpdate(AsyncWebServer &server) {
|
|||||||
if (currentProgress != lastProgress && (currentProgress % 10 == 0 || final)) {
|
if (currentProgress != lastProgress && (currentProgress % 10 == 0 || final)) {
|
||||||
sendUpdateProgress(currentProgress, "uploading");
|
sendUpdateProgress(currentProgress, "uploading");
|
||||||
oledShowMessage("Update: " + String(currentProgress) + "%");
|
oledShowMessage("Update: " + String(currentProgress) + "%");
|
||||||
delay(50);
|
vTaskDelay(50 / portTICK_PERIOD_MS);
|
||||||
lastProgress = currentProgress;
|
lastProgress = currentProgress;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user