Skip to content

Commit 3e7ce1e

Browse files
committed
fix(ble_ota): add missing os_mbuf_len function for IDF 4.4 compatibility
1 parent bc1e6f9 commit 3e7ce1e

File tree

6 files changed

+34
-2
lines changed

6 files changed

+34
-2
lines changed

components/bluetooth/ble_profiles/esp/ble_ota/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,7 @@
7777
## v0.1.14 - 2024-11-21
7878
* BLE-OTA:
7979
* Add support for enabling BLE 5.0 for NimBLE
80+
81+
## v0.1.15 - 2025-07-29
82+
* BLE-OTA:
83+
* Fixed BLE OTA data corruption issue caused by incomplete NimBLE's mbufs reading [#502](https://github.com/espressif/esp-iot-solution/pull/502)

components/bluetooth/ble_profiles/esp/ble_ota/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,7 @@ You can create a project from this example by the following command:
1111
```
1212
idf.py create-project-from-example "espressif/ble_ota^0.1.8:ble_ota"
1313
```
14+
15+
> ![TIP]
16+
>
17+
> When using NimBLE, it may be necessary to increase `CONFIG_BT_NIMBLE_HOST_TASK_STACK_SIZE`

components/bluetooth/ble_profiles/esp/ble_ota/README_CN.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,7 @@
55
## 从机示例代码
66

77
[ESP BLE OTA](https://github.com/espressif/esp-iot-solution/tree/master/examples/bluetooth/ble_ota)
8+
9+
> ![TIP]
10+
>
11+
> 使用 NimBLE 时,可能需要增大 `CONFIG_BT_NIMBLE_HOST_TASK_STACK_SIZE`

components/bluetooth/ble_profiles/esp/ble_ota/idf_component.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: "0.1.14"
1+
version: "0.1.15"
22
targets:
33
- esp32
44
- esp32c3

components/bluetooth/ble_profiles/esp/ble_ota/src/nimble_ota.c

Lines changed: 20 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
*/
@@ -19,6 +19,25 @@
1919
#include "freertos/semphr.h"
2020
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0)
2121
#include "esp_nimble_hci.h"
22+
23+
/*
24+
* This is a workaround for the missing os_mbuf_len function in NimBLE.
25+
* It is not present in NimBLE 1.3, but is present in NimBLE 1.4.
26+
* This function is used to get the length of an os_mbuf.
27+
*/
28+
uint16_t
29+
os_mbuf_len(const struct os_mbuf *om)
30+
{
31+
uint16_t len;
32+
33+
len = 0;
34+
while (om != NULL) {
35+
len += om->om_len;
36+
om = SLIST_NEXT(om, om_next);
37+
}
38+
39+
return len;
40+
}
2241
#endif
2342

2443
#ifdef CONFIG_PRE_ENC_OTA
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
CONFIG_BT_NIMBLE_ENABLED=y
2+
CONFIG_BT_NIMBLE_HOST_TASK_STACK_SIZE=6144

0 commit comments

Comments
 (0)