Skip to content

Fix undefined reference to ble_svc_gap_device_name_set when GATT server is disabled#349

Merged
h2zero merged 2 commits into
h2zero:masterfrom
iranl:patch-1
Aug 24, 2025
Merged

Fix undefined reference to ble_svc_gap_device_name_set when GATT server is disabled#349
h2zero merged 2 commits into
h2zero:masterfrom
iranl:patch-1

Conversation

@iranl

@iranl iranl commented Jul 20, 2025

Copy link
Copy Markdown
Contributor

Since commit espressif/esp-idf@a58ce39 (included in v5.5-RC1) the function ble_svc_gap_device_name_set will not be defined in esp-idf when CONFIG_BT_NIMBLE_GATT_SERVER=n and compilation of esp-nimble-cpp will fail as a result.

This PR makes calling ble_svc_gap_device_name_set conditional on CONFIG_BT_NIMBLE_GAP_SERVICE in line with the examples in esp-idf master (see the above commit)

@h2zero

h2zero commented Jul 21, 2025

Copy link
Copy Markdown
Owner

Thanks, but this will also prevent the ability to change the name if that macro is not defined, such as when using an older NimBLE/IDF version. We should check if it is defined at all first then check the value.

@iranl

iranl commented Jul 21, 2025

Copy link
Copy Markdown
Contributor Author

CONFIG_BT_NIMBLE_GAP_SERVICE was introduced in IDF 5.1 and setting ble_svc_gap_device_name_set shouldn't have any effect when CONFIG_BT_NIMBLE_GAP_SERVICE=n since that time. It will only give a compilation error starting with IDF 5.5 though.

But I get your point for IDF 5.0 and below.

Imho most obvious solution would be to change the macro to:
#if !defined(ESP_IDF_VERSION) || ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 5, 0) || CONFIG_BT_NIMBLE_GAP_SERVICE

So this should only affect IDF 5.5 and up.

@h2zero

h2zero commented Aug 24, 2025

Copy link
Copy Markdown
Owner

Thanks!

@h2zero h2zero merged commit 88df909 into h2zero:master Aug 24, 2025
41 checks passed
h2zero pushed a commit that referenced this pull request Sep 2, 2025
…er is disabled (#349)

* Fix undefined reference to ble_svc_gap_device_name_set when GATT server is disabled

* Do not affect ESP-IDF <5.5.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants