bluetooth: fix that functions "coex_enable" and "coex_disable" are not used in pairs on ESP32-C3, ESP32-S3, ESP32-C2 and ESP32-C6

This commit is contained in:
wangmengyang 2023-01-04 15:34:05 +08:00
parent 4485bd4245
commit 29610b8a1b
4 changed files with 35 additions and 4 deletions

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}