Skip to content

Add RFD900x remote reconfiguration via uplinked RfdConfig (Phase 4) - #35

Closed
ivan-lyf wants to merge 2 commits into
feat/two-way-radio-communicationfrom
feat/rfd900x-remote-config
Closed

ivan-lyf wants to merge 2 commits into
feat/two-way-radio-communicationfrom
feat/rfd900x-remote-config

Conversation

@ivan-lyf

Copy link
Copy Markdown
Contributor

What

Implements the missing phase of two-way radio communication: FALCON can now reconfigure the rocket-side RFD900x over serial from an uplinked RfdConfig protobuf command (+++ -> ATSn=v per populated field -> AT&W -> ATZ), per the team decision that FALCON applies rfd_config (superseding the stale "ground-local" comment in GroundCommand.proto).

Safety design — this must never brick comms

  • Validate before touching the modem: range checks per S-register plus min_freq <= max_freq; an empty or invalid config is rejected with no bytes sent (-EINVAL).
  • Every command verified: each ATSn=v must return OK, then the register is read back with ATSn? and compared — a silently-clamped value aborts the session.
  • AT&W is only sent after every write verified; ATZ only after AT&W returns OK. Any earlier failure (timeout, ERROR, mismatch) aborts with ATO, so EEPROM keeps the config the link was established with.
  • Telemetry TX suspended during the session (radio_tx_suspend()) so the +++ guard time sees a silent serial line toward the modem.
  • Robust response parsing: command echo, blank lines, and RSSI noise are ignored; only a bare OK / all-digit value line counts.

Structure

  • firmware/src/radio/rfd900x_at.c — transport-agnostic AT session engine (the part under test)
  • firmware/src/radio/rfd900x.c — UART transport + telemetry suspension glue; simulated on native_sim
  • firmware/src/radio/command_thread.c — dispatches GroundCommand.rfd_config to the engine
  • boards/.../ubcrocket_polarity.dts — rfd-uart alias, PLACEHOLDER: USART2 PA2/PA3 @ 57600 assumed; if the real path is AT-passthrough via the GNSS board, only the transport in rfd900x.c changes

Testing

New suite firmware/tests/rfd900x runs the engine against a scripted mock modem — 12/12 passing on native_sim/native/64:
happy path (all 6 registers), partial config, zero-value field (NETID 0), echo/noise tolerance, empty config, min>max, out-of-range values, no OK after +++, ERROR reply, mid-sequence silence, readback mismatch, unacknowledged AT&W (asserts ATZ never sent).

Also verified: full firmware builds for ubcrocket_polarity (SDK 0.17.4) and native_sim/native/64; existing state-machine suite still passes; integration suite still builds for ubcrocket_polarity; clang-format clean.

Open items before flight

  • Confirm the physical serial path to the modem (direct UART vs GNSS-board passthrough) and the final S-register bounds in uplink_config.h (currently placeholders).
  • Bench-test against two real RFD900x modems, including the ground-station sequencing/recovery-window plan (rocket reconfigures first, ground follows).
  • The final command list from the finalized protobuf may add/remove registers — extend build_writes() accordingly.

🤖 Generated with Claude Code

ivan-lyf and others added 2 commits July 26, 2026 11:03
Carries over in-progress work from the feature branch working tree:
- VTX/RunCam power switch confirmed on PD6; RunCam UART moved to UART4
- RunCam auto-records while powered, so camera_recording commands and the
  landed-state UART stop are dropped; recording follows the power rail

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
FALCON now applies an uplinked RfdConfig to the rocket-side RFD900x
through an AT command session (team decision: supersedes the stale
ground-local comment in GroundCommand.proto).

Safety design -- a half-applied config must never brick comms:
- config validated (ranges, min<=max) before the modem is touched
- every AT command must be acknowledged with OK before the next one
- every S-register is read back (ATSn?) and compared after writing
- AT&W (EEPROM write) is only sent after all writes verified; ATZ only
  after AT&W is acknowledged; any earlier failure aborts with ATO so
  the modem keeps the config the link was established with
- telemetry TX is suspended during the session so the +++ guard time
  sees a silent serial line

The AT session engine (rfd900x_at.c) is transport-agnostic; the UART
transport (rfd900x.c, rfd-uart alias, USART2 PA2/PA3 @57600 placeholder)
can be swapped for GNSS-board AT-passthrough once the physical path is
confirmed.

Tested with a scripted mock modem (firmware/tests/rfd900x): happy path,
partial/zero-value configs, echo+noise tolerance, validation rejects,
entry timeout, ERROR reply, mid-sequence silence, readback mismatch,
and unacknowledged AT&W -- 12/12 passing on native_sim.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@ivan-lyf ivan-lyf closed this Jul 26, 2026
@ivan-lyf
ivan-lyf deleted the feat/rfd900x-remote-config branch July 26, 2026 18:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Assignees

Couldn't load assignees.