fix(split): reserve peripheral slot before stopping scanning
In the event that the peripheral MAC address does not match, this allows scanning to continue.
This commit is contained in:
parent
4e18b879bd
commit
544612c8c0
1 changed files with 10 additions and 8 deletions
|
@ -433,20 +433,22 @@ static int stop_scanning() {
|
|||
static bool split_central_eir_found(const bt_addr_le_t *addr) {
|
||||
LOG_DBG("Found the split service");
|
||||
|
||||
// Reserve peripheral slot. Once the central has bonded to its peripherals,
|
||||
// the peripheral MAC addresses will be validated internally and the slot
|
||||
// reservation will fail if there is a mismatch.
|
||||
int slot_idx = reserve_peripheral_slot(addr);
|
||||
if (slot_idx < 0) {
|
||||
LOG_INF("Unable to reserve peripheral slot (err %d)", slot_idx);
|
||||
return false;
|
||||
}
|
||||
struct peripheral_slot *slot = &peripherals[slot_idx];
|
||||
|
||||
// Stop scanning so we can connect to the peripheral device.
|
||||
int err = stop_scanning();
|
||||
if (err < 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int slot_idx = reserve_peripheral_slot(addr);
|
||||
if (slot_idx < 0) {
|
||||
LOG_ERR("Failed to reserve peripheral slot (err %d)", slot_idx);
|
||||
return false;
|
||||
}
|
||||
|
||||
struct peripheral_slot *slot = &peripherals[slot_idx];
|
||||
|
||||
LOG_DBG("Initiating new connnection");
|
||||
struct bt_le_conn_param *param =
|
||||
BT_LE_CONN_PARAM(CONFIG_ZMK_SPLIT_BLE_PREF_INT, CONFIG_ZMK_SPLIT_BLE_PREF_INT,
|
||||
|
|
Loading…
Add table
Reference in a new issue