Skip to content

Commit

Permalink
Merge branch 'bugfix/coex_enable_disable_not_in_pairs' into 'master'
Browse files Browse the repository at this point in the history
bluetooth: fix that functions "coex_enable" and "coex_disable" are not used in pairs

Closes BCI-317

See merge request espressif/esp-idf!21895
  • Loading branch information
jack0c committed Jan 18, 2023
2 parents 3636495 + 29610b8 commit 43f5f3d
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 4 deletions.
15 changes: 14 additions & 1 deletion components/bt/controller/esp32c2/bt.c
Expand Up @@ -749,6 +749,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;
Expand All @@ -761,10 +763,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)
Expand All @@ -776,6 +786,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;
}
Expand Down
5 changes: 4 additions & 1 deletion components/bt/controller/esp32c3/bt.c
Expand Up @@ -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;
Expand Down Expand Up @@ -1438,6 +1438,9 @@ esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode)
#endif
} while (0);

#if CONFIG_SW_COEXIST_ENABLE
coex_disable();
#endif
return ret;
}

Expand Down
14 changes: 13 additions & 1 deletion components/bt/controller/esp32c6/bt.c
Expand Up @@ -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;
Expand All @@ -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)
Expand All @@ -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;
}
Expand Down
5 changes: 4 additions & 1 deletion components/bt/controller/esp32s3/bt.c
Expand Up @@ -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;
Expand Down Expand Up @@ -1484,6 +1484,9 @@ esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode)
#endif
} while (0);

#if CONFIG_SW_COEXIST_ENABLE
coex_disable();
#endif
return ret;
}

Expand Down

0 comments on commit 43f5f3d

Please sign in to comment.