-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Esp form uiupdate #36
Changes from all commits
594e9f1
181a153
59ab9e5
3311159
a12ab27
cbaa34d
7a062dc
d73f694
92db600
4f85775
2a0a597
0ac74ac
1b77c3d
e155974
b4b85fd
25884fb
a88b352
c2edc65
f955b19
faff733
622f25e
36a2354
8541346
bc3959b
40dff69
3400ef8
8c76559
94bb462
257c216
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -367,20 +367,26 @@ String get_query_id(const String &jsonResults) { | |
|
||
StaticJsonDocument<DET_DOC_SIZE> groundlight_json_doc; | ||
|
||
// Parses the detectors from the Groundlight API. | ||
detector_list get_detector_list(const char *endpoint, const char *apiToken) { | ||
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++) | ||
{ | ||
_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"]); | ||
strlcpy(_detector_list[i].id, detectors[i]["id"], sizeof(_detector_list[i].id)); | ||
strlcpy(_detector_list[i].type, detectors[i]["type"], sizeof(_detector_list[i].type)); | ||
strlcpy(_detector_list[i].created_at, detectors[i]["created_at"], sizeof((_detector_list[i].created_at))); | ||
strlcpy(_detector_list[i].name, detectors[i]["name"], sizeof(_detector_list[i].name)); | ||
strlcpy(_detector_list[i].query, detectors[i]["query"], sizeof(_detector_list[i].query)); | ||
strlcpy(_detector_list[i].group_name, detectors[i]["group_name"], sizeof(_detector_list[i].group_name)); | ||
if (!detectors[i]["metadata"].isNull()) { | ||
String 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'; | ||
} | ||
} | ||
detector_list res = { _detector_list, detectors.size() }; | ||
return res; | ||
|
@@ -401,16 +407,38 @@ String detector_to_string(detector d) { | |
res += d.group_name; | ||
res += "\n\tConfidence threshold: "; | ||
res += d.confidence_threshold; | ||
res += "\n\tMetadata: "; | ||
res += d.metadata; | ||
return res; | ||
} | ||
|
||
detector get_detector_by_id(const char *endpoint, const char *detectorId, const char *apiToken) { | ||
detector_list detectors = get_detector_list(endpoint, apiToken); | ||
detector det = { "NONE", "NONE", "NONE", "NONE", "NONE", "NONE", 0.0, "None" }; | ||
for (int i = 0; i < detectors.size; i++) { | ||
if (String(detectors.detectors[i].id) == String(detectorId)) { | ||
return detectors.detectors[i]; | ||
det = detectors.detectors[i]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can probably stop iterating ? |
||
break; | ||
} | ||
} | ||
if (0<detectors.size){ | ||
delete[] detectors.detectors; | ||
} | ||
return det; | ||
} | ||
|
||
detector get_detector_by_name(const char *endpoint, const char *detectorName, const char *apiToken) { | ||
detector_list detectors = get_detector_list(endpoint, apiToken); | ||
detector det = { "NONE", "NONE", "NONE", "NONE", "NONE", "NONE", 0.0, "None" }; | ||
for (int i = 0; i < detectors.size; i++) { | ||
if (String(detectors.detectors[i].name) == String(detectorName)) { | ||
det = detectors.detectors[i]; | ||
} | ||
} | ||
return detector { "NONE", "NONE", "NONE", "NONE", "NONE", "NONE", 0.0 }; | ||
if (0<detectors.size){ | ||
delete[] detectors.detectors; | ||
} | ||
|
||
return det; | ||
} | ||
#endif |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,6 +53,7 @@ build_flags = | |
'-D CAMERA_MODEL_M5STACK_PSRAM' | ||
'-D NAME="GROUNDLIGHT_DEMO_UNIT"' | ||
'-D ENABLE_AP' | ||
# '-D ENABLE_STACKLIGHT' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do the demo units no longer work with Stacklight? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes we are skipping stacklight connection for now due to connection issues on my end, and once I confirmed the stacklight is functioning, I will enable it again. |
||
lib_deps = | ||
${env.lib_deps} | ||
https://github.com/me-no-dev/ESPAsyncWebServer.git#master | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An awesome bonus here would be to check the length of the string before you copy it into the char array. We've had memory overflow problems before on, for example, detectors with ridiculously long queries.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought if I use strlcpy to copy the string, it specifies the size of string so that overflow won't happen?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Admittedly not strictly a part of your PR, but just above here are some unsafe strcpy calls