Compare commits

...

2 Commits

Author SHA1 Message Date
47470eb944 Merge pull request #51 from Anzarion/main
Fix: Add NULL checks to prevent crash without RFID module
2025-10-15 15:37:20 +02:00
Anzarion
e1da8eb525 Fix: Add NULL checks to prevent crash without RFID module
- Added NULL checks before vTaskSuspend/vTaskResume in scale.cpp
- Prevents crash when calibrating without RFID module connected
- Allows scale to work as standalone device without RFID
2025-09-30 10:37:58 +02:00
2 changed files with 6 additions and 6 deletions

View File

@@ -28,7 +28,7 @@ int16_t lastDisplayedWeight = 0;
int16_t lastStableWeight = 0; // For API/action triggering
unsigned long lastMeasurementTime = 0;
uint8_t weigthCouterToApi = 0;
uint8_t weightCounterToApi = 0;
uint8_t scale_tare_counter = 0;
bool scaleTareRequest = false;
uint8_t pauseMainTask = 0;
@@ -285,8 +285,8 @@ uint8_t calibrate_scale() {
scaleCalibrationActive = true;
vTaskSuspend(RfidReaderTask);
vTaskSuspend(ScaleTask);
if (RfidReaderTask != NULL) vTaskSuspend(RfidReaderTask);
if (ScaleTask != NULL) vTaskSuspend(ScaleTask);
pauseBambuMqttTask = true;
pauseMainTask = 1;
@@ -393,8 +393,8 @@ uint8_t calibrate_scale() {
returnState = 0;
}
vTaskResume(RfidReaderTask);
vTaskResume(ScaleTask);
if (RfidReaderTask != NULL) vTaskResume(RfidReaderTask);
if (ScaleTask != NULL) vTaskResume(ScaleTask);
pauseBambuMqttTask = false;
pauseMainTask = 0;
scaleCalibrationActive = false;

View File

@@ -18,7 +18,7 @@ int16_t getFilteredDisplayWeight();
extern HX711 scale;
extern int16_t weight;
extern uint8_t weigthCouterToApi;
extern uint8_t weightCounterToApi;
extern uint8_t scale_tare_counter;
extern uint8_t scaleTareRequest;
extern uint8_t pauseMainTask;