mirror of
https://github.com/espressif/esp-idf.git
synced 2026-04-27 19:13:21 +00:00
feat(nimble): Added changes in examples to have code under flags
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user