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

This commit is contained in:
Rahul Tank
2024-08-16 15:06:35 +05:30
parent 1bb33a31b8
commit a992ae6528
13 changed files with 65 additions and 31 deletions
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Unlicense OR CC0-1.0
*/
@@ -77,7 +77,7 @@ blecent_l2cap_coc_send_data(struct ble_l2cap_chan *chan)
}
/**
* After connetion is established on GAP layer, service discovery is performed. On
* After connection is established on GAP layer, service discovery is performed. On
* it's completion, this API is called for making a connection is on L2CAP layer.
*/
static void
@@ -340,12 +340,14 @@ blecent_connect_if_interesting(void *disc)
}
#endif
#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) {
MODLOG_DFLT(DEBUG, "Failed to cancel scan; rc=%d\n", rc);
return;
}
#endif
/* Figure out address to use for connect (no privacy for now) */
rc = ble_hs_id_infer_auto(0, &own_addr_type);
@@ -403,7 +405,7 @@ blecent_gap_event(struct ble_gap_event *event, void *arg)
return 0;
}
/* An advertisment report was received during GAP discovery. */
/* An advertisement report was received during GAP discovery. */
print_adv_fields(&fields);
/* Try to connect to the advertiser if it looks interesting. */
@@ -470,7 +472,7 @@ blecent_gap_event(struct ble_gap_event *event, void *arg)
#if CONFIG_EXAMPLE_EXTENDED_ADV
case BLE_GAP_EVENT_EXT_DISC:
/* An advertisment report was received during GAP discovery. */
/* An advertisement report was received during GAP discovery. */
ext_print_adv_report(&event->disc);
blecent_connect_if_interesting(&event->disc);