feat: add task handles for BambuMqttTask and ScaleTask; rename stopTasks to stopAllTasks

This commit is contained in:
Manuel Weiser 2025-02-20 11:52:36 +01:00
parent 4475d21218
commit 6f24630a7d
3 changed files with 12 additions and 4 deletions

View File

@ -36,4 +36,5 @@ void mqtt_loop(void * parameter);
bool setBambuSpool(String payload);
void bambu_restart();
extern TaskHandle_t BambuMqttTask;
#endif

View File

@ -3,14 +3,20 @@
#include <Update.h>
#include <SPIFFS.h>
#include "commonFS.h"
#include "bambu.h"
#include "scale.h"
#include "nfc.h"
// Magic byte patterns für verschiedene Image-Typen
const uint8_t FIRMWARE_MAGIC = 0xE9;
const uint8_t ESP_MAGIC = 0xE9;
void stopTasks() {
void stopAllTasks() {
// Stop all tasks
vTaskSuspend(NULL);
vTaskSuspend(NfcTask);
vTaskSuspend(BambuMqttTask);
vTaskSuspend(ScaleTask);
//vTaskDelay(100 / portTICK_PERIOD_MS);
}
void handleOTAUpload(AsyncWebServerRequest *request, String filename, size_t index, uint8_t *data, size_t len, bool final) {
@ -21,8 +27,7 @@ void handleOTAUpload(AsyncWebServerRequest *request, String filename, size_t ind
static size_t spiffsSize = 0;
static const uint32_t SPIFFS_START = 0x310000; // SPIFFS start in full.bin
stopTasks();
vTaskDelay(100 / portTICK_PERIOD_MS);
stopAllTasks();
if (!index) {
// Reset static variables

View File

@ -15,4 +15,6 @@ extern uint8_t weigthCouterToApi;
extern uint8_t scale_tare_counter;
extern uint8_t pauseMainTask;
extern TaskHandle_t ScaleTask;
#endif