rebase: Phase D — multi-slot pairing on top of state_mgr base

bt.h: add OLED accessors (bt_is_connected, bt_get_addr, bt_hci_err_count)
and 6 multi-slot accessors (bt_get_slot, bt_set_slot, bt_forget_slot,
bt_wipe_all_slots, bt_slot_occupied, bt_slot_get_addr).

bt.cpp:
- #include "slots.h"; add g_current_slot + update_discoverable()
  helper that gates gap_discoverable_control on slots_any_empty().
- 3 OLED accessor impls + 6 slot accessor impls.
- bt_init: slots_load() + g_current_slot from Config_body.current_slot,
  then update_discoverable() instead of bare gap_discoverable_control(1).
- HCI_EVENT_INQUIRY_RESULT: slot-ownership filter (skip devices owned
  by other slots; if our slot is occupied, only accept matching addr).
- L2CAP_EVENT_CHANNEL_OPENED HID_CONTROL: slot_assign on empty slot
  (Phase G auto-bond pattern).
- L2CAP_EVENT_CHANNEL_OPENED HID_INTERRUPT: replace upstream's
  gap_*_control(false) pair with update_discoverable() — they wanted
  "non-discoverable once connected"; we want "non-discoverable once
  all 4 slots are full". Strictly looser, which is correct since
  empty slots need to accept new pairings.
- Inquiry-complete + disconnection-complete handlers similarly
  swapped to update_discoverable().

Upstream's state_mgr hooks (state_init / state_set / state_update
calls in L2CAP_EVENT_CHANNEL_OPENED and elsewhere) are preserved
as-is — they're the upstream rumble-fix infrastructure.

Build still fails on oled.cpp references to audio_peak_* / counter
accessors that Phase E adds.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
MarcelineVPQ
2026-05-17 07:58:18 -06:00
co-authored by Claude Opus 4.7
parent 41c89ebcfd
commit 0593d79f5b
2 changed files with 139 additions and 5 deletions
+13
View File
@@ -25,4 +25,17 @@ std::vector<uint8_t> get_feature_data(uint8_t reportId,uint16_t len);
void init_feature();
void set_feature_data(uint8_t reportId, uint8_t* data,uint16_t len);
// OLED add-on accessors.
bool bt_is_connected();
void bt_get_addr(uint8_t out[6]);
uint32_t bt_hci_err_count();
// Multi-slot persistent pairing (Phase G). Modeled on zurce/DS5Dongle-OLED.
int bt_get_slot();
void bt_set_slot(int slot);
void bt_forget_slot(int slot);
void bt_wipe_all_slots();
bool bt_slot_occupied(int slot);
void bt_slot_get_addr(int slot, uint8_t out[6]);
#endif //DS5_BRIDGE_BT_H