rf_diag.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536
  1. // rf_diag.h -- RF reverse-engineering & calibration scaffolding (NOT used in normal operation).
  2. //
  3. // The puck protocol is solved (see radio.cpp / rf_link.cpp), but the tooling that solved it is preserved here:
  4. // promiscuous raw capture, CRC-validating config sweeps, bit-exact frame replay, address/CRC listen, the
  5. // scan-then-respond dongle experiment, the dongle beacon, and the live-session sniffer. Each is driven by a
  6. // flag toggled from the CDC console (serial_console.cpp) and serviced by rfDiagTask() from loop(). Isolating
  7. // it keeps rf_link.cpp readable while keeping the hard-won RE history compilable and runnable.
  8. #pragma once
  9. #include <stdint.h>
  10. // ---- mode flags (toggled by the CDC console; mutually managed there) ----
  11. extern bool g_rfListen;
  12. extern bool g_rfBeacon;
  13. extern uint8_t g_plen, g_s1incl; // dongle-beacon payload length / S1INCL toggle
  14. extern bool g_rfRaw;
  15. extern bool g_rfSweep;
  16. extern bool g_rfCap, g_rfCapOne, g_rfReplay;
  17. extern uint8_t g_replayLen;
  18. extern bool g_rfAuto;
  19. extern uint8_t g_capV, g_cfgIdx;
  20. extern bool g_rfRespond;
  21. extern bool g_sniff;
  22. extern uint8_t g_sniffPh, g_sniffPark;
  23. // ---- start hooks (called from the console on command) ----
  24. void rfListenStart(); // RX + log on the discovery addr/channel
  25. void rfRawStart(uint8_t ch); // promiscuous preamble-match capture (no CRC)
  26. void rfCapStart(uint8_t ch); // CRC-validating framing sweep (cycles config combos)
  27. void rfReplayOnce(); // bit-exact re-transmit of a captured real-puck frame
  28. void rfBeaconOnce(); // dongle beacon experiment ([01][seq][..][E2@5])
  29. void applyCfg(uint8_t i); // apply autosweep candidate radio config i
  30. void rfRespondStart(); // scan-then-respond (RX ch2 adv, reply host frame)
  31. void rfSniffStart(); // session sniffer (learn session params, then capture the live exchange)
  32. // Per-loop: service whichever diag mode is active.
  33. void rfDiagTask();