bonds.h 1.2 KB

123456789101112131415161718192021222324
  1. // bonds.h -- the puck's bond slots + live link state.
  2. //
  3. // The real puck holds four controller bonds and exposes one HID control interface per slot (interface N owns
  4. // slot N). We mirror that: g_slot[N] holds the bond record [8 uuid][16 serial] plus a staging buffer for that
  5. // interface's pending feature-report reply (filled by puck_hid.cpp's command channel). Bonds persist to
  6. // flash (bonds.bin). g_connSlot / g_connReplyMs are the live RF link state, shared here so the USB feature
  7. // handler can report per-slot connection status without depending on the RF layer.
  8. #pragma once
  9. #include <stdint.h>
  10. #define NSLOT 4
  11. // per-slot state (record = [8 uuid][16 serial]) + per-interface response staging
  12. struct Slot { uint8_t rec[24]; bool used; uint8_t resp[63]; uint16_t resp_len; };
  13. extern Slot g_slot[NSLOT];
  14. extern int g_connSlot; // bonded slot being polled (== the USB-connected slot); -1 = none
  15. extern unsigned long g_connReplyMs; // millis of last RF reply (link-alive timestamp)
  16. extern volatile bool g_dirty; // bonds changed -> flush to flash from loop()
  17. extern bool g_pairing;
  18. bool recEmpty(const uint8_t *r);
  19. void loadBonds();
  20. void saveBonds();