From 4602b4a35b9db3be3718454aa67f18b9d88a98d5 Mon Sep 17 00:00:00 2001 From: Matthew Frost Date: Wed, 27 Dec 2023 22:17:00 +0100 Subject: [PATCH] better handling of backend not being reachable --- src/main.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index fe6cbcd..7ec3c92 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -334,13 +334,15 @@ void handleData1Interrupt() { // Process the response DynamicJsonDocument json = httpClient.decodeJsonResponse(response); - bool DisableDoor = json["enabled"].as(); - settings.setDisableDoor(!DisableDoor); + if (json.containsKey("enabled")) { + bool DisableDoor = json["enabled"].as(); + settings.setDisableDoor(!DisableDoor); + #ifdef SERIAL_DEBUG + Serial.println("JSON Reader Enabled: " + json["enabled"].as()); + #endif + } + - #ifdef SERIAL_DEBUG - Serial.println("JSON Reader Enabled: " + json["enabled"].as()); - #endif - } }