mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-02 03:00:34 +03:00
feat(nimble): Add support to allow connection during scanning
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user