Skip to content

Commit a684c15

Browse files
committed
Merge branch 'bugfix/fix_compilation_issues_v5.4' into 'release/v5.4'
fix(nimble): Address compilation issues in nimble examples (v5.4) See merge request espressif/esp-idf!42866
2 parents 8bc293d + 40a5e18 commit a684c15

File tree

34 files changed

+173
-32
lines changed

34 files changed

+173
-32
lines changed

components/bt/host/nimble/Kconfig.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,7 @@ menu "BLE 5.x Features"
581581

582582
config BT_NIMBLE_EXT_SCAN
583583
bool "Enable extended scanning"
584-
depends on BT_NIMBLE_50_FEATURE_SUPPORT && BT_NIMBLE_ROLE_OBSERVER
584+
depends on BT_NIMBLE_50_FEATURE_SUPPORT
585585
default y
586586
help
587587
Enable this option to do extended scanning.
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#pragma once
8+
9+
#include "esp_log.h"
10+
11+
#ifdef __cplusplus
12+
extern "C" {
13+
#endif
14+
15+
#define BLE_SVC_GAP_TAG "ble_svc_gap"
16+
17+
/**
18+
* Stub implementations for GAP service APIs.
19+
* These are compiled when CONFIG_BT_NIMBLE_GAP_SERVICE is disabled.
20+
*/
21+
22+
static inline void ble_svc_gap_init(void)
23+
{
24+
ESP_LOGE(BLE_SVC_GAP_TAG, "GAP service not enabled. Enable CONFIG_BT_NIMBLE_GAP_SERVICE to use this API.");
25+
}
26+
27+
static inline int ble_svc_gap_device_name_set(const char *name)
28+
{
29+
(void)name;
30+
ESP_LOGE(BLE_SVC_GAP_TAG, "GAP service not enabled. Enable CONFIG_BT_NIMBLE_GAP_SERVICE to use this API.");
31+
return -1;
32+
}
33+
34+
static inline const char *ble_svc_gap_device_name(void)
35+
{
36+
ESP_LOGE(BLE_SVC_GAP_TAG, "GAP service not enabled. Enable CONFIG_BT_NIMBLE_GAP_SERVICE to use this API.");
37+
return NULL;
38+
}
39+
40+
static inline int ble_svc_gap_device_appearance_set(uint16_t appearance)
41+
{
42+
ESP_LOGE(BLE_SVC_GAP_TAG, "GAP service not enabled. Enable CONFIG_BT_NIMBLE_GAP_SERVICE to use this API.");
43+
return -1;
44+
}
45+
46+
static inline int ble_svc_gap_device_key_material_set(uint8_t *session_key, uint8_t *iv)
47+
{
48+
ESP_LOGE(BLE_SVC_GAP_TAG, "GAP service not enabled. Enable CONFIG_BT_NIMBLE_GAP_SERVICE to use this API.");
49+
return -1;
50+
}
51+
52+
#ifdef __cplusplus
53+
}
54+
#endif

components/bt/host/nimble/port/include/esp_nimble_cfg.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1804,9 +1804,11 @@
18041804
#endif
18051805

18061806
/*** @apache-mynewt-nimble/nimble/host/services/gap */
1807+
#ifdef CONFIG_BT_NIMBLE_GAP_SERVICE
18071808
#ifndef MYNEWT_VAL_BLE_SVC_GAP_APPEARANCE
18081809
#define MYNEWT_VAL_BLE_SVC_GAP_APPEARANCE CONFIG_BT_NIMBLE_SVC_GAP_APPEARANCE
18091810
#endif
1811+
#endif
18101812

18111813
#ifndef MYNEWT_VAL_BLE_SVC_GAP_APPEARANCE_WRITE_PERM
18121814
#if CONFIG_BT_NIMBLE_SVC_GAP_APPEAR_WRITE_PERM
@@ -1819,20 +1821,24 @@
18191821
#endif //CONFIG_BT_NIMBLE_SVC_GAP_APPEAR_WRITE_PERM
18201822
#endif //MYNEWT_VAL_BLE_SVC_GAP_APPEARANCE_WRITE_PERM
18211823

1824+
#ifdef CONFIG_BT_NIMBLE_GAP_SERVICE
18221825
#ifndef MYNEWT_VAL_BLE_SVC_GAP_CENTRAL_ADDRESS_RESOLUTION
18231826
#define MYNEWT_VAL_BLE_SVC_GAP_CENTRAL_ADDRESS_RESOLUTION \
18241827
CONFIG_BT_NIMBLE_SVC_GAP_CENT_ADDR_RESOLUTION
18251828
#endif
1829+
#endif
18261830

18271831
#ifndef CONFIG_BT_NIMBLE_SVC_GAP_DEVICE_NAME
18281832
#define MYNEWT_VAL_BLE_SVC_GAP_DEVICE_NAME "nimble"
18291833
#else
18301834
#define MYNEWT_VAL_BLE_SVC_GAP_DEVICE_NAME CONFIG_BT_NIMBLE_SVC_GAP_DEVICE_NAME
18311835
#endif
18321836

1837+
#ifdef CONFIG_BT_NIMBLE_GAP_SERVICE
18331838
#ifndef MYNEWT_VAL_BLE_SVC_GAP_DEVICE_NAME_MAX_LENGTH
18341839
#define MYNEWT_VAL_BLE_SVC_GAP_DEVICE_NAME_MAX_LENGTH CONFIG_BT_NIMBLE_GAP_DEVICE_NAME_MAX_LEN // According to the specification, the maximum length should be 248
18351840
#endif
1841+
#endif
18361842

18371843
#ifndef MYNEWT_VAL_BLE_SVC_GAP_DEVICE_NAME_WRITE_PERM
18381844
#if CONFIG_BT_NIMBLE_SVC_GAP_NAME_WRITE_PERM

components/protocomm/src/transports/protocomm_nimble.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2019-2024 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2019-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -547,6 +547,7 @@ static int simple_ble_start(const simple_ble_cfg_t *cfg)
547547
ble_hs_cfg.sm_our_key_dist = BLE_SM_PAIR_KEY_DIST_ENC | BLE_SM_PAIR_KEY_DIST_ID;
548548
ble_hs_cfg.sm_their_key_dist = BLE_SM_PAIR_KEY_DIST_ENC | BLE_SM_PAIR_KEY_DIST_ID;
549549

550+
#if MYNEWT_VAL(BLE_GATTS)
550551
rc = gatt_svr_init(cfg);
551552
if (rc != 0) {
552553
ESP_LOGE(TAG, "Error initializing GATT server");
@@ -565,6 +566,7 @@ static int simple_ble_start(const simple_ble_cfg_t *cfg)
565566
resp_data.name_len = strlen(ble_svc_gap_device_name());
566567
resp_data.name_is_complete = 1;
567568
}
569+
#endif
568570

569571
/* Set manufacturer data if protocomm_ble_mfg_data points to valid data */
570572
if (protocomm_ble_mfg_data != NULL) {

examples/bluetooth/ble_get_started/nimble/NimBLE_Beacon/main/main.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,14 @@ void app_main(void) {
7878
return;
7979
}
8080

81+
#if CONFIG_BT_NIMBLE_GAP_SERVICE
8182
/* GAP service initialization */
8283
rc = gap_init();
8384
if (rc != 0) {
8485
ESP_LOGE(TAG, "failed to initialize GAP service, error code: %d", rc);
8586
return;
8687
}
88+
#endif
8789

8890
/* NimBLE host configuration initialization */
8991
nimble_host_config_init();

examples/bluetooth/ble_get_started/nimble/NimBLE_Connection/main/main.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,14 @@ void app_main(void) {
8282
return;
8383
}
8484

85+
#if CONFIG_BT_NIMBLE_GAP_SERVICE
8586
/* GAP service initialization */
8687
rc = gap_init();
8788
if (rc != 0) {
8889
ESP_LOGE(TAG, "failed to initialize GAP service, error code: %d", rc);
8990
return;
9091
}
92+
#endif
9193

9294
/* NimBLE host configuration initialization */
9395
nimble_host_config_init();

examples/bluetooth/ble_get_started/nimble/NimBLE_Connection/main/src/gap.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,7 @@ int gap_init(void) {
251251
/* Local variables */
252252
int rc = 0;
253253

254+
254255
/* Initialize GAP service */
255256
ble_svc_gap_init();
256257

examples/bluetooth/ble_get_started/nimble/NimBLE_GATT_Server/main/main.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,14 @@ void app_main(void) {
109109
return;
110110
}
111111

112+
#if CONFIG_BT_NIMBLE_GAP_SERVICE
112113
/* GAP service initialization */
113114
rc = gap_init();
114115
if (rc != 0) {
115116
ESP_LOGE(TAG, "failed to initialize GAP service, error code: %d", rc);
116117
return;
117118
}
119+
#endif
118120

119121
/* GATT server initialization */
120122
rc = gatt_svc_init();

examples/bluetooth/ble_get_started/nimble/NimBLE_Security/main/main.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,14 @@ void app_main(void) {
118118
return;
119119
}
120120

121+
#if CONFIG_BT_NIMBLE_GAP_SERVICE
121122
/* GAP service initialization */
122123
rc = gap_init();
123124
if (rc != 0) {
124125
ESP_LOGE(TAG, "failed to initialize GAP service, error code: %d", rc);
125126
return;
126127
}
128+
#endif
127129

128130
/* GATT server initialization */
129131
rc = gatt_svc_init();

0 commit comments

Comments
 (0)