Skip to content

fix: drop a sign key the server never accepted, so the station can be added again - #48

Merged
maxidragon merged 1 commit into
masterfrom
fix/forget-unaccepted-sign-key
Nov 10, 2026
Merged

maxidragon merged 1 commit into
masterfrom
fix/forget-unaccepted-sign-key

Conversation

@maxidragon

@maxidragon maxidragon commented Nov 10, 2026 •

Copy link
Copy Markdown
Member

Problem

When a station is added again, submit creates a new sign key and add_device saves it to flash right away, before the server has accepted it. If the server never accepts it, the station is stuck. That happens when an old backend refuses the key, when someone rejects or ignores the approval in the panel, or when the station restarts before approval:

  • Every handshake mismatches. The key isn't 0, so fix: let a station without a sign key be added again #45's re-add path doesn't apply, and the station shows "Server Not Trusted!".
  • The server still lists the station, so it counts as added, and submit only dismisses the error.
  • Only "Reset settings", which wipes the key, gets it out.

Seen on the competition router: a station pressed submit while the backend refused its new key, and stayed on "Server Not Trusted!" until it was reset.

Change

  • add_device also saves a pending flag (SIGN_PENDING in NVS) when it creates a new key.
  • The first handshake that matches clears the flag: the key counts as accepted from then on.
  • A handshake that doesn't match while the flag is set drops the key (back to 0) instead of showing "Server Not Trusted!". From there fix: let a station without a sign key be added again #45's flow applies: "Device not added", then submit, then approval in the panel.
  • A key that has matched once is never dropped, so a real trust failure (a wrong or impostor server) still shows the error. Stations already in the field have no flag, so they keep today's behaviour.
  • "Reset settings" also deletes the flag.

If the station reconnects before the approval, it drops the key and asks again with a new one. The backend keeps only the latest request per station, so approving it stores the key the station actually holds.

Verification

  • cargo fmt --check; clippy -D warnings for v3, v4 and the default build; release builds for v3 and v4.
  • Desk test on a v3 station connected to the competition router:
    1. Submit after "Reset settings", not approved, then a connector restart: the station logged [trust] the server never accepted the sign key, dropping it to be added again and showed "Device not added". No "Server Not Trusted!".
    2. Submit again, approved in the panel, then another restart: [trust] server trusted.

@maxidragon
maxidragon merged commit e6d259a into master Nov 10, 2026
10 checks passed
@maxidragon
maxidragon deleted the fix/forget-unaccepted-sign-key branch November 10, 2026 18:36
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