From 6297edade51094bca08d7660d4c1f2624394dcd2 Mon Sep 17 00:00:00 2001 From: luoxu Date: Wed, 23 Apr 2025 16:35:34 +0800 Subject: [PATCH] fix(ble_mesh): fixed the issue of incorrect proxy adv flag setting --- components/bt/esp_ble_mesh/core/ext_adv.c | 3 ++- .../bt/esp_ble_mesh/core/proxy_server.c | 25 ++++++++++++------- .../bt/esp_ble_mesh/core/proxy_server.h | 1 + 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/components/bt/esp_ble_mesh/core/ext_adv.c b/components/bt/esp_ble_mesh/core/ext_adv.c index fecfe30c3b..68d5403995 100644 --- a/components/bt/esp_ble_mesh/core/ext_adv.c +++ b/components/bt/esp_ble_mesh/core/ext_adv.c @@ -303,6 +303,7 @@ static uint32_t received_adv_evts_handle(uint32_t recv_evts) CONFIG_BLE_MESH_GATT_PROXY_SERVER if (unlikely(i == BLE_MESH_ADV_PROXY_INS)) { BT_DBG("Mesh Proxy Advertising auto stop"); + bt_mesh_proxy_server_adv_flag_set(false); } else #endif { @@ -366,7 +367,7 @@ void bt_mesh_adv_update(void) { #if (CONFIG_BLE_MESH_NODE && CONFIG_BLE_MESH_PB_GATT) || \ CONFIG_BLE_MESH_GATT_PROXY_SERVER - BT_WARN("Mesh Proxy Advertising stopped manually"); + BT_DBG("Mesh Proxy Advertising stopped manually"); bt_mesh_proxy_server_adv_stop(); if (adv_insts[BLE_MESH_ADV_PROXY_INS].busy) { ble_mesh_adv_task_wakeup(ADV_TASK_PROXY_ADV_UPD_EVT); diff --git a/components/bt/esp_ble_mesh/core/proxy_server.c b/components/bt/esp_ble_mesh/core/proxy_server.c index ac95c24cee..68f2978609 100644 --- a/components/bt/esp_ble_mesh/core/proxy_server.c +++ b/components/bt/esp_ble_mesh/core/proxy_server.c @@ -2,7 +2,7 @@ /* * SPDX-FileCopyrightText: 2017 Intel Corporation - * SPDX-FileContributor: 2018-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileContributor: 2018-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -170,6 +170,11 @@ static void proxy_sar_timeout(struct k_work *work) bt_mesh_gatts_disconnect(client->conn, 0x13); } +void bt_mesh_proxy_server_adv_flag_set(bool enable) +{ + proxy_adv_enabled = enable; +} + #if CONFIG_BLE_MESH_GATT_PROXY_SERVER /** * The following callbacks are used to notify proper information @@ -853,7 +858,9 @@ static void proxy_connected(struct bt_mesh_conn *conn, uint8_t err) conn_count++; /* Since we use ADV_OPT_ONE_TIME */ - proxy_adv_enabled = false; +#if !CONFIG_BLE_MESH_USE_BLE_50 + bt_mesh_proxy_server_adv_flag_set(false); +#endif #if CONFIG_BLE_MESH_PROXY_SOLIC_PDU_RX /* Before re-enabling advertising, stop advertising @@ -1498,7 +1505,7 @@ static int node_id_adv(struct bt_mesh_subnet *sub) return err; } - proxy_adv_enabled = true; + bt_mesh_proxy_server_adv_flag_set(true); return 0; } @@ -1529,7 +1536,7 @@ static int net_id_adv(struct bt_mesh_subnet *sub) return err; } - proxy_adv_enabled = true; + bt_mesh_proxy_server_adv_flag_set(true); return 0; } @@ -1592,7 +1599,7 @@ static int private_node_id_adv(struct bt_mesh_subnet *sub) return err; } - proxy_adv_enabled = true; + bt_mesh_proxy_server_adv_flag_set(true); return 0; } @@ -1636,7 +1643,7 @@ static int private_net_id_adv(struct bt_mesh_subnet *sub) return err; } - proxy_adv_enabled = true; + bt_mesh_proxy_server_adv_flag_set(true); return 0; } @@ -1902,7 +1909,7 @@ int32_t bt_mesh_proxy_server_adv_start(void) prov_sd, prov_sd_len) == 0) { #endif /* CONFIG_BLE_MESH_USE_BLE_50 */ - proxy_adv_enabled = true; + bt_mesh_proxy_server_adv_flag_set(true); /* Advertise 60 seconds using fast interval */ if (prov_fast_adv) { @@ -1959,7 +1966,7 @@ int bt_mesh_proxy_server_adv_stop(void) return -EINVAL; } - proxy_adv_enabled = false; + bt_mesh_proxy_server_adv_flag_set(false); return 0; } @@ -2022,7 +2029,7 @@ int bt_mesh_proxy_server_deinit(void) proxy_adv_inst = BLE_MESH_ADV_INS_UNUSED; #endif - proxy_adv_enabled = false; + bt_mesh_proxy_server_adv_flag_set(false); gatt_svc = MESH_GATT_NONE; #if CONFIG_BLE_MESH_GATT_PROXY_SERVER diff --git a/components/bt/esp_ble_mesh/core/proxy_server.h b/components/bt/esp_ble_mesh/core/proxy_server.h index 6cebe965da..fc4041f877 100644 --- a/components/bt/esp_ble_mesh/core/proxy_server.h +++ b/components/bt/esp_ble_mesh/core/proxy_server.h @@ -118,6 +118,7 @@ void bt_mesh_proxy_server_identity_stop(struct bt_mesh_subnet *sub); bool bt_mesh_proxy_server_relay(struct net_buf_simple *buf, uint16_t dst); void bt_mesh_proxy_server_addr_add(struct net_buf_simple *buf, uint16_t addr); +void bt_mesh_proxy_server_adv_flag_set(bool enable); int bt_mesh_proxy_server_init(void); int bt_mesh_proxy_server_deinit(void);