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

This commit is contained in:
Rahul Tank
2024-08-01 13:49:10 +05:30
parent 4af7646927
commit 92e4100df1
13 changed files with 65 additions and 31 deletions

View File

@@ -48,7 +48,7 @@
#endif
#endif
/*** The UUID of the service containing the subscribable characterstic ***/
/*** The UUID of the service containing the subscribable characteristic ***/
static const ble_uuid_t * remote_svc_uuid =
BLE_UUID128_DECLARE(0x2d, 0x71, 0xa2, 0x59, 0xb4, 0x58, 0xc8, 0x12,
0x99, 0x99, 0x43, 0x95, 0x12, 0x2f, 0x46, 0x59);
@@ -203,7 +203,7 @@ blecent_custom_gatt_operations(const struct peer* peer)
remote_chr_uuid,
BLE_UUID16_DECLARE(BLE_GATT_DSC_CLT_CFG_UUID16));
if (dsc == NULL) {
MODLOG_DFLT(ERROR, "Error: Peer lacks a CCCD for the subscribable characterstic\n");
MODLOG_DFLT(ERROR, "Error: Peer lacks a CCCD for the subscribable characteristic\n");
goto err;
}
@@ -601,12 +601,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);
@@ -687,7 +689,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. */
@@ -840,7 +842,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);