Skip to content

Commit 4145c5f

Browse files
authored
NimBLE updates (#24163)
1 parent 512ecb6 commit 4145c5f

File tree

73 files changed

+1014
-761
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+1014
-761
lines changed

lib/libesp32_div/esp-nimble-cpp/.gitignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

lib/libesp32_div/esp-nimble-cpp/CHANGELOG.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,36 @@
11
# Changelog
22
All notable changes to this project will be documented in this file.
33

4+
## [2.3.3] 2025-09-05
5+
6+
## Fixed
7+
- NimBLEAdvertisedDevice::isConnectable returning incorrect result.
8+
- Extended advertisements not reporting full data.
9+
10+
## Added
11+
- Support up to 1650 bytes of advertisement with extended advertising
12+
13+
## [2.3.2] 2025-09-02
14+
15+
## Fixed
16+
- Build failures with esp-idf versions 4.x.
17+
- Workaround for upstream issue causing onConnectFail to not be called.
18+
- Build failures with idf v5.5+ and specific roles are not enabled.
19+
20+
## Changed
21+
- Allow peripheral and central roles to be used without broadcaster/observer roles.
22+
- Where applicable, `MYNEWT_VAL_` macros are used to control feature availability instead of `CONFIG_`
23+
24+
## [2.3.1] 2025-06-11
25+
26+
## Fixed
27+
- Build errors when disabling BLE roles.
28+
- `NimBLEClient::readValue` call not returning when the instance was created with a`NimBLEServer` and reading a secured characteristic.
29+
- `NimBLEScan` destructor potentially causing a crash.
30+
31+
## Added
32+
- `NimBLEBeacon::BeaconData` `std::vector<uint8_t>` operator to allow it to be used as a parameter to `NimBLEAdvertisementData::setManufacturerData`.
33+
434
## [2.3.0] 2025-05-19
535

636
## Fixed

lib/libesp32_div/esp-nimble-cpp/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ idf_component_register(
3737
"esp32c3"
3838
"esp32c5"
3939
"esp32c6"
40+
"esp32c61"
4041
"esp32h2"
4142
"esp32p4"
4243
INCLUDE_DIRS

lib/libesp32_div/esp-nimble-cpp/Kconfig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,10 @@ config NIMBLE_CPP_FREERTOS_TASK_BLOCK_BIT
204204
Configure the bit to set in the task notification value when a task is blocked waiting for an event.
205205
This should be set to a bit that is not used by other notifications in the system.
206206

207+
config NIMBLE_CPP_IDF
208+
bool
209+
default BT_NIMBLE_ENABLED
210+
207211
#
208212
# BT config
209213
#

lib/libesp32_div/esp-nimble-cpp/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
NimBLE CPP library for use with ESP32 that attempts to maintain compatibility with the [nkolban cpp_utils BLE API](https://github.com/nkolban/esp32-snippets/tree/master/cpp_utils).
1111

12+
The library is threadsafe, characteristics can be set from any thread.
13+
1214
**An Arduino version of this library, including NimBLE, can be [found here.](https://github.com/h2zero/NimBLE-Arduino)**
1315

1416
This library **significantly** reduces resource usage and improves performance for ESP32 BLE applications as compared

lib/libesp32_div/esp-nimble-cpp/docs/1.x_to2.x_migration_guide.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ The changes listed here are only the required changes that must be made, and a s
4343
Note: If setting a custom address, it should be set with `NimBLEDevice::setOwnAddr` first before calling `NimBLEDevice::setOwnAddrType`.
4444
- `NimBLEDevice::getClientListSize` replaced with `NimBLEDevice::getCreatedClientCount`.
4545
- `NimBLEDevice::getClientList` was removed and `NimBLEDevice::getConnectedClients` can be used instead which returns a `std::vector` of pointers to the connected client instances. This was done because internally the clients are managed in a `std::array` which replaced the 'std::list`.
46+
- `NimBLEDevice::getClientByID(uint16_t conn_id);` has been changed to `NimBLEDevice::getClientByHandle(uint16_t connHandle)`
4647
<br/>
4748

4849
## BLE Addresses
@@ -54,7 +55,7 @@ The default address type is public `0`, whereas many devices use a random `1` ad
5455
If you experience this issue please create your address instances with the address type specified, i.e. `NimBLEAddress address("11:22:33:44:55:66", TYPE_HERE)`
5556

5657
`NimBLEAddress::getNative` has been removed and replaced with `NimBLEAddress::getBase`.
57-
This returns a pointer to `const ble_addr_t` instead of a pointer to the address value that `getNative` did. The value can be accessed through this struct via `ble_addr_t.value` and type is in `ble_addr_t.type`.
58+
This returns a pointer to `const ble_addr_t` instead of a pointer to the address value that `getNative` did. The value can be accessed through this struct via `ble_addr_t.val` and type is in `ble_addr_t.type`.
5859
<br/>
5960

6061
## BLE UUID's
@@ -133,6 +134,7 @@ Have been removed, instead the application should use `NimBLERemoteCharacteristi
133134
- - `NimBLEScanCallbacks::onResult`, functions the same as the old `NimBLEAdvertisedDeviceCallbacks::onResult` but now takes aa `const NimBLEAdvertisedDevice*` instead of non-const.
134135
- - `NimBLEScanCallbacks::onScanEnd`, replaces the scanEnded callback passed to `NimBLEScan::start` and now takes a `const NimBLEScanResults&` and `int reason` parameter.
135136
- - `NimBLEScanCallbacks::onDiscovered`, This is called immediately when a device is first scanned, before any scan response data is available and takes a `const NimBLEAdvertisedDevice*` parameter.
137+
- `NimBLEScan::setAdvertisedDeviceCallbacks(NimBLEAdvertisedDeviceCallbacks* callbacks, bool wantDuplicates)` has been changed to `NimBLEScan::setScanCallbacks(NimBLEScanCallbacks* callbacks, bool wantDuplicates);`
136138
<br/>
137139

138140
### Advertised Device

lib/libesp32_div/esp-nimble-cpp/docs/Doxyfile

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@ PROJECT_NAME = esp-nimble-cpp
4848
# could be handy for archiving the generated documentation or if some version
4949
# control system is used.
5050

51-
PROJECT_NUMBER = 2.3.0
52-
51+
PROJECT_NUMBER = 2.3.3
5352
# Using the PROJECT_BRIEF tag one can provide an optional one line description
5453
# for a project that appears at the top of each page and should give viewer a
5554
# quick idea about the purpose of the project. Keep the description short.
@@ -2417,12 +2416,12 @@ INCLUDE_FILE_PATTERNS =
24172416
# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
24182417

24192418
PREDEFINED = _DOXYGEN_ \
2420-
CONFIG_BT_ENABLED \
2421-
CONFIG_BT_NIMBLE_ROLE_CENTRAL \
2422-
CONFIG_BT_NIMBLE_ROLE_OBSERVER \
2423-
CONFIG_BT_NIMBLE_ROLE_PERIPHERAL \
2424-
CONFIG_BT_NIMBLE_ROLE_BROADCASTER \
2425-
CONFIG_BT_NIMBLE_EXT_ADV
2419+
CONFIG_BT_NIMBLE_ENABLED=1 \
2420+
MYNEWT_VAL_BLE_ROLE_CENTRAL=1 \
2421+
MYNEWT_VAL_BLE_ROLE_OBSERVER=1 \
2422+
MYNEWT_VAL_BLE_ROLE_PERIPHERAL=1 \
2423+
MYNEWT_VAL_BLE_ROLE_BROADCASTER=1 \
2424+
MYNEWT_VAL_BLE_EXT_ADV=1
24262425

24272426
# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this
24282427
# tag can be used to specify a list of macro names that should be expanded. The

lib/libesp32_div/esp-nimble-cpp/docs/Migration_guide.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ This can be changed to use passkey authentication or numeric comparison. See [Se
234234
Advertising works the same as the original API except:
235235

236236
Calling `NimBLEAdvertising::setAdvertisementData` will entirely replace any data set with `NimBLEAdvertising::addServiceUUID`, or
237-
`NimBLEAdvertising::setAppearance` or similar methods. You should set all the data you wish to advertise within the `NimBLEAdvertisementData` instead.
237+
`NimBLEAdvertising::setAppearance` or similar methods. You should set all the data you wish to advertise within the `NimBLEAdvertisementData` instead if calling `NimBLEAdvertising::setAdvertisementData`.
238238
<br/>
239239

240240
> BLEAdvertising::start (NimBLEAdvertising::start)

lib/libesp32_div/esp-nimble-cpp/docs/Usage_tips.md

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
# Usage Tips
22

3-
## Put BLE functions in a task running on the NimBLE stack core
3+
## Threadsafety
44

5-
When commands are sent to the stack from a different core they can experience delays in execution.
6-
This library detects this and invokes the esp32 IPC to reroute these commands through the correct core but this also increases overhead.
7-
Therefore it is highly recommended to create tasks for BLE to run on the same core, the macro `CONFIG_BT_NIMBLE_PINNED_TO_CORE` can be used to set the core.
8-
<br/>
5+
This library is threadsafe. Attribues can be manipulated freely.
96

107
## Do not delete client instances unless necessary or unused
118

@@ -32,6 +29,41 @@ or nullptr such as when calling `NimBLEClient::getService`. The latter being a
3229
Most of the functions in this library return something that should be checked before proceeding.
3330
<br/>
3431

32+
## Persisted bonds can be lost due to low MAX_CCCDS
33+
34+
The symptom: CONFIG_BT_NIMBLE_MAX_BONDS is set to N, but a smaller number of bonds is preserved, perhaps even a single bond. The limitation of persisted bonds can be observed via NimBLEDevice::getNumBonds(). The number may not reach CONFIG_BT_NIMBLE_MAX_BONDS.
35+
36+
Cause: For each bond, NimBLE persists each of the CCCD (client characteristic configuration descriptor) values that have been subscribed
37+
to by the client. If CONFIG_BT_NIMBLE_MAX_CCCDS is too low, the older CCCD values are overwritten by the newer ones. The loss of the older
38+
CCCDs values results in those bonds being lost.
39+
40+
Fix: Increase CONFIG_BT_NIMBLE_MAX_CCCDS. These take approximately 40 bytes in NVS, 2 bytes for the CCCD value and the NVS metadata overhead. The value of
41+
CONFIG_BT_NIMBLE_MAX_CCCDS should conservatively be no less than (CONFIG_BT_NIMBLE_MAX_BONDS * {maximum number of characteristics that can be subscribed to}).
42+
43+
## Device 'Local Name'
44+
45+
'Local name' refers to how the device is seen and displayed.
46+
47+
A devices 'Local name' can be thought of as coming from two places, the <i>Advertising "Local name"</i> and the <i>the GATT Device Name</i>.
48+
49+
### Advertising "Local name"
50+
51+
Field found in the advertising data payload. Value is set via NimBLEAdvertising::setName().
52+
53+
### GATT Device Name
54+
55+
Characteristic UUID 0x2A00 in the Generic Access service. Set via NimBLEDevice::init() or NimBLEDevice::setDeviceName().
56+
57+
This characteristic is read <b>after</b> connecting to the device.
58+
59+
### Important considerations
60+
61+
* OSes cache the <i>'GATT Device Name'</i>.
62+
* OSes update the device name based on the <i>'GATT Device Name'</i> after connecting to a device. This means that if you set the <i>Advertising 'Local name'</i> to "ABCD" but the <i>'GATT Device Name'</i> to "12345", the device will be seen as "ABCD" until connecting to the device, at which time the devices name will change to "12345".
63+
* If no <i>'Advertising "Local name"'</i> is set, OSes, such as iOS, may display the devices name as 'Unnamed' until the device is connected to, at which time the <i>'GATT Device Name'</i> is read and used instead.
64+
65+
It is recommended that both <i>'Advertising "Local name"'</i> <b>and</b> <i>'GATT Device Name'</i> be set appropriately, after considering the above described behavior.
66+
3567
## There will be bugs - please report them
3668

3769
No code is bug free and unit testing will not find them all on it's own. If you encounter a bug, please report it along with any logs and decoded backtrace if applicable.

lib/libesp32_div/esp-nimble-cpp/examples/NimBLE_Client/main/main.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ bool connectToServer() {
112112

113113
/** No client to reuse? Create a new one. */
114114
if (!pClient) {
115-
if (NimBLEDevice::getCreatedClientCount() >= NIMBLE_MAX_CONNECTIONS) {
115+
if (NimBLEDevice::getCreatedClientCount() >= MYNEWT_VAL(BLE_MAX_CONNECTIONS)) {
116116
printf("Max clients reached - no more connections available\n");
117117
return false;
118118
}
@@ -261,8 +261,7 @@ extern "C" void app_main(void) {
261261
* These are the default values, only shown here for demonstration.
262262
*/
263263
// NimBLEDevice::setSecurityAuth(false, false, true);
264-
265-
NimBLEDevice::setSecurityAuth(/*BLE_SM_PAIR_AUTHREQ_BOND | BLE_SM_PAIR_AUTHREQ_MITM |*/ BLE_SM_PAIR_AUTHREQ_SC);
264+
// NimBLEDevice::setSecurityAuth(BLE_SM_PAIR_AUTHREQ_BOND | BLE_SM_PAIR_AUTHREQ_MITM | BLE_SM_PAIR_AUTHREQ_SC);
266265

267266
/** Optional: set the transmit power */
268267
NimBLEDevice::setPower(3); /** 3dbm */

0 commit comments

Comments
 (0)