wifi: more disconnect reasons for retries & include error code in exception #3992
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.
Changes
Based on goals and discussion in #3837:
expand retries to all reasons for disconnection except for: the two current fatal reasons that raise an exception (NO_AP_FOUND==201 and AUTH_FAIL==202); and the one reason that arises when user code manually triggers a wi-fi disconnect or stop (ASSOC_LEAVE==8)
return the error code for exceptions that don't currently have specific error strings (used to be just "Unknown failure")
For example,
will raise to user code:
Discussion
I've tested this in various scenarios with Peplink and Apple APs, and there is slight variation in disconnect reason codes that arise from various actions. I'd expect other equipment to potentially have other variations. So I'd like more eyes on this code, and hopefully some testing by others in different environments too. I'm open to further tweaking the disconnection reasons we raise exceptions for, and further tweaking the reason logic in the event handler.
The most questionable thing here I think is the slight muddling of the shared-bindings / common-hal interface with the
wifi_radio_error_t
enum
and returning the reason number from common-hal. Every known disconnect reason is now in theenum
, andWIFI_RADIO_ERROR_UNKNOWN
is no longer needed. The alternative (especially if the error number is considered inelegant), assuming we want specific errors known to users (very useful for troubleshooting), is to itemize each of the 30+ disconnect reasons as a unique error string. Or perhaps raise the Espressif-specific exceptions in common-hal, and return the IEEE-based codes to raise in shared-bindings. Or perhaps there's another solution I'm not aware of.The saving grace is that most of the reasons in the
enum
are IEEE 802.11 numbers, so should carry over to any future alternate wi-fi-capable ports.There is a small risk with this code that the IDF returns an unexpected reason code not in the
enum
(not in their docs). Not sure how to handle this.