Skip to content

Commit 304b561

Browse files
committed
Merge branch 'fix/gatt_cache_peer_init_incl_svc' into 'master'
fix(nimble): Added parameter in peer_init for included service allocation See merge request espressif/esp-idf!39822
2 parents 8b2a1b4 + a82bdb8 commit 304b561

File tree

16 files changed

+325
-22
lines changed

16 files changed

+325
-22
lines changed

components/bt/host/nimble/Kconfig.in

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -751,9 +751,11 @@ config BT_NIMBLE_GATT_CACHING_INCLUDE_SERVICES
751751
Enable this option to include *included services* (e.g., services referenced by other services)
752752
in the GATT database cache. Disabling this will skip caching of included service entries.
753753
config BT_NIMBLE_INCL_SVC_DISCOVERY
754-
bool "Enable Included service discovery"
755-
default y if BT_NIMBLE_GATT_CACHING_INCLUDE_SERVICES
756-
default n
754+
bool
755+
default y if BT_NIMBLE_GATT_CACHING && BT_NIMBLE_GATT_CACHING_INCLUDE_SERVICES
756+
default n if BT_NIMBLE_GATT_CACHING && !BT_NIMBLE_GATT_CACHING_INCLUDE_SERVICES
757+
default n if !BT_NIMBLE_GATT_CACHING
758+
prompt "Enable Included service discovery" if !BT_NIMBLE_GATT_CACHING
757759
help
758760
Enable this option to start discovery for included service.
759761
config BT_NIMBLE_GATT_CACHING_MAX_CONNS

examples/bluetooth/nimble/ble_cts/cts_cent/main/main.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -568,8 +568,13 @@ app_main(void)
568568
ble_hs_cfg.store_status_cb = ble_store_util_status_rr;
569569

570570
/* Initialize data structures to track connected peers. */
571+
#if MYNEWT_VAL(BLE_INCL_SVC_DISCOVERY) || MYNEWT_VAL(BLE_GATT_CACHING_INCLUDE_SERVICES)
572+
rc = peer_init(MYNEWT_VAL(BLE_MAX_CONNECTIONS), 64, 64, 64, 64);
573+
assert(rc == 0);
574+
#else
571575
rc = peer_init(MYNEWT_VAL(BLE_MAX_CONNECTIONS), 64, 64, 64);
572576
assert(rc == 0);
577+
#endif
573578

574579
#if CONFIG_BT_NIMBLE_GAP_SERVICE
575580
/* Set the default device name. */

examples/bluetooth/nimble/ble_enc_adv_data/enc_adv_data_cent/main/main.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -622,8 +622,13 @@ app_main(void)
622622
ble_hs_cfg.sm_io_cap = BLE_SM_IO_CAP_KEYBOARD_ONLY;
623623

624624
/* Initialize data structures to track connected peers. */
625+
#if MYNEWT_VAL(BLE_INCL_SVC_DISCOVERY) || MYNEWT_VAL(BLE_GATT_CACHING_INCLUDE_SERVICES)
626+
rc = peer_init(MYNEWT_VAL(BLE_MAX_CONNECTIONS), 64, 64, 64, 64);
627+
assert(rc == 0);
628+
#else
625629
rc = peer_init(MYNEWT_VAL(BLE_MAX_CONNECTIONS), 64, 64, 64);
626630
assert(rc == 0);
631+
#endif
627632

628633
#if CONFIG_BT_NIMBLE_GAP_SERVICE
629634
/* Set the default device name. */

examples/bluetooth/nimble/ble_gattc_gatts_coex/main/main.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -549,9 +549,11 @@ void app_main(void)
549549
nimble_port_init();
550550

551551
ble_hs_cfg.sync_cb = on_sync;
552-
552+
#if MYNEWT_VAL(BLE_INCL_SVC_DISCOVERY) || MYNEWT_VAL(BLE_GATT_CACHING_INCLUDE_SERVICES)
553+
peer_init(MYNEWT_VAL(BLE_MAX_CONNECTIONS), 64, 64, 64, 64);
554+
#else
553555
peer_init(MYNEWT_VAL(BLE_MAX_CONNECTIONS), 64, 64, 64);
554-
556+
#endif
555557
ble_svc_gap_init();
556558
ble_svc_gatt_init();
557559
ble_svc_ans_init();

examples/bluetooth/nimble/ble_htp/htp_cent/main/main.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -698,9 +698,13 @@ app_main(void)
698698
ble_hs_cfg.store_status_cb = ble_store_util_status_rr;
699699

700700
/* Initialize data structures to track connected peers. */
701+
#if MYNEWT_VAL(BLE_INCL_SVC_DISCOVERY) || MYNEWT_VAL(BLE_GATT_CACHING_INCLUDE_SERVICES)
702+
rc = peer_init(MYNEWT_VAL(BLE_MAX_CONNECTIONS), 64, 64, 64, 64);
703+
assert(rc == 0);
704+
#else
701705
rc = peer_init(MYNEWT_VAL(BLE_MAX_CONNECTIONS), 64, 64, 64);
702706
assert(rc == 0);
703-
707+
#endif
704708
#if CONFIG_BT_NIMBLE_GAP_SERVICE
705709
/* Set the default device name. */
706710
rc = ble_svc_gap_device_name_set("nimble-htp-cent");

examples/bluetooth/nimble/ble_l2cap_coc/coc_blecent/main/main.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -572,9 +572,13 @@ app_main(void)
572572
#endif
573573

574574
/* Initialize data structures to track connected peers. */
575+
#if MYNEWT_VAL(BLE_INCL_SVC_DISCOVERY) || MYNEWT_VAL(BLE_GATT_CACHING_INCLUDE_SERVICES)
576+
rc = peer_init(MYNEWT_VAL(BLE_MAX_CONNECTIONS), 64, 64, 64, 64);
577+
assert(rc == 0);
578+
#else
575579
rc = peer_init(MYNEWT_VAL(BLE_MAX_CONNECTIONS), 64, 64, 64);
576580
assert(rc == 0);
577-
581+
#endif
578582
#if CONFIG_BT_NIMBLE_GAP_SERVICE
579583
/* Set the default device name. */
580584
rc = ble_svc_gap_device_name_set("blecent-l2coc");

examples/bluetooth/nimble/ble_multi_conn/ble_multi_conn_cent/main/main.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,9 +454,13 @@ app_main(void)
454454
ble_hs_cfg.store_status_cb = ble_store_util_status_rr;
455455

456456
/* Initialize data structures to track connected peers. */
457+
#if MYNEWT_VAL(BLE_INCL_SVC_DISCOVERY) || MYNEWT_VAL(BLE_GATT_CACHING_INCLUDE_SERVICES)
458+
rc = peer_init(BLE_PEER_MAX_NUM, BLE_PEER_MAX_NUM, BLE_PEER_MAX_NUM, BLE_PEER_MAX_NUM, BLE_PEER_MAX_NUM);
459+
assert(rc == 0);
460+
#else
457461
rc = peer_init(BLE_PEER_MAX_NUM, BLE_PEER_MAX_NUM, BLE_PEER_MAX_NUM, BLE_PEER_MAX_NUM);
458462
assert(rc == 0);
459-
463+
#endif
460464
/* Set the default device name. We will act as both central and peripheral. */
461465
rc = ble_svc_gap_device_name_set("esp-ble-role-coex");
462466
assert(rc == 0);

examples/bluetooth/nimble/ble_periodic_sync/main/main.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,9 +203,13 @@ app_main(void)
203203
ble_hs_cfg.store_status_cb = ble_store_util_status_rr;
204204

205205
/* Initialize data structures to track connected peers. */
206+
#if MYNEWT_VAL(BLE_INCL_SVC_DISCOVERY) || MYNEWT_VAL(BLE_GATT_CACHING_INCLUDE_SERVICES)
207+
rc = peer_init(MYNEWT_VAL(BLE_MAX_CONNECTIONS), 64, 64, 64, 64);
208+
assert(rc == 0);
209+
#else
206210
rc = peer_init(MYNEWT_VAL(BLE_MAX_CONNECTIONS), 64, 64, 64);
207211
assert(rc == 0);
208-
212+
#endif
209213
#if CONFIG_BT_NIMBLE_GAP_SERVICE
210214
/* Set the default device name. */
211215
rc = ble_svc_gap_device_name_set("nimble_periodic_sync");

examples/bluetooth/nimble/ble_phy/phy_cent/main/main.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -553,9 +553,13 @@ app_main(void)
553553
ble_hs_cfg.store_status_cb = ble_store_util_status_rr;
554554

555555
/* Initialize data structures to track connected peers. */
556+
#if MYNEWT_VAL(BLE_INCL_SVC_DISCOVERY) || MYNEWT_VAL(BLE_GATT_CACHING_INCLUDE_SERVICES)
557+
rc = peer_init(MYNEWT_VAL(BLE_MAX_CONNECTIONS), 64, 64, 64, 64);
558+
assert(rc == 0);
559+
#else
556560
rc = peer_init(MYNEWT_VAL(BLE_MAX_CONNECTIONS), 64, 64, 64);
557561
assert(rc == 0);
558-
562+
#endif
559563
#if CONFIG_BT_NIMBLE_GAP_SERVICE
560564
/* Set the default device name. */
561565
rc = ble_svc_gap_device_name_set("blecent-phy");

0 commit comments

Comments
 (0)