@@ -355,12 +355,6 @@ static void split_central_process_connection(struct bt_conn *conn) {
355
355
static bool split_central_eir_found (const bt_addr_le_t * addr ) {
356
356
LOG_DBG ("Found the split service" );
357
357
358
- int slot_idx = reserve_peripheral_slot (addr );
359
- if (slot_idx < 0 ) {
360
- LOG_ERR ("Failed to reserve peripheral slot (err %d)" , slot_idx );
361
- return false;
362
- }
363
-
364
358
// Stop scanning so we can connect to the peripheral device.
365
359
LOG_DBG ("Stopping peripheral scanning" );
366
360
is_scanning = false;
@@ -370,29 +364,24 @@ static bool split_central_eir_found(const bt_addr_le_t *addr) {
370
364
return false;
371
365
}
372
366
373
- struct peripheral_slot * slot = & peripherals [slot_idx ];
374
-
375
- slot -> conn = bt_conn_lookup_addr_le (BT_ID_DEFAULT , addr );
376
- if (slot -> conn ) {
377
- LOG_DBG ("Found existing connection" );
378
- split_central_process_connection (slot -> conn );
379
- err = bt_conn_le_phy_update (slot -> conn , BT_CONN_LE_PHY_PARAM_2M );
380
- if (err ) {
381
- LOG_ERR ("Update phy conn failed (err %d)" , err );
382
- }
383
- } else {
384
- struct bt_le_conn_param * param = BT_LE_CONN_PARAM (0x0006 , 0x0006 , 30 , 400 );
385
-
386
- LOG_DBG ("Initiating new connnection" );
387
-
388
- err = bt_conn_le_create (addr , BT_CONN_LE_CREATE_CONN , param , & slot -> conn );
389
- if (err ) {
390
- LOG_ERR ("Create conn failed (err %d) (create conn? 0x%04x)" , err ,
391
- BT_HCI_OP_LE_CREATE_CONN );
392
- start_scan ();
393
- }
367
+ int slot_idx = reserve_peripheral_slot (addr );
368
+ if (slot_idx < 0 ) {
369
+ LOG_ERR ("Failed to reserve peripheral slot (err %d)" , slot_idx );
370
+ start_scan ();
371
+ return false;
394
372
}
395
373
374
+ LOG_DBG ("Initiating new connnection" );
375
+ struct bt_le_conn_param * param = BT_LE_CONN_PARAM (6 , 6 , 399 , 900 );
376
+ struct peripheral_slot * slot = & peripherals [slot_idx ];
377
+ err = bt_conn_le_create (addr , BT_CONN_LE_CREATE_CONN , param , & slot -> conn );
378
+ if (err ) {
379
+ LOG_ERR ("Create conn failed (err %d) (create conn? 0x%04x)" , err ,
380
+ BT_HCI_OP_LE_CREATE_CONN );
381
+ release_peripheral_slot (slot_idx );
382
+ start_scan ();
383
+ }
384
+
396
385
return false;
397
386
}
398
387
0 commit comments