Skip to content

Fix stale operator list never cleared during network registration - #13

Merged
samuelbles07 merged 5 commits into
mainfrom
fix/operator-exhaustion
Apr 2, 2026
Merged

Fix stale operator list never cleared during network registration#13
samuelbles07 merged 5 commits into
mainfrom
fix/operator-exhaustion

Conversation

@samuelbles07

@samuelbles07 samuelbles07 commented Mar 30, 2026

Copy link
Copy Markdown
Collaborator

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

  • Promote exhaustion counter to class member (registrationFailCount_), loaded/saved via setOperators() so applications can persist it across power cycles
  • Add getRegistrationFailCount() getter for persistence readback
  • Track last attempted operator (not last successful) in currentOperatorId_ so registration resumes from the correct position
  • Clear operator list and reset counter when threshold (3 full passes) is reached

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.
@samuelbles07 samuelbles07 changed the title Fix registration flow when attempt operator list exhausted Fix stale operator list never cleared during network registration Mar 30, 2026
@samuelbles07
samuelbles07 merged commit 5b55e73 into main Apr 2, 2026
2 checks passed
@samuelbles07
samuelbles07 deleted the fix/operator-exhaustion branch April 2, 2026 05:16
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.

1 participant