feat(nimble): Add support to allow connection during scanning

This commit is contained in:
Rahul Tank
2024-09-04 14:27:04 +05:30
parent 4af7646927
commit 92e4100df1
13 changed files with 65 additions and 31 deletions
@@ -85,7 +85,7 @@ ble_cent_client_gap_event(struct ble_gap_event *event, void *arg)
case BLE_GAP_EVENT_EXT_DISC:
rc = ble_hs_adv_parse_fields(&fields, event->ext_disc.data, event->ext_disc.length_data);
/* An advertisment report was received during GAP discovery. */
/* An advertisement report was received during GAP discovery. */
if ((rc == 0) && fields.name && (fields.name_len >= strlen(BLE_PEER_NAME)) &&
!strncmp((const char *)fields.name, BLE_PEER_NAME, strlen(BLE_PEER_NAME))) {
ble_cent_connect(&event->ext_disc);
@@ -319,12 +319,14 @@ ble_cent_connect(void *disc)
return;
}
#if !(MYNEWT_VAL(BLE_HOST_ALLOW_CONNECT_WITH_SCAN))
/* Scanning must be stopped before a connection can be initiated. */
rc = ble_gap_disc_cancel();
if (rc != 0) {
ESP_LOGE(TAG, "Failed to cancel scan; rc=%d\n", rc);
return;
}
#endif
/* We won't connect to the same device. Change our static random address to simulate
* multi-connection with only one central and one peripheral.