fix: add error handling for WiFi.scanNetworks() in /scan endpoint#9
Open
avineet4 wants to merge 1 commit intolocalrice:mainfrom
Open
fix: add error handling for WiFi.scanNetworks() in /scan endpoint#9avineet4 wants to merge 1 commit intolocalrice:mainfrom
avineet4 wants to merge 1 commit intolocalrice:mainfrom
Conversation
- Check for negative return values from WiFi.scanNetworks() - Return 500 error with JSON error response when scan fails - Add WiFi.scanDelete() to prevent memory leak - Improve serial output to indicate scan success/failure - Fixes issue where scan errors were masked by empty array response Fixes potential crashes and improves debugging experience when WiFi scan operations fail due to hardware issues or interference.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR fixes missing error handling in the
/scanendpoint whenWiFi.scanNetworks()fails.Problem
WiFi.scanNetworks()can return negative values on error (e.g., -1 for WIFI_SCAN_FAILED, -2 for WIFI_SCAN_RUNNING)[]with 200 OK status, masking the errorWiFi.scanDelete()) is performedSolution
networks < 0WiFi.scanDelete()to prevent memory leakChanges Made
/scanendpoint insrc/EasyWiFi.cpp(lines 300-326)Testing
Impact
Fixes #10