Fix stale operator list never cleared during network registration - #13
Merged
Conversation
Promote operatorListExhaustedCount from local variable to class member (registrationFailCount_) so it persists across multiple calls to startNetworkRegistration(). The counter is loaded/saved via setOperators() to allow the application to persist it across power cycles. When the threshold (3) is reached, the operator list is cleared, forcing a fresh operator scan on the next registration attempt.
Only increment registrationFailCount_ via the OPERATOR_LIST_EXHAUSTED handler (full pass through all operators). The operation-timeout exit path preserves whatever count was accumulated during the call.
Set currentOperatorId_ when attempting an operator (not only on success) so that on the next wake cycle, registration resumes from where it left off rather than restarting from index 0. This ensures the device can eventually exhaust the full operator list across wake cycles.
Add setCoapDomain() and setCoapDomainDefault() to AirgradientClient, mirroring the existing HTTP domain API. setCoapDomainDefault() resets to the hardcoded IP (AIRGRADIENT_COAP_IP) to preserve current behavior.
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.
Problem
The operator list exhaustion counter was a local variable in
startNetworkRegistration(), resetting to 0 on every call. Combined with short operation timeouts on wake cycles (100s), the 3x exhaustion threshold was never reached -- the stale operator list persisted indefinitely across wake cycles, preventing fresh operator scans.Additionally,
currentOperatorId_only tracked the last successful operator, causing registration to always restart from that position instead of resuming where it left off after a failed wake cycle.Changes
registrationFailCount_), loaded/saved viasetOperators()so applications can persist it across power cyclesgetRegistrationFailCount()getter for persistence readbackcurrentOperatorId_so registration resumes from the correct position