diff --git a/app/src/split/bluetooth/central.c b/app/src/split/bluetooth/central.c index b70d79e3..ccf1cc28 100644 --- a/app/src/split/bluetooth/central.c +++ b/app/src/split/bluetooth/central.c @@ -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,