diff --git a/lib/groundlight/src/groundlight.cpp b/lib/groundlight/src/groundlight.cpp index d5eddb5..3d3e3c7 100644 --- a/lib/groundlight/src/groundlight.cpp +++ b/lib/groundlight/src/groundlight.cpp @@ -355,9 +355,11 @@ String get_query_id(const String &jsonResults) { DynamicJsonDocument results(1024); ArduinoJson::DeserializationError deserializeError = deserializeJson(results, jsonResults); if (deserializeError != ArduinoJson::DeserializationError::Ok) { + // Serial.println("Failed to parse JSON"); return "NONE"; } if (!results.containsKey("id")) { + // Serial.println("No query ID found in JSON"); return "NONE"; } return results["id"]; @@ -366,13 +368,11 @@ String get_query_id(const String &jsonResults) { StaticJsonDocument groundlight_json_doc; detector_list get_detector_list(const char *endpoint, const char *apiToken) { - String jsonResponse = get_detectors(endpoint, apiToken); - deserializeJson(groundlight_json_doc, jsonResponse); + deserializeJson(groundlight_json_doc, get_detectors(endpoint, apiToken)); JsonArray detectors = groundlight_json_doc["results"]; detector *_detector_list = new detector[detectors.size()]; for (int i = 0; i < detectors.size(); i++) { - JsonObject detectorObj = detectors[i]; _detector_list[i].confidence_threshold = detectors[i]["confidence_threshold"]; strcpy(_detector_list[i].id, detectors[i]["id"]); strcpy(_detector_list[i].type, detectors[i]["type"]); @@ -380,9 +380,9 @@ detector_list get_detector_list(const char *endpoint, const char *apiToken) { strcpy(_detector_list[i].name, detectors[i]["name"]); strcpy(_detector_list[i].query, detectors[i]["query"]); strcpy(_detector_list[i].group_name, detectors[i]["group_name"]); - if (!detectorObj["metadata"].isNull()) { + if (!detectors[i]["metadata"].isNull()) { String metadataStr; - serializeJson(detectorObj["metadata"], metadataStr); + serializeJson(detectors[i]["metadata"], metadataStr); strlcpy(_detector_list[i].metadata, metadataStr.c_str(), sizeof(_detector_list[i].metadata)); } else { _detector_list[i].metadata[0] = '\0'; diff --git a/src/deployable_example.cpp b/src/deployable_example.cpp index b03c1cb..485d44e 100644 --- a/src/deployable_example.cpp +++ b/src/deployable_example.cpp @@ -523,7 +523,7 @@ void setup() { // at http://192.168.4.1/ server.on("/", HTTP_GET, [](AsyncWebServerRequest *request){ request->send_P(200, "text/html", index_html, processor); - }); + }); server.on("/config", HTTP_GET, [] (AsyncWebServerRequest *request) { preferences.begin("config", false);