mirror of
https://github.com/suchmememanyskill/CYD-Klipper.git
synced 2026-03-21 13:43:25 +00:00
Null check in printer state
This commit is contained in:
@@ -18,13 +18,16 @@ void KlipperPrinter::parse_state(JsonDocument &in)
|
|||||||
const char *state = status["webhooks"]["state"];
|
const char *state = status["webhooks"]["state"];
|
||||||
const char *message = status["webhooks"]["state_message"];
|
const char *message = status["webhooks"]["state_message"];
|
||||||
|
|
||||||
if (strcmp(state, "ready") == 0 && printer_data.state == PrinterStateError)
|
if (state != NULL)
|
||||||
{
|
{
|
||||||
printer_data.state = PrinterStateIdle;
|
if (strcmp(state, "ready") == 0 && printer_data.state == PrinterStateError)
|
||||||
}
|
{
|
||||||
else if ((strcmp(state, "shutdown") == 0 || strcmp(state, "error") == 0) && printer_data.state != PrinterStateError)
|
printer_data.state = PrinterStateIdle;
|
||||||
{
|
}
|
||||||
printer_data.state = PrinterStateError;
|
else if ((strcmp(state, "shutdown") == 0 || strcmp(state, "error") == 0) && printer_data.state != PrinterStateError)
|
||||||
|
{
|
||||||
|
printer_data.state = PrinterStateError;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (message != NULL && (printer_data.state_message == NULL || strcmp(printer_data.state_message, message)))
|
if (message != NULL && (printer_data.state_message == NULL || strcmp(printer_data.state_message, message)))
|
||||||
|
|||||||
Reference in New Issue
Block a user