mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-02 11:10:54 +03:00
fix(openthread): fix the esp_openthread_stop
This commit is contained in:
@@ -312,11 +312,13 @@ esp_err_t esp_openthread_start(const esp_openthread_config_t *config)
|
|||||||
esp_err_t esp_openthread_stop(void)
|
esp_err_t esp_openthread_stop(void)
|
||||||
{
|
{
|
||||||
ESP_RETURN_ON_FALSE(s_ot_syn_semaphore != NULL, ESP_ERR_INVALID_STATE, OT_PLAT_LOG_TAG, "OpenThread is not initialized");
|
ESP_RETURN_ON_FALSE(s_ot_syn_semaphore != NULL, ESP_ERR_INVALID_STATE, OT_PLAT_LOG_TAG, "OpenThread is not initialized");
|
||||||
|
#if (CONFIG_OPENTHREAD_FTD || CONFIG_OPENTHREAD_MTD)
|
||||||
esp_openthread_lock_acquire(portMAX_DELAY);
|
esp_openthread_lock_acquire(portMAX_DELAY);
|
||||||
otInstance *instance = esp_openthread_get_instance();
|
otInstance *instance = esp_openthread_get_instance();
|
||||||
bool is_thread_not_active = (otThreadGetDeviceRole(instance) == OT_DEVICE_ROLE_DISABLED && otIp6IsEnabled(instance) == false);
|
bool is_thread_not_active = (otThreadGetDeviceRole(instance) == OT_DEVICE_ROLE_DISABLED && otIp6IsEnabled(instance) == false);
|
||||||
esp_openthread_lock_release();
|
esp_openthread_lock_release();
|
||||||
ESP_RETURN_ON_FALSE(is_thread_not_active, ESP_ERR_INVALID_STATE, OT_PLAT_LOG_TAG, "Thread interface is still active");
|
ESP_RETURN_ON_FALSE(is_thread_not_active, ESP_ERR_INVALID_STATE, OT_PLAT_LOG_TAG, "Thread interface is still active");
|
||||||
|
#endif
|
||||||
esp_openthread_mainloop_exit();
|
esp_openthread_mainloop_exit();
|
||||||
xSemaphoreTake(s_ot_syn_semaphore, portMAX_DELAY);
|
xSemaphoreTake(s_ot_syn_semaphore, portMAX_DELAY);
|
||||||
vTaskDelete(s_ot_task_handle);
|
vTaskDelete(s_ot_task_handle);
|
||||||
|
|||||||
Reference in New Issue
Block a user