From bfa1dfb194f20f80b394d9bb18e89932727a22e0 Mon Sep 17 00:00:00 2001 From: ltmopen <110580482+ltmopen@users.noreply.github.com> Date: Mon, 28 Oct 2024 15:20:47 +0800 Subject: [PATCH 1/2] Update adapter.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 源代码开启编译优化后uuid将不能被正确赋值,导致函数ble_gatts_find_svc执行失败。 --- components/bt/esp_ble_mesh/core/nimble_host/adapter.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/components/bt/esp_ble_mesh/core/nimble_host/adapter.c b/components/bt/esp_ble_mesh/core/nimble_host/adapter.c index fcad7200599..67752467e99 100644 --- a/components/bt/esp_ble_mesh/core/nimble_host/adapter.c +++ b/components/bt/esp_ble_mesh/core/nimble_host/adapter.c @@ -1334,16 +1334,16 @@ int bt_mesh_gatts_service_start(struct bt_mesh_gatt_service *svc) { int rc; uint16_t handle; - + // const ble_uuid_t *uuid; if (BLE_MESH_UUID_16(svc->attrs[0].user_data)->val == BT_UUID_MESH_PROXY_VAL) { - rc = ble_gatts_find_svc(BLE_UUID16_DECLARE(BT_UUID_MESH_PROXY_VAL), &handle); + const ble_uuid_t *uuid = BLE_UUID16_DECLARE(BT_UUID_MESH_PROXY_VAL); + rc = ble_gatts_find_svc(uuid, &handle); } else { - rc = ble_gatts_find_svc(BLE_UUID16_DECLARE(BT_UUID_MESH_PROV_VAL), &handle); + const ble_uuid_t *uuid = BLE_UUID16_DECLARE(BT_UUID_MESH_PROV_VAL); + rc = ble_gatts_find_svc(uuid, &handle); } - assert(rc == 0); ble_gatts_svc_set_visibility(handle, 1); - /* FIXME: figure out end handle */ ble_svc_gatt_changed(handle, 0xffff); From d56f94ca939c7228cc45ee1b64e1a408e264d10f Mon Sep 17 00:00:00 2001 From: ltmopen <110580482+ltmopen@users.noreply.github.com> Date: Mon, 28 Oct 2024 21:27:07 +0800 Subject: [PATCH 2/2] Update adapter.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit bt_mesh_gatts_service_stop函数uuid赋值方式不对,当开启编译优化时uuid无法正确赋值 --- components/bt/esp_ble_mesh/core/nimble_host/adapter.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/components/bt/esp_ble_mesh/core/nimble_host/adapter.c b/components/bt/esp_ble_mesh/core/nimble_host/adapter.c index 67752467e99..419db1271d0 100644 --- a/components/bt/esp_ble_mesh/core/nimble_host/adapter.c +++ b/components/bt/esp_ble_mesh/core/nimble_host/adapter.c @@ -1309,16 +1309,18 @@ int bt_mesh_gatts_service_stop(struct bt_mesh_gatt_service *svc) { int rc; uint16_t handle; - + if (!svc) { BT_ERR("%s, Invalid parameter", __func__); return -EINVAL; } if (BLE_MESH_UUID_16(svc->attrs[0].user_data)->val == BT_UUID_MESH_PROXY_VAL) { - rc = ble_gatts_find_svc(BLE_UUID16_DECLARE(BT_UUID_MESH_PROXY_VAL), &handle); + const ble_uuid_t *uuid = BLE_UUID16_DECLARE(BT_UUID_MESH_PROXY_VAL); + rc = ble_gatts_find_svc(uuid, &handle); } else { - rc = ble_gatts_find_svc(BLE_UUID16_DECLARE(BT_UUID_MESH_PROV_VAL), &handle); + const ble_uuid_t *uuid = BLE_UUID16_DECLARE(BT_UUID_MESH_PROV_VAL); + rc = ble_gatts_find_svc(uuid, &handle); } assert(rc == 0);