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

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>
This commit is contained in:
sl-uwb 2026-03-20 16:34:18 -04:00
parent 688a9bdbe9
commit fd6893f684
2 changed files with 542 additions and 876 deletions

View File

@ -1,8 +1,17 @@
; SaltyBot UWB Tag Firmware ; SaltyBot UWB Tag Firmware — Issue #545, Issue #698
; Target: Makerfabs ESP32 UWB Pro with Display (DW1000 + SSD1306 OLED) ; Target: Makerfabs ESP32 UWB Pro with Display (DW3000 + SSD1306 OLED)
;
; The tag is battery-powered, worn by the person being tracked.
; It initiates DS-TWR ranging with each anchor in round-robin,
; shows status on OLED display, and sends data via ESP-NOW.
;
; Library: Makerfabs MaUWB_DW3000
; https://github.com/Makerfabs/MaUWB_DW3000
; ;
; Flash: ; Flash:
; pio run -e tag --target upload ; pio run -e tag --target upload
; Monitor (USB debug):
; pio device monitor -b 115200
[env:tag] [env:tag]
platform = espressif32 platform = espressif32
@ -10,12 +19,11 @@ board = esp32dev
framework = arduino framework = arduino
monitor_speed = 115200 monitor_speed = 115200
upload_speed = 921600 upload_speed = 921600
lib_extra_dirs = ../../lib
lib_deps = lib_deps =
https://github.com/Makerfabs/MaUWB_DW3000.git
adafruit/Adafruit SSD1306@^2.5.7 adafruit/Adafruit SSD1306@^2.5.7
adafruit/Adafruit GFX Library@^1.11.5 adafruit/Adafruit GFX Library@^1.11.5
board_build.partitions = huge_app.csv
build_flags = build_flags =
-DCORE_DEBUG_LEVEL=0 -DCORE_DEBUG_LEVEL=0
-DTAG_ID=0x01 -DTAG_ID=0x01 ; unique per tag (0x010xFE)
-Wno-error=return-type -DRANGE_INTERVAL_MS=50 ; 20 Hz round-robin across discovered anchors

File diff suppressed because it is too large Load Diff