From 3fd78bf329df94d6660832d696d5534a00e186fe Mon Sep 17 00:00:00 2001 From: luoxu Date: Fri, 6 Jun 2025 14:28:19 +0800 Subject: [PATCH 1/3] fix(ble_mesh): fixed proxy server might send segment message with incorrect format refer commit: 7738bca124a2d15f14a3b9573ee468c166077a37 --- components/bt/esp_ble_mesh/core/proxy_server.c | 2 +- components/bt/esp_ble_mesh/core/scan.c | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/components/bt/esp_ble_mesh/core/proxy_server.c b/components/bt/esp_ble_mesh/core/proxy_server.c index 50d881e991..cc98e03cdc 100644 --- a/components/bt/esp_ble_mesh/core/proxy_server.c +++ b/components/bt/esp_ble_mesh/core/proxy_server.c @@ -1341,7 +1341,7 @@ int bt_mesh_proxy_server_segment_send(struct bt_mesh_conn *conn, uint8_t type, net_buf_simple_pull(msg, mtu); while (msg->len) { - if (msg->len + 1 < mtu) { + if (msg->len + 1 <= mtu) { net_buf_simple_push_u8(msg, BLE_MESH_PROXY_PDU_HDR(BLE_MESH_PROXY_SAR_LAST, type)); proxy_send(conn, msg->data, msg->len); break; diff --git a/components/bt/esp_ble_mesh/core/scan.c b/components/bt/esp_ble_mesh/core/scan.c index 9931c873eb..4ddd2418d3 100644 --- a/components/bt/esp_ble_mesh/core/scan.c +++ b/components/bt/esp_ble_mesh/core/scan.c @@ -2,7 +2,7 @@ /* * SPDX-FileCopyrightText: 2017 Intel Corporation - * SPDX-FileContributor: 2020-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileContributor: 2020-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -86,13 +86,14 @@ int bt_mesh_unprov_dev_info_query(uint8_t uuid[16], uint8_t addr[6], { uint8_t idx = 0; uint8_t cnt = 0; + uint8_t pair_num = unprov_dev_info_fifo.pair_num; - if (uuid == NULL || addr == NULL) { + if (uuid == NULL && addr == NULL) { BT_WARN("No available information to query"); return -1; } - while (cnt < unprov_dev_info_fifo.pair_num) { + while (cnt < pair_num) { idx = (cnt + unprov_dev_info_fifo.start_idx) % BLE_MESH_STORE_UNPROV_INFO_MAX_NUM; if (query_type & BLE_MESH_STORE_UNPROV_INFO_QUERY_TYPE_UUID) { if (!memcmp(unprov_dev_info_fifo.info[idx].addr, addr, 6)) { @@ -118,7 +119,7 @@ int bt_mesh_unprov_dev_info_query(uint8_t uuid[16], uint8_t addr[6], cnt++; } - if (cnt == unprov_dev_info_fifo.pair_num) { + if (cnt == pair_num) { return -1; } From a99d369dc2663f4d68a1de94ee186ce2f18169e5 Mon Sep 17 00:00:00 2001 From: luoxu Date: Wed, 28 May 2025 17:21:26 +0800 Subject: [PATCH 2/3] fix(ble_mesh): fixed issue with recv ntf before ccc done --- .../core/bluedroid_host/adapter.c | 4 +++- .../bt/esp_ble_mesh/core/proxy_client.c | 21 +++++++++++++++++-- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/components/bt/esp_ble_mesh/core/bluedroid_host/adapter.c b/components/bt/esp_ble_mesh/core/bluedroid_host/adapter.c index 2480494181..2f3b3d351b 100644 --- a/components/bt/esp_ble_mesh/core/bluedroid_host/adapter.c +++ b/components/bt/esp_ble_mesh/core/bluedroid_host/adapter.c @@ -1599,8 +1599,10 @@ static void bt_mesh_bta_gattc_cb(tBTA_GATTC_EVT event, tBTA_GATTC *p_data) for (i = 0; i < ARRAY_SIZE(bt_mesh_gattc_info); i++) { if (bt_mesh_gattc_info[i].conn.handle == handle) { if (bt_mesh_gattc_info[i].wr_desc_done == false) { - BT_DBG("Receive notification before finishing to write ccc"); + BT_WARN("Receive notification before finishing to write ccc"); +#if !CONFIG_BLE_MESH_BQB_TEST return; +#endif } conn = &bt_mesh_gattc_info[i].conn; diff --git a/components/bt/esp_ble_mesh/core/proxy_client.c b/components/bt/esp_ble_mesh/core/proxy_client.c index 016db7f2ce..d89c5ff1fd 100644 --- a/components/bt/esp_ble_mesh/core/proxy_client.c +++ b/components/bt/esp_ble_mesh/core/proxy_client.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2017-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -31,7 +31,7 @@ static struct bt_mesh_proxy_server { struct bt_mesh_conn *conn; - + bt_mesh_addr_t addr; enum __attribute__((packed)) { CLI_NONE, CLI_PROV, @@ -465,6 +465,7 @@ static void proxy_connected(bt_mesh_addr_t *addr, struct bt_mesh_conn *conn, int server->conn = bt_mesh_conn_ref(conn); server->conn_type = CLI_NONE; + memcpy(&server->addr, addr, sizeof(bt_mesh_addr_t)); net_buf_simple_reset(&server->buf); #if CONFIG_BLE_MESH_RPR_SRV && CONFIG_BLE_MESH_PB_GATT @@ -629,6 +630,12 @@ static ssize_t proxy_write_ccc(bt_mesh_addr_t *addr, struct bt_mesh_conn *conn) return 0; } +#if CONFIG_BLE_MESH_BQB_TEST + /* notify maybe received first */ + if (server->conn_type == CLI_PROXY) { + return 0; + } +#endif return -EINVAL; } @@ -641,6 +648,16 @@ static ssize_t proxy_recv_ntf(struct bt_mesh_conn *conn, uint8_t *data, uint16_t return -ENOTCONN; } +#if CONFIG_BLE_MESH_BQB_TEST + /* update conn type if notify received before write ccc */ + if (server->conn_type == CLI_NONE) { + server->conn_type = CLI_PROXY; + if (proxy_client_connect_cb) { + proxy_client_connect_cb(&server->addr, server - servers, server->net_idx); + } + } +#endif + if (server->conn_type == CLI_PROXY) { return proxy_recv(conn, NULL, data, len, 0, 0); } From 9b9b5c335f75eefe7db7d26385d1d9c854262829 Mon Sep 17 00:00:00 2001 From: luoxu Date: Fri, 6 Jun 2025 14:37:08 +0800 Subject: [PATCH 3/3] feat(ble_mesh): update lib to f15b27e2d2 --- components/bt/esp_ble_mesh/lib/lib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/bt/esp_ble_mesh/lib/lib b/components/bt/esp_ble_mesh/lib/lib index 0d48fd67ae..35d9a782d0 160000 --- a/components/bt/esp_ble_mesh/lib/lib +++ b/components/bt/esp_ble_mesh/lib/lib @@ -1 +1 @@ -Subproject commit 0d48fd67aead5d2929851a849e987a49fa094dd7 +Subproject commit 35d9a782d05c6a86672622802d64c2f79e7a647b