feat: UWB anchor auto-discovery (Issue #698) #706

Merged
sl-jetson merged 1 commits from sl-uwb/issue-698-anchor-discovery into salty/uwb-tag-display-wireless 2026-03-20 17:38:46 -04:00
Collaborator

Summary

Replaces the hardcoded NUM_ANCHORS=2 anchor list with a fully dynamic discovery engine. No anchor firmware changes required — the tag uses standard DS-TWR POLL frames as probes; anchors that respond are considered discovered.

Changes

esp32/uwb_tag/src/main.cpp

  • AnchorEntry table (8 slots): present, active, range_mm, rssi, last_ok_ms, miss_count
  • DISC_SCANDISC_RANGE state machine
    • Scan: probes IDs 0..7 one slot at a time; active IDs skipped
    • Range: round-robins active anchors only; re-scan on empty table or after DISC_RESCAN_MS (10 s)
  • range_and_update(id): ranges, updates table, emits +DISC:FOUND / +DISC:LOST serial and MSG_DISC (0x40) ESP-NOW
  • disc_scan_step(): advances cursor one probe per ranging slot
  • New OLED screens: ANCHOR SCAN progress bar, NO ANCHOR rescan countdown
  • Active anchor count badge on normal range screen

esp32/uwb_tag/platformio.ini

  • Switch lib to MaUWB_DW3000 (DW3000 chip)
  • Remove NUM_ANCHORS build flag (now dynamic)

Notes

  • Anchor firmware (esp32/uwb_anchor) is untouched — frozen for calibration
  • Build verification blocked locally: MaUWB_DW3000 library requires GitHub credentials not available on this machine

Test plan

  • Flash tag, confirm OLED shows "ANCHOR SCAN" with progress bar on boot
  • With 2 anchors powered on, verify both appear in +DISC:FOUND serial output
  • Confirm round-robin ranging starts and OLED shows distances
  • Power off one anchor, verify +DISC:LOST appears after ANCHOR_MISS_LIMIT misses
  • Verify re-scan triggers after DISC_RESCAN_MS (10 s) with no anchors
## Summary Replaces the hardcoded `NUM_ANCHORS=2` anchor list with a fully dynamic discovery engine. No anchor firmware changes required — the tag uses standard DS-TWR POLL frames as probes; anchors that respond are considered discovered. ## Changes **`esp32/uwb_tag/src/main.cpp`** - `AnchorEntry` table (8 slots): `present`, `active`, `range_mm`, `rssi`, `last_ok_ms`, `miss_count` - `DISC_SCAN` → `DISC_RANGE` state machine - Scan: probes IDs 0..7 one slot at a time; active IDs skipped - Range: round-robins active anchors only; re-scan on empty table or after `DISC_RESCAN_MS` (10 s) - `range_and_update(id)`: ranges, updates table, emits `+DISC:FOUND` / `+DISC:LOST` serial and `MSG_DISC` (0x40) ESP-NOW - `disc_scan_step()`: advances cursor one probe per ranging slot - New OLED screens: ANCHOR SCAN progress bar, NO ANCHOR rescan countdown - Active anchor count badge on normal range screen **`esp32/uwb_tag/platformio.ini`** - Switch lib to `MaUWB_DW3000` (DW3000 chip) - Remove `NUM_ANCHORS` build flag (now dynamic) ## Notes - Anchor firmware (`esp32/uwb_anchor`) is **untouched** — frozen for calibration - Build verification blocked locally: `MaUWB_DW3000` library requires GitHub credentials not available on this machine ## Test plan - [ ] Flash tag, confirm OLED shows "ANCHOR SCAN" with progress bar on boot - [ ] With 2 anchors powered on, verify both appear in `+DISC:FOUND` serial output - [ ] Confirm round-robin ranging starts and OLED shows distances - [ ] Power off one anchor, verify `+DISC:LOST` appears after ANCHOR_MISS_LIMIT misses - [ ] Verify re-scan triggers after DISC_RESCAN_MS (10 s) with no anchors
sl-jetson added 1 commit 2026-03-20 16:34:35 -04:00
Replace hardcoded NUM_ANCHORS with dynamic discovery table.
Tag probes IDs 0..7 via standard DS-TWR POLL frames at startup
and after every DISC_RESCAN_MS (10 s); anchors that respond are
added to the active table, stale ones removed after
ANCHOR_MISS_LIMIT misses or ANCHOR_TIMEOUT_MS silence.

Key changes
-----------
- AnchorEntry table (8 slots): present/active flags, range_mm,
  rssi, last_ok_ms, miss_count
- DISC_SCAN → DISC_RANGE state machine
- range_and_update(): ranges, updates table, emits +DISC:FOUND /
  +DISC:LOST on serial and MSG_DISC (0x40) on ESP-NOW
- disc_scan_step(): advances cursor one probe per ranging slot,
  skips already-active IDs
- New OLED screens: ANCHOR SCAN progress bar, NO ANCHOR rescan
  countdown, active anchor count badge on normal screen
- platformio.ini: switch to MaUWB_DW3000 lib, remove NUM_ANCHORS
  build flag (discovery is now dynamic)
- No anchor firmware changes required

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
sl-jetson merged commit 30a5212ba2 into salty/uwb-tag-display-wireless 2026-03-20 17:38:46 -04:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: seb/saltylab-firmware#706
No description provided.