mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
fix(ble_mesh): fix issues in mesh deinit
This commit is contained in:
parent
836dba4fa7
commit
cd5f3bf146
@ -96,7 +96,7 @@ esp_err_t esp_ble_mesh_deinit(esp_ble_mesh_deinit_param_t *param)
|
||||
}
|
||||
|
||||
/* Take the Semaphore, wait BLE Mesh de-initialization to finish. */
|
||||
xSemaphoreTake(semaphore, portMAX_DELAY);
|
||||
__ASSERT(xSemaphoreTake(semaphore, 3000 / portTICK_PERIOD_MS) == pdTRUE, "BLE Mesh deinit take semaphore failed");
|
||||
/* Don't forget to delete the semaphore at the end. */
|
||||
vSemaphoreDelete(semaphore);
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2017-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@ -33,7 +33,10 @@ esp_err_t esp_ble_mesh_init(esp_ble_mesh_prov_t *prov, esp_ble_mesh_comp_t *comp
|
||||
/**
|
||||
* @brief De-initialize BLE Mesh module.
|
||||
*
|
||||
* @note This function shall be invoked after esp_ble_mesh_client_model_deinit().
|
||||
* @note
|
||||
* 1. This function shall be invoked after esp_ble_mesh_client_model_deinit().
|
||||
* 2. This function is strictly forbidden to run in any BTC Task Context
|
||||
* (e.g. registered Mesh Event Callback).
|
||||
*
|
||||
* @param[in] param: Pointer to the structure of BLE Mesh deinit parameters.
|
||||
*
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2017-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@ -57,6 +57,29 @@
|
||||
#include "esp_ble_mesh_provisioning_api.h"
|
||||
#include "esp_ble_mesh_networking_api.h"
|
||||
|
||||
#if CONFIG_BLE_MESH_DEINIT
|
||||
static SemaphoreHandle_t deinit_comp_semaphore;
|
||||
#endif
|
||||
|
||||
static inline void btc_ble_mesh_prov_cb_to_app_reprocess(esp_ble_mesh_prov_cb_event_t event,
|
||||
esp_ble_mesh_prov_cb_param_t *param)
|
||||
{
|
||||
switch (event) {
|
||||
#if CONFIG_BLE_MESH_DEINIT
|
||||
case ESP_BLE_MESH_DEINIT_MESH_COMP_EVT:
|
||||
assert(deinit_comp_semaphore);
|
||||
/* Give the semaphore when BLE Mesh de-initialization is finished.
|
||||
* @note: At nimble host, once this lock is released, it will cause
|
||||
* the btc task to be deleted.
|
||||
*/
|
||||
xSemaphoreGive(deinit_comp_semaphore);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void btc_ble_mesh_prov_cb_to_app(esp_ble_mesh_prov_cb_event_t event,
|
||||
esp_ble_mesh_prov_cb_param_t *param)
|
||||
{
|
||||
@ -65,6 +88,8 @@ static inline void btc_ble_mesh_prov_cb_to_app(esp_ble_mesh_prov_cb_event_t even
|
||||
if (btc_ble_mesh_cb) {
|
||||
btc_ble_mesh_cb(event, param);
|
||||
}
|
||||
|
||||
btc_ble_mesh_prov_cb_to_app_reprocess(event, param);
|
||||
}
|
||||
|
||||
static inline void btc_ble_mesh_model_cb_to_app(esp_ble_mesh_model_cb_event_t event,
|
||||
@ -2268,8 +2293,8 @@ void btc_ble_mesh_prov_call_handler(btc_msg_t *msg)
|
||||
case BTC_BLE_MESH_ACT_DEINIT_MESH:
|
||||
act = ESP_BLE_MESH_DEINIT_MESH_COMP_EVT;
|
||||
param.deinit_mesh_comp.err_code = bt_mesh_deinit((struct bt_mesh_deinit_param *)&arg->mesh_deinit.param);
|
||||
/* Give the semaphore when BLE Mesh de-initialization is finished. */
|
||||
xSemaphoreGive(arg->mesh_deinit.semaphore);
|
||||
/* Temporarily save the deinit semaphore and release it after the mesh deinit complete event is handled in the app layer */
|
||||
deinit_comp_semaphore = arg->mesh_deinit.semaphore;
|
||||
break;
|
||||
#endif /* CONFIG_BLE_MESH_DEINIT */
|
||||
default:
|
||||
|
Loading…
x
Reference in New Issue
Block a user