Skip to content

Headless mode - #8

Merged
PSi86 merged 3 commits into
mainfrom
headless-mode
May 27, 2026
Merged

PSi86 merged 3 commits into
mainfrom
headless-mode

Conversation

@PSi86

@PSi86 PSi86 commented May 27, 2026

Copy link
Copy Markdown
Owner

Key changes:

TX Latency Reduction and Non-Blocking Transmission

  • Switched from RadioLib's blocking transmit() to non-blocking setTx() with DIO1 IRQ, reducing main loop blocking and improving on-air latency by ~300 µs. Added mechanisms to preload the TX FIFO and optimize standby transitions, resulting in faster and more efficient packet transmission.

IRQ Robustness and Deadlock Prevention

  • Reworked the IRQ handler to dispatch based on explicit SX126x IRQ flags, not just internal state, and introduced watchdogs to recover from missed or spurious IRQs. This fixes a deadlock that previously occurred in broadcast scenarios.

Post-Review Hardening and Defensive Fixes

  • Addressed several edge cases and potential failure modes, including watchdog timeout tuning for larger packets, submission watchdog for persistent TX failures, and improved error handling and state recovery. Stream-TX state is now correctly reset

PSi86 and others added 3 commits May 20, 2026 15:38
Stage 0 (re-sync of shared headers + full working-tree mirror from the
WLED-LoRa fork canonical) and Stage 1 PR-1 (wire-protocol extension for
runtime RF config) of the multi-gateway plan, combined here since this
repo had no interim Stage-0 commit.

PR-1 adds:
- OPC_RF_CONFIG (0x0D) and OPC_GET_RF_CONFIG (0x0E) with 12-byte
  P_RfConfig payload (freq_hz / bw_khz_x10 / sf / cr_den / sync_word /
  tx_power_dbm / preamble, all LE). Unicast-only — broadcast forbidden
  by design (analog to OPC_CONFIG).
- USB-CDC additions: EV_RF_CHANGED (0xF6) with RfChangeReason enum,
  GW_CMD_SET_RF_CONFIG (0x02) carrying a persist/volatile flag for the
  channel-scan workflow, GW_CMD_GET_RF_CONFIG (0x03).
- RULES[] entries + static_asserts.

Stage 0 brings the rest of the working tree in line with canonical
(racelink_wled.cpp/h, transport_core.h, headless.h, indicators.h,
docs/).

Co-Authored-By: Claude Opus 4.7 <[email protected]>
…lers

Stage 1 PR-3 of the multi-gateway plan. Mirrors the gateway-side
PR-2 (commit d115966 in RaceLink_Gateway) on the WLED node side, so a
host can change a node's LoRa PHY parameters at runtime, persist them
across reboots, and read them back.

New file rf_config_nvs.h (header-only, WLED-fork-local):
- Same NVS namespace (rl_rf) + schema (magic + CRC16 over P_RfConfig)
  + range validator as the gateway copy. A cross-flashed image
  therefore picks up the existing slot interpretably.
- bootCounterIncrement / Clear / wipe for boot-loop recovery: after
  3 consecutive failed boots the persisted slot is wiped on the next
  radioInit() so beginCommon() lands on the compile defaults.

racelink_wled.cpp / racelink_wled.h changes:
- radioInit() now ticks the boot counter, loads g_activeRfConfig from
  NVS (with compile-time defaults as fallback, persisted on first boot),
  builds PhyCfg from it, and clears the counter after a successful
  beginCommon(). The RACELINK_FREQ_HZ / RACELINK_BW_KHZ / RACELINK_SF /
  RACELINK_CR / RACELINK_SYNC_WORD / RACELINK_PREAMBLE / RACELINK_TX_POWER
  defines remain the compile-default source.
- New OPC_RF_CONFIG (0x0D) handler: validate -> NACK on out-of-range,
  ACK_ERROR on NVS write failure, ACK_OK + delay(50) + ESP.restart()
  on success. Broadcast frames are rejected at the receiver (defence
  in depth; the rules table already forbids broadcast).
- New OPC_GET_RF_CONFIG (0x0E) handler: validates the reserved byte,
  emits a P_RfConfig reply via sendRfConfigReplyTo() carrying
  g_activeRfConfig (which mirrors the NVS slot 1:1 after radioInit).
- sendRfConfigReplyTo() builds the 12 B P_RfConfig N2M reply via the
  standard build() helper for byte-layout symmetry with the master
  side.

Build verified: pio run -e RaceLink_Node_v1_c3_ct62 succeeds
(RAM 21.6%, Flash 70.8%).

Co-Authored-By: Claude Opus 4.7 <[email protected]>
- Introduced persistedMasterLast3 and persistedMasterFull6 to maintain a snapshot of the master state independently of live variables.
- Updated addToConfig and readFromConfig methods to ensure consistent handling of persisted values.
- Improved comments for clarity on persistence behavior and its interaction with macFilterPersist.
- Added boot-loop recovery mechanisms in rf_config_nvs.h to manage corrupted configurations.
@PSi86
PSi86 merged commit da4cb67 into main May 27, 2026
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