Skip to content
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

Merged
merged 29 commits into from
Mar 18, 2024
Merged

Esp form uiupdate #36

merged 29 commits into from
Mar 18, 2024

Conversation

siyangye
Copy link
Contributor

Implemented autoconfig feature for the localhost web page.

Copy link
Contributor

@brandon-groundlight brandon-groundlight left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking pretty good! I have a few comments and questions for right now and then I can give this another look over.

@@ -8,6 +8,7 @@
"vector": "cpp",
"string_view": "cpp",
"initializer_list": "cpp",
"cmath": "cpp"
"cmath": "cpp",
"*.tcc": "cpp"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this line?

strlcpy(_detector_list[i].metadata, metadataStr.c_str(), sizeof(_detector_list[i].metadata));
} else {
_detector_list[i].metadata[0] = '\0';
}
Copy link
Contributor

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.

Copy link
Contributor Author

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?

Copy link
Contributor

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

@@ -52,7 +52,8 @@ build_flags =
${env.build_flags}
'-D CAMERA_MODEL_M5STACK_PSRAM'
'-D NAME="GROUNDLIGHT_DEMO_UNIT"'
# '-D ENABLE_AP'
'-D ENABLE_AP'
# '-D ENABLE_STACKLIGHT'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do the demo units no longer work with Stacklight?

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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.

@@ -170,7 +170,7 @@ int start_hr = 8;
int end_hr = 17;

bool disable_deep_sleep_for_notifications = false;
bool disable_deep_sleep_until_reset = false;
bool disable_deep_sleep_until_reset = true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we want to disable deep sleep on the first loop?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So that the access point remains active, and we can still access the local web page to update configuration settings later on.

Twilio SID: <input type="text" name="twilio_sid" value="%twilio_sid%">
Twilio Token: <input type="text" name="twilio_token" value="%twilio_token%">
Twilio Number: <input type="text" name="twilio_number" value="%twilio_number%">
Twilio Recipient: <input type="text" name="twilio_recipient" value="%twilio_recipient%">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we intentionally killing support for notifications off the camera?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I killed the support for notifications because it is currently supported through the web app.

@@ -787,6 +838,8 @@ void loop () {
}
if (WiFi.isConnected()) {
debug_printf("WIFI connected to SSID %s\n", ssid);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should look into adding a linter for these spare lines

for (int i = 0; i < detectors.size; i++) {
if (String(detectors.detectors[i].id) == String(detectorId)) {
return detectors.detectors[i];
det = detectors.detectors[i];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can probably stop iterating ?

Motion Alpha (float between 0 and 1): <input type="text" name="mot_a" value="%mot_a%">
Motion Beta (float between 0 and 1): <input type="text" name="mot_b" value="%mot_b%">
</div>
Enable Stacklight: <input type="checkbox" id="stacklightCheckbox" name="stacklightbox" value="true" onchange="toggleStacklightSettings()">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if stacklight is currently disabled, should this be disabled as well ?

detector esp_det = get_detector_by_name(endpoint, esp_detector_name.c_str(), apiToken);
if (strcmp(esp_det.id, "NONE") == 0) {
preferences.putString("det_id", "DETECTOR NOT FOUND");
Serial.println("Error: Detector not found.");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should probably be consistent about using the debug_printf vs Serial.println ?

Copy link
Contributor

@positavi positavi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

approved to merge after comments are addressed. assuming it works on actual devices.

@siyangye siyangye merged commit c6f18a1 into main Mar 18, 2024
2 checks passed
@siyangye siyangye deleted the esp-form-uiupdate branch March 18, 2024 23:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants