Skip to content

Commit

Permalink
more cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Supersilvia authored and Supersilvia committed Mar 11, 2024
1 parent 622f25e commit 36a2354
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions lib/groundlight/src/groundlight.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"];
Expand All @@ -366,23 +368,21 @@ String get_query_id(const String &jsonResults) {
StaticJsonDocument<DET_DOC_SIZE> 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"]);
strcpy(_detector_list[i].created_at, detectors[i]["created_at"]);
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';
Expand Down
2 changes: 1 addition & 1 deletion src/deployable_example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 36a2354

Please sign in to comment.