Skip to content

Commit

Permalink
[ESP32] Fixed crash on commissioning into a second fabric (#17170)
Browse files Browse the repository at this point in the history
* [ESP32] Fixed crash on commissioning into a second fabric

* Removed comment
  • Loading branch information
jadhavrohit924 authored and pull[bot] committed Aug 29, 2023
1 parent a4333ec commit 1024119
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 16 deletions.
24 changes: 16 additions & 8 deletions examples/all-clusters-app/esp32/main/DeviceCallbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,20 +120,28 @@ void DeviceCallbacks::DeviceEventCallback(const ChipDeviceEvent * event, intptr_
case DeviceEventType::kCommissioningComplete: {
ESP_LOGI(TAG, "Commissioning complete");
#if CONFIG_BT_NIMBLE_ENABLED && CONFIG_DEINIT_BLE_ON_COMMISSIONING_COMPLETE
int ret = nimble_port_stop();
if (ret == 0)

if (ble_hs_is_enabled())
{
nimble_port_deinit();
esp_err_t err = esp_nimble_hci_and_controller_deinit();
err += esp_bt_mem_release(ESP_BT_MODE_BLE);
if (err == ESP_OK)
int ret = nimble_port_stop();
if (ret == 0)
{
nimble_port_deinit();
esp_err_t err = esp_nimble_hci_and_controller_deinit();
err += esp_bt_mem_release(ESP_BT_MODE_BLE);
if (err == ESP_OK)
{
ESP_LOGI(TAG, "BLE deinit successful and memory reclaimed");
}
}
else
{
ESP_LOGI(TAG, "BLE deinit successful and memory reclaimed");
ESP_LOGW(TAG, "nimble_port_stop() failed");
}
}
else
{
ESP_LOGW(TAG, "nimble_port_stop() failed");
ESP_LOGI(TAG, "BLE already deinited");
}
#endif
}
Expand Down
24 changes: 16 additions & 8 deletions examples/lighting-app/esp32/main/DeviceCallbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,20 +72,28 @@ void DeviceCallbacks::DeviceEventCallback(const ChipDeviceEvent * event, intptr_
case DeviceEventType::kCommissioningComplete: {
ESP_LOGI(TAG, "Commissioning complete");
#if CONFIG_BT_NIMBLE_ENABLED && CONFIG_DEINIT_BLE_ON_COMMISSIONING_COMPLETE
int ret = nimble_port_stop();
if (ret == 0)

if (ble_hs_is_enabled())
{
nimble_port_deinit();
esp_err_t err = esp_nimble_hci_and_controller_deinit();
err += esp_bt_mem_release(ESP_BT_MODE_BLE);
if (err == ESP_OK)
int ret = nimble_port_stop();
if (ret == 0)
{
nimble_port_deinit();
esp_err_t err = esp_nimble_hci_and_controller_deinit();
err += esp_bt_mem_release(ESP_BT_MODE_BLE);
if (err == ESP_OK)
{
ESP_LOGI(TAG, "BLE deinit successful and memory reclaimed");
}
}
else
{
ESP_LOGI(TAG, "BLE deinit successful and memory reclaimed");
ESP_LOGW(TAG, "nimble_port_stop() failed");
}
}
else
{
ESP_LOGW(TAG, "nimble_port_stop() failed");
ESP_LOGI(TAG, "BLE already deinited");
}
#endif
}
Expand Down

0 comments on commit 1024119

Please sign in to comment.