feat: self-calibrate the falling-back floor from the group's live RSSI baseline - #15
Merged
Merged
Conversation
…I baseline
The falling-back floor used to be a fixed dBm value picked by hand via the
Sensitivity setting -- the right number depends on terrain, group size and
antenna placement and changes every ride, making field calibration slow and
imprecise. The floor now derives automatically as `baseline - margin`, where
the baseline is the median slow-EMA RSSI across the intact group (see
src/calibration.{h,cpp}), falling back to the historical fixed -105 dBm floor
until at least 2 peers are present to calibrate against. Sensitivity 0-10
keeps its familiar ruler but now sets the margin (0-30 dB) below that
baseline instead of an absolute dBm number.
To make the calibration observable in the field: the range-test screen now
also shows the live baseline/floor/trend per peer, and a new opt-in onboard
trace ring buffer (`trace on/off/dump/clear` on the serial console) records
raw/fast/slow RSSI plus baseline/floor for post-ride CSV analysis.
No wire-format change (Protocol::kVersion untouched) and no NVS migration --
the `sensLvl` key and the `status` console output stay exactly as before.
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.
Summary
floor = group_baseline - margin, where the baseline is the median slow-EMA RSSI across the intact group (src/calibration.{h,cpp}, pure/testable). Falls back to the historical fixed −105 dBm floor until ≥2 peers are present to calibrate against.trace on/off/dump/clearon the serial console, PSRAM-backed with a RAM fallback) for post-ride CSV analysis of raw/fast/slow RSSI + baseline/floor.Protocol::kVersionuntouched), no NVS migration —sensLvlkey andstatusconsole output unchanged (Flasher settings panel unaffected).Test plan
pio test -e native— 78/78 passing, including 16 new tests forcalibration.h(median robustness/outlier resistance, floor clamping, fallback, margin mapping)pio run— firmware builds clean (RAM 7.2%, Flash 10.8%)flasher/flasher.py --check— flasher self-test passes🤖 Generated with Claude Code