Skip to content

Commit

Permalink
Merge branch 'bugfix/wifi_prov_deinit_github_v5.1' into 'release/v5.1'
Browse files Browse the repository at this point in the history
wifi_prov_mgr: Fixed memory leak after bluetooth stack was stopping. (v5.1)

See merge request espressif/esp-idf!23436
  • Loading branch information
wmy-espressif committed Apr 27, 2023
2 parents 8719a45 + f6e0867 commit 5bba395
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
10 changes: 10 additions & 0 deletions components/protocomm/src/transports/protocomm_ble.c
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,15 @@ static void transport_simple_ble_connect(esp_gatts_cb_event_t event, esp_gatt_if
{
esp_err_t ret;
ESP_LOGD(TAG, "Inside BLE connect w/ conn_id - %d", param->connect.conn_id);

#ifdef CONFIG_WIFI_PROV_KEEP_BLE_ON_AFTER_PROV
/* Ignore BLE events received after protocomm layer is stopped */
if (protoble_internal == NULL) {
ESP_LOGI(TAG,"Protocomm layer has already stopped");
return;
}
#endif

if (protoble_internal->pc_ble->sec &&
protoble_internal->pc_ble->sec->new_transport_session) {
ret = protoble_internal->pc_ble->sec->new_transport_session(protoble_internal->pc_ble->sec_inst,
Expand Down Expand Up @@ -610,6 +619,7 @@ esp_err_t protocomm_ble_stop(protocomm_t *pc)
if (ret) {
ESP_LOGE(TAG, "BLE stop failed");
}
simple_ble_deinit();
#else
#ifdef CONFIG_WIFI_PROV_DISCONNECT_AFTER_PROV
/* Keep BT stack on, but terminate the connection after provisioning */
Expand Down
10 changes: 10 additions & 0 deletions components/protocomm/src/transports/protocomm_nimble.c
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,15 @@ static void transport_simple_ble_connect(struct ble_gap_event *event, void *arg)
{
esp_err_t ret;
ESP_LOGD(TAG, "Inside BLE connect w/ conn_id - %d", event->connect.conn_handle);

#ifdef CONFIG_WIFI_PROV_KEEP_BLE_ON_AFTER_PROV
/* Ignore BLE events received after protocomm layer is stopped */
if (protoble_internal == NULL) {
ESP_LOGI(TAG,"Protocomm layer has already stopped");
return;
}
#endif

if (protoble_internal->pc_ble->sec &&
protoble_internal->pc_ble->sec->new_transport_session) {
ret =
Expand Down Expand Up @@ -990,6 +999,7 @@ esp_err_t protocomm_ble_stop(protocomm_t *pc)
if (ret == 0) {
nimble_port_deinit();
}
free_gatt_ble_misc_memory(ble_cfg_p);
#else
#ifdef CONFIG_WIFI_PROV_DISCONNECT_AFTER_PROV
/* Keep BT stack on, but terminate the connection after provisioning */
Expand Down

0 comments on commit 5bba395

Please sign in to comment.