rf_diag.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. // rf_diag.h -- RF reverse-engineering & calibration scaffolding (NOT used in normal operation).
  2. //
  3. // Tooling that solved the puck protocol, preserved here: promiscuous raw capture, CRC-validating config sweeps,
  4. // bit-exact frame replay, address/CRC listen, the scan-then-respond dongle experiment, the dongle beacon, and
  5. // the live-session sniffer. Each is driven by a flag toggled from the CDC console (serial_console.cpp) and
  6. // serviced by rfDiagTask() from loop().
  7. #pragma once
  8. #include <stdint.h>
  9. // ---- mode flags (toggled by the CDC console; mutually managed there) ----
  10. extern bool g_rfListen;
  11. extern bool g_rfBeacon;
  12. extern uint8_t g_plen, g_s1incl; // dongle-beacon payload length / S1INCL toggle
  13. extern bool g_rfRaw;
  14. extern bool g_rfSweep;
  15. extern bool g_rfCap, g_rfCapOne, g_rfReplay;
  16. extern uint8_t g_replayLen;
  17. extern bool g_rfAuto;
  18. extern uint8_t g_capV, g_cfgIdx;
  19. extern bool g_rfRespond;
  20. extern bool g_sniff;
  21. extern uint8_t g_sniffPh, g_sniffPark;
  22. // ---- start hooks (called from the console on command) ----
  23. void rfListenStart(); // RX + log on the discovery addr/channel
  24. void rfRawStart(uint8_t ch); // promiscuous preamble-match capture (no CRC)
  25. void rfCapStart(
  26. 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. // session sniffer (learn session params, then capture the live exchange)
  32. void rfSniffStart();
  33. // Per-loop: service whichever diag mode is active.
  34. void rfDiagTask();