Skip to content

Commit

Permalink
fix(network_prov): Reduce restrictions for the scheme_ble source incl…
Browse files Browse the repository at this point in the history
…uding
  • Loading branch information
wqx6 committed Sep 6, 2024
1 parent ce7246d commit 361a0f1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
2 changes: 1 addition & 1 deletion network_provisioning/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ if(CONFIG_ESP_WIFI_ENABLED AND CONFIG_ESP_WIFI_SOFTAP_SUPPORT)
list(APPEND srcs "src/scheme_softap.c")
endif()

if(CONFIG_SOC_BT_SUPPORTED AND CONFIG_BT_ENABLED)
if(CONFIG_BT_ENABLED)
if(CONFIG_BT_BLUEDROID_ENABLED OR CONFIG_BT_NIMBLE_ENABLED)
list(APPEND srcs
"src/scheme_ble.c")
Expand Down
18 changes: 8 additions & 10 deletions network_provisioning/src/scheme_ble.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,45 +199,43 @@ static esp_err_t set_config_endpoint(void *config, const char *endpoint_name, ui
/* Used when both BT and BLE are not needed by application */
void network_prov_scheme_ble_event_cb_free_btdm(void *user_data, network_prov_cb_event_t event, void *event_data)
{
#ifdef CONFIG_BT_CONTROLLER_ENABLED
esp_err_t err;
switch (event) {
case NETWORK_PROV_INIT:
#ifdef CONFIG_BT_CONTROLLER_ENABLED
/* Release BT memory, as we need only BLE */
err = esp_bt_mem_release(ESP_BT_MODE_CLASSIC_BT);
if (err != ESP_OK) {
ESP_LOGE(TAG, "bt_mem_release of classic BT failed %d", err);
} else {
ESP_LOGI(TAG, "BT memory released");
}
#endif
break;

case NETWORK_PROV_DEINIT:
#ifndef CONFIG_NETWORK_PROV_KEEP_BLE_ON_AFTER_PROV
#ifdef CONFIG_BT_CONTROLLER_ENABLED
/* Release memory used by BLE and Bluedroid host stack */
err = esp_bt_mem_release(ESP_BT_MODE_BTDM);
if (err != ESP_OK) {
ESP_LOGE(TAG, "bt_mem_release of BTDM failed %d", err);
} else {
ESP_LOGI(TAG, "BTDM memory released");
}
#endif
#endif
#endif /* !CONFIG_NETWORK_PROV_KEEP_BLE_ON_AFTER_PROV */
break;

default:
break;
}
#endif /* CONFIG_BT_CONTROLLER_ENABLED */
}

/* Used when BT is not needed by application */
void network_prov_scheme_ble_event_cb_free_bt(void *user_data, network_prov_cb_event_t event, void *event_data)
{
#ifdef CONFIG_BT_CONTROLLER_ENABLED
esp_err_t err;
switch (event) {
#ifdef CONFIG_BT_CONTROLLER_ENABLED
case NETWORK_PROV_INIT:
/* Release BT memory, as we need only BLE */
err = esp_bt_mem_release(ESP_BT_MODE_CLASSIC_BT);
Expand All @@ -246,36 +244,36 @@ void network_prov_scheme_ble_event_cb_free_bt(void *user_data, network_prov_cb_e
} else {
ESP_LOGI(TAG, "BT memory released");
}
#endif
break;

default:
break;
}
#endif /* CONFIG_BT_CONTROLLER_ENABLED */
}

/* Used when BLE is not needed by application */
void network_prov_scheme_ble_event_cb_free_ble(void *user_data, network_prov_cb_event_t event, void *event_data)
{
#ifdef CONFIG_BT_CONTROLLER_ENABLED
esp_err_t err;
switch (event) {
case NETWORK_PROV_DEINIT:
#ifndef CONFIG_NETWORK_PROV_KEEP_BLE_ON_AFTER_PROV
#ifdef CONFIG_BT_CONTROLLER_ENABLED
/* Release memory used by BLE stack */
err = esp_bt_mem_release(ESP_BT_MODE_BLE);
if (err != ESP_OK) {
ESP_LOGE(TAG, "bt_mem_release of BLE failed %d", err);
} else {
ESP_LOGI(TAG, "BLE memory released");
}
#endif
#endif
#endif /* !CONFIG_NETWORK_PROV_KEEP_BLE_ON_AFTER_PROV */
break;

default:
break;
}
#endif /* CONFIG_BT_CONTROLLER_ENABLED */
}

const network_prov_scheme_t network_prov_scheme_ble = {
Expand Down

0 comments on commit 361a0f1

Please sign in to comment.