diff --git a/examples/bluetooth/nimble/ble_chan_sound_initiator/main/gatt_svr.c b/examples/bluetooth/nimble/ble_chan_sound_initiator/main/gatt_svr.c index 0363664490..168d0035c7 100644 --- a/examples/bluetooth/nimble/ble_chan_sound_initiator/main/gatt_svr.c +++ b/examples/bluetooth/nimble/ble_chan_sound_initiator/main/gatt_svr.c @@ -25,8 +25,12 @@ int gatt_svr_init(void) { +#if CONFIG_BT_NIMBLE_GAP_SERVICE ble_svc_gap_init(); +#endif /* CONFIG_BT_NIMBLE_GAP_SERVICE */ +#if MYNEWT_VAL(BLE_GATTS) ble_svc_gatt_init(); +#endif ble_svc_ras_init(); return 0; diff --git a/examples/bluetooth/nimble/ble_chan_sound_reflector/main/gatt_svr.c b/examples/bluetooth/nimble/ble_chan_sound_reflector/main/gatt_svr.c index f0829469ec..fdadd4c2aa 100644 --- a/examples/bluetooth/nimble/ble_chan_sound_reflector/main/gatt_svr.c +++ b/examples/bluetooth/nimble/ble_chan_sound_reflector/main/gatt_svr.c @@ -25,8 +25,12 @@ int custom_gatt_svr_init(void) { +#if CONFIG_BT_NIMBLE_GAP_SERVICE ble_svc_gap_init(); +#endif /* CONFIG_BT_NIMBLE_GAP_SERVICE */ +#if MYNEWT_VAL(BLE_GATTS) ble_svc_gatt_init(); +#endif ble_svc_ras_init(); return 0; diff --git a/examples/bluetooth/nimble/ble_cts/cts_prph/main/gatt_svr.c b/examples/bluetooth/nimble/ble_cts/cts_prph/main/gatt_svr.c index b790d53709..b11cef220a 100644 --- a/examples/bluetooth/nimble/ble_cts/cts_prph/main/gatt_svr.c +++ b/examples/bluetooth/nimble/ble_cts/cts_prph/main/gatt_svr.c @@ -169,8 +169,12 @@ gatt_svr_init(void) { struct ble_svc_cts_cfg cfg; +#if CONFIG_BT_NIMBLE_GAP_SERVICE ble_svc_gap_init(); +#endif /* CONFIG_BT_NIMBLE_GAP_SERVICE */ +#if MYNEWT_VAL(BLE_GATTS) ble_svc_gatt_init(); +#endif cfg.fetch_time_cb = fetch_current_time; cfg.local_time_info_cb = fetch_local_time_info; diff --git a/examples/bluetooth/nimble/ble_dynamic_service/main/gatt_svr.c b/examples/bluetooth/nimble/ble_dynamic_service/main/gatt_svr.c index 7957174bb9..4efb54ba8d 100644 --- a/examples/bluetooth/nimble/ble_dynamic_service/main/gatt_svr.c +++ b/examples/bluetooth/nimble/ble_dynamic_service/main/gatt_svr.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2021-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Unlicense OR CC0-1.0 */ @@ -253,9 +253,15 @@ int dynamic_service(const uint8_t operation, const struct ble_gatt_svc_def *svcs int gatt_svr_init(void) { +#if CONFIG_BT_NIMBLE_GAP_SERVICE ble_svc_gap_init(); +#endif /* CONFIG_BT_NIMBLE_GAP_SERVICE */ +#if MYNEWT_VAL(BLE_GATTS) ble_svc_gatt_init(); +#endif +#if CONFIG_BT_NIMBLE_ANS_SERVICE ble_svc_ans_init(); +#endif /* Setting a value for the read-only descriptor */ gatt_svr_dsc_val = 0x99; diff --git a/examples/bluetooth/nimble/ble_enc_adv_data/enc_adv_data_prph/main/gatt_svr.c b/examples/bluetooth/nimble/ble_enc_adv_data/enc_adv_data_prph/main/gatt_svr.c index 0c5020855d..912597dc4c 100644 --- a/examples/bluetooth/nimble/ble_enc_adv_data/enc_adv_data_prph/main/gatt_svr.c +++ b/examples/bluetooth/nimble/ble_enc_adv_data/enc_adv_data_prph/main/gatt_svr.c @@ -226,8 +226,12 @@ gatt_svr_init(void) { int rc; +#if CONFIG_BT_NIMBLE_GAP_SERVICE ble_svc_gap_init(); +#endif /* CONFIG_BT_NIMBLE_GAP_SERVICE */ +#if MYNEWT_VAL(BLE_GATTS) ble_svc_gatt_init(); +#endif rc = ble_gatts_count_cfg(gatt_svr_svcs); if (rc != 0) { diff --git a/examples/bluetooth/nimble/ble_gattc_gatts_coex/main/main.c b/examples/bluetooth/nimble/ble_gattc_gatts_coex/main/main.c index fc052080ff..665b179d9e 100644 --- a/examples/bluetooth/nimble/ble_gattc_gatts_coex/main/main.c +++ b/examples/bluetooth/nimble/ble_gattc_gatts_coex/main/main.c @@ -574,9 +574,16 @@ void app_main(void) #else peer_init(MYNEWT_VAL(BLE_MAX_CONNECTIONS), 64, 64, 64); #endif + +#if CONFIG_BT_NIMBLE_GAP_SERVICE ble_svc_gap_init(); +#endif /* CONFIG_BT_NIMBLE_GAP_SERVICE */ +#if MYNEWT_VAL(BLE_GATTS) ble_svc_gatt_init(); +#endif +#if CONFIG_BT_NIMBLE_ANS_SERVICE ble_svc_ans_init(); +#endif ble_gatts_count_cfg(gatt_svr_svcs); ble_gatts_add_svcs(gatt_svr_svcs); diff --git a/examples/bluetooth/nimble/ble_htp/htp_prph/main/gatt_svr.c b/examples/bluetooth/nimble/ble_htp/htp_prph/main/gatt_svr.c index d0587f8fa0..82b6b1f1bc 100644 --- a/examples/bluetooth/nimble/ble_htp/htp_prph/main/gatt_svr.c +++ b/examples/bluetooth/nimble/ble_htp/htp_prph/main/gatt_svr.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2017-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2017-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -117,9 +117,15 @@ gatt_svr_init(void) { int rc; +#if CONFIG_BT_NIMBLE_GAP_SERVICE ble_svc_gap_init(); +#endif +#if MYNEWT_VAL(BLE_GATTS) ble_svc_gatt_init(); +#endif +#if CONFIG_BT_NIMBLE_ANS_SERVICE ble_svc_htp_init(); +#endif rc = ble_gatts_count_cfg(gatt_svr_svcs); if (rc != 0) { diff --git a/examples/bluetooth/nimble/ble_multi_adv/main/gatt_svr.c b/examples/bluetooth/nimble/ble_multi_adv/main/gatt_svr.c index 175d160dd6..bf5d27b4d9 100644 --- a/examples/bluetooth/nimble/ble_multi_adv/main/gatt_svr.c +++ b/examples/bluetooth/nimble/ble_multi_adv/main/gatt_svr.c @@ -178,8 +178,12 @@ gatt_svr_init(void) { int rc; +#if CONFIG_BT_NIMBLE_GAP_SERVICE ble_svc_gap_init(); +#endif +#if MYNEWT_VAL(BLE_GATTS) ble_svc_gatt_init(); +#endif rc = ble_gatts_count_cfg(gatt_svr_svcs); if (rc != 0) { diff --git a/examples/bluetooth/nimble/ble_multi_conn/ble_multi_conn_cent/main/gatt_svr.c b/examples/bluetooth/nimble/ble_multi_conn/ble_multi_conn_cent/main/gatt_svr.c index 05cd00b7ef..3325d82615 100644 --- a/examples/bluetooth/nimble/ble_multi_conn/ble_multi_conn_cent/main/gatt_svr.c +++ b/examples/bluetooth/nimble/ble_multi_conn/ble_multi_conn_cent/main/gatt_svr.c @@ -160,8 +160,12 @@ gatt_svr_init(void) { int rc; +#if CONFIG_BT_NIMBLE_GAP_SERVICE ble_svc_gap_init(); +#endif +#if MYNEWT_VAL(BLE_GATTS) ble_svc_gatt_init(); +#endif rc = ble_gatts_count_cfg(gatt_svr_svcs); if (rc != 0) { diff --git a/examples/bluetooth/nimble/ble_multi_conn/ble_multi_conn_prph/main/gatt_svr.c b/examples/bluetooth/nimble/ble_multi_conn/ble_multi_conn_prph/main/gatt_svr.c index 0e7e982b80..8cf94097c0 100644 --- a/examples/bluetooth/nimble/ble_multi_conn/ble_multi_conn_prph/main/gatt_svr.c +++ b/examples/bluetooth/nimble/ble_multi_conn/ble_multi_conn_prph/main/gatt_svr.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -114,9 +114,12 @@ gatt_svr_init(void) { int rc; +#if CONFIG_BT_NIMBLE_GAP_SERVICE ble_svc_gap_init(); +#endif +#if MYNEWT_VAL(BLE_GATTS) ble_svc_gatt_init(); - +#endif rc = ble_gatts_count_cfg(gatt_svr_svcs); if (rc != 0) { return rc; diff --git a/examples/bluetooth/nimble/ble_periodic_adv/main/main.c b/examples/bluetooth/nimble/ble_periodic_adv/main/main.c index 83c2e67f84..c315ba9b7a 100644 --- a/examples/bluetooth/nimble/ble_periodic_adv/main/main.c +++ b/examples/bluetooth/nimble/ble_periodic_adv/main/main.c @@ -177,6 +177,7 @@ app_main(void) ble_hs_cfg.reset_cb = periodic_adv_on_reset; ble_hs_cfg.sync_cb = periodic_adv_on_sync; ble_hs_cfg.store_status_cb = ble_store_util_status_rr; + #if CONFIG_BT_NIMBLE_GAP_SERVICE /* Set the default device name. */ int rc = ble_svc_gap_device_name_set("nimble_periodic_adv"); diff --git a/examples/bluetooth/nimble/ble_phy/phy_prph/main/gatt_svr.c b/examples/bluetooth/nimble/ble_phy/phy_prph/main/gatt_svr.c index 52ee798707..e14647c31d 100644 --- a/examples/bluetooth/nimble/ble_phy/phy_prph/main/gatt_svr.c +++ b/examples/bluetooth/nimble/ble_phy/phy_prph/main/gatt_svr.c @@ -136,8 +136,12 @@ gatt_svr_init_le_phy(void) { int rc; +#if CONFIG_BT_NIMBLE_GAP_SERVICE ble_svc_gap_init(); +#endif +#if MYNEWT_VAL(BLE_GATTS) ble_svc_gatt_init(); +#endif rc = ble_gatts_count_cfg(gatt_svr_svcs_le_phy); if (rc != 0) { diff --git a/examples/bluetooth/nimble/ble_spp/spp_server/main/main.c b/examples/bluetooth/nimble/ble_spp/spp_server/main/main.c index 42f01344a2..2617c4e679 100644 --- a/examples/bluetooth/nimble/ble_spp/spp_server/main/main.c +++ b/examples/bluetooth/nimble/ble_spp/spp_server/main/main.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2021-2025 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2021-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Unlicense OR CC0-1.0 */ @@ -332,9 +332,12 @@ gatt_svr_register_cb(struct ble_gatt_register_ctxt *ctxt, void *arg) int gatt_svr_init(void) { int rc = 0; +#if CONFIG_BT_NIMBLE_GAP_SERVICE ble_svc_gap_init(); +#endif +#if MYNEWT_VAL(BLE_GATTS) ble_svc_gatt_init(); - +#endif rc = ble_gatts_count_cfg(new_ble_svc_gatt_defs); if (rc != 0) { diff --git a/examples/bluetooth/nimble/blehr/main/gatt_svr.c b/examples/bluetooth/nimble/blehr/main/gatt_svr.c index dfb928f887..ddfb335294 100644 --- a/examples/bluetooth/nimble/blehr/main/gatt_svr.c +++ b/examples/bluetooth/nimble/blehr/main/gatt_svr.c @@ -168,9 +168,12 @@ gatt_svr_init(void) { int rc; +#if CONFIG_BT_NIMBLE_GAP_SERVICE ble_svc_gap_init(); +#endif +#if MYNEWT_VAL(BLE_GATTS) ble_svc_gatt_init(); - +#endif rc = ble_gatts_count_cfg(gatt_svr_svcs); if (rc != 0) { return rc; diff --git a/examples/bluetooth/nimble/bleprph/main/gatt_svr.c b/examples/bluetooth/nimble/bleprph/main/gatt_svr.c index eb45537f4f..8aae8a48b5 100644 --- a/examples/bluetooth/nimble/bleprph/main/gatt_svr.c +++ b/examples/bluetooth/nimble/bleprph/main/gatt_svr.c @@ -243,8 +243,12 @@ gatt_svr_init(void) #if CONFIG_BT_NIMBLE_GAP_SERVICE ble_svc_gap_init(); #endif /* CONFIG_BT_NIMBLE_GAP_SERVICE */ +#if MYNEWT_VAL(BLE_GATTS) ble_svc_gatt_init(); +#endif +#if CONFIG_BT_NIMBLE_ANS_SERVICE ble_svc_ans_init(); +#endif rc = ble_gatts_count_cfg(gatt_svr_svcs); if (rc != 0) { diff --git a/examples/bluetooth/nimble/bleprph_host_only/main/gatt_svr.c b/examples/bluetooth/nimble/bleprph_host_only/main/gatt_svr.c index 3b4b4d6a2d..60c3d2bf73 100644 --- a/examples/bluetooth/nimble/bleprph_host_only/main/gatt_svr.c +++ b/examples/bluetooth/nimble/bleprph_host_only/main/gatt_svr.c @@ -221,9 +221,15 @@ gatt_svr_init(void) { int rc; +#if CONFIG_BT_NIMBLE_GAP_SERVICE ble_svc_gap_init(); +#endif /* CONFIG_BT_NIMBLE_GAP_SERVICE */ +#if MYNEWT_VAL(BLE_GATTS) ble_svc_gatt_init(); +#endif +#if CONFIG_BT_NIMBLE_ANS_SERVICE ble_svc_ans_init(); +#endif rc = ble_gatts_count_cfg(gatt_svr_svcs); if (rc != 0) { diff --git a/examples/bluetooth/nimble/bleprph_host_only/main/uart_driver.c b/examples/bluetooth/nimble/bleprph_host_only/main/uart_driver.c index 55d98ebb36..0cd5a7f71f 100644 --- a/examples/bluetooth/nimble/bleprph_host_only/main/uart_driver.c +++ b/examples/bluetooth/nimble/bleprph_host_only/main/uart_driver.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2021-2025 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2021-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Unlicense OR CC0-1.0 */ @@ -220,7 +220,12 @@ ble_transport_to_ll_cmd_impl(void *buf) data[0] = HCI_H4_CMD; memcpy(data + 1, buf, len - 1); hci_uart_send(data, len); + +#if MYNEWT_VAL(MP_RUNTIME_ALLOC) + ble_transport_free(BLE_HCI_CMD, buf); +#else ble_transport_free(buf); +#endif return 0; } diff --git a/examples/bluetooth/nimble/bleprph_wifi_coex/main/gatt_svr.c b/examples/bluetooth/nimble/bleprph_wifi_coex/main/gatt_svr.c index 0eda8bfc9e..0d36e70738 100644 --- a/examples/bluetooth/nimble/bleprph_wifi_coex/main/gatt_svr.c +++ b/examples/bluetooth/nimble/bleprph_wifi_coex/main/gatt_svr.c @@ -194,9 +194,15 @@ gatt_svr_init(void) { int rc; +#if CONFIG_BT_NIMBLE_GAP_SERVICE ble_svc_gap_init(); +#endif /* CONFIG_BT_NIMBLE_GAP_SERVICE */ +#if MYNEWT_VAL(BLE_GATTS) ble_svc_gatt_init(); +#endif +#if CONFIG_BT_NIMBLE_ANS_SERVICE ble_svc_ans_init(); +#endif rc = ble_gatts_count_cfg(gatt_svr_svcs); if (rc != 0) { diff --git a/examples/bluetooth/nimble/power_save/main/gatt_svr.c b/examples/bluetooth/nimble/power_save/main/gatt_svr.c index f59de24e10..04e170d38b 100644 --- a/examples/bluetooth/nimble/power_save/main/gatt_svr.c +++ b/examples/bluetooth/nimble/power_save/main/gatt_svr.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -227,9 +227,15 @@ gatt_svr_init(void) { int rc; +#if CONFIG_BT_NIMBLE_GAP_SERVICE ble_svc_gap_init(); +#endif /* CONFIG_BT_NIMBLE_GAP_SERVICE */ +#if MYNEWT_VAL(BLE_GATTS) ble_svc_gatt_init(); +#endif +#if CONFIG_BT_NIMBLE_ANS_SERVICE ble_svc_ans_init(); +#endif rc = ble_gatts_count_cfg(gatt_svr_svcs); if (rc != 0) { diff --git a/examples/bluetooth/nimble/throughput_app/bleprph_throughput/main/gatt_svr.c b/examples/bluetooth/nimble/throughput_app/bleprph_throughput/main/gatt_svr.c index 40adb0e4d3..0f952f2f67 100644 --- a/examples/bluetooth/nimble/throughput_app/bleprph_throughput/main/gatt_svr.c +++ b/examples/bluetooth/nimble/throughput_app/bleprph_throughput/main/gatt_svr.c @@ -197,8 +197,12 @@ gatt_svr_init(void) { int rc; +#if CONFIG_BT_NIMBLE_GAP_SERVICE ble_svc_gap_init(); +#endif /* CONFIG_BT_NIMBLE_GAP_SERVICE */ +#if MYNEWT_VAL(BLE_GATTS) ble_svc_gatt_init(); +#endif rc = ble_gatts_count_cfg(gatts_test_svcs); if (rc != 0) {