diff --git a/components/bt/controller/esp32c2/bt.c b/components/bt/controller/esp32c2/bt.c index 25d1e699ba..ca5ae2256b 100644 --- a/components/bt/controller/esp32c2/bt.c +++ b/components/bt/controller/esp32c2/bt.c @@ -750,6 +750,8 @@ esp_err_t esp_bt_controller_deinit(void) esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode) { + esp_err_t ret = ESP_OK; + if (mode != ESP_BT_MODE_BLE) { ESP_LOGW(NIMBLE_PORT_LOG_TAG, "invalid controller mode"); return ESP_FAIL; @@ -762,10 +764,18 @@ esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode) coex_enable(); #endif if (ble_controller_enable(mode) != 0) { - return ESP_FAIL; + ret = ESP_FAIL; + goto error; } + ble_controller_status = ESP_BT_CONTROLLER_STATUS_ENABLED; return ESP_OK; + +error: +#if CONFIG_SW_COEXIST_ENABLE + coex_disable(); +#endif + return ret; } esp_err_t esp_bt_controller_disable(void) @@ -777,6 +787,9 @@ esp_err_t esp_bt_controller_disable(void) if (ble_controller_disable() != 0) { return ESP_FAIL; } +#if CONFIG_SW_COEXIST_ENABLE + coex_disable(); +#endif ble_controller_status = ESP_BT_CONTROLLER_STATUS_INITED; return ESP_OK; } diff --git a/components/bt/controller/esp32c3/bt.c b/components/bt/controller/esp32c3/bt.c index 1bab7da38c..06acad6b17 100644 --- a/components/bt/controller/esp32c3/bt.c +++ b/components/bt/controller/esp32c3/bt.c @@ -1383,7 +1383,7 @@ static void bt_controller_deinit_internal(void) esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode) { - int ret = ESP_OK; + esp_err_t ret = ESP_OK; if (btdm_controller_status != ESP_BT_CONTROLLER_STATUS_INITED) { return ESP_ERR_INVALID_STATE; @@ -1438,6 +1438,9 @@ error: #endif } while (0); +#if CONFIG_SW_COEXIST_ENABLE + coex_disable(); +#endif return ret; } diff --git a/components/bt/controller/esp32c6/bt.c b/components/bt/controller/esp32c6/bt.c index c659d747d8..23cf720bd6 100644 --- a/components/bt/controller/esp32c6/bt.c +++ b/components/bt/controller/esp32c6/bt.c @@ -729,6 +729,8 @@ esp_err_t esp_bt_controller_deinit(void) esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode) { + esp_err_t ret = ESP_OK; + if (mode != ESP_BT_MODE_BLE) { ESP_LOGW(NIMBLE_PORT_LOG_TAG, "invalid controller mode"); return ESP_FAIL; @@ -743,10 +745,17 @@ esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode) #endif // CONFIG_SW_COEXIST_ENABLE if (ble_controller_enable(mode) != 0) { - return ESP_FAIL; + ret = ESP_FAIL; + goto error; } ble_controller_status = ESP_BT_CONTROLLER_STATUS_ENABLED; return ESP_OK; + +error: +#if CONFIG_SW_COEXIST_ENABLE + coex_disable(); +#endif + return ret; } esp_err_t esp_bt_controller_disable(void) @@ -758,6 +767,9 @@ esp_err_t esp_bt_controller_disable(void) if (ble_controller_disable() != 0) { return ESP_FAIL; } +#if CONFIG_SW_COEXIST_ENABLE + coex_disable(); +#endif ble_controller_status = ESP_BT_CONTROLLER_STATUS_INITED; return ESP_OK; } diff --git a/components/bt/controller/esp32s3/bt.c b/components/bt/controller/esp32s3/bt.c index 9e625dc05b..ab4c187bb6 100644 --- a/components/bt/controller/esp32s3/bt.c +++ b/components/bt/controller/esp32s3/bt.c @@ -1429,7 +1429,7 @@ static void bt_controller_deinit_internal(void) esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode) { - int ret = ESP_OK; + esp_err_t ret = ESP_OK; if (btdm_controller_status != ESP_BT_CONTROLLER_STATUS_INITED) { return ESP_ERR_INVALID_STATE; @@ -1484,6 +1484,9 @@ error: #endif } while (0); +#if CONFIG_SW_COEXIST_ENABLE + coex_disable(); +#endif return ret; }