mirror of
https://github.com/h2zero/esp-nimble-cpp.git
synced 2024-11-24 22:20:55 +01:00
fix(NimBLEDevice): clear all before port_deinit to prevent crash
This commit is contained in:
parent
91210b8610
commit
73f0277042
1 changed files with 31 additions and 31 deletions
|
@ -920,20 +920,6 @@ void NimBLEDevice::init(const std::string &deviceName) {
|
||||||
*/
|
*/
|
||||||
/* STATIC */
|
/* STATIC */
|
||||||
void NimBLEDevice::deinit(bool clearAll) {
|
void NimBLEDevice::deinit(bool clearAll) {
|
||||||
int ret = nimble_port_stop();
|
|
||||||
if (ret == 0) {
|
|
||||||
nimble_port_deinit();
|
|
||||||
#ifdef CONFIG_NIMBLE_CPP_IDF
|
|
||||||
# if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0)
|
|
||||||
ret = esp_nimble_hci_and_controller_deinit();
|
|
||||||
if (ret != ESP_OK) {
|
|
||||||
NIMBLE_LOGE(LOG_TAG, "esp_nimble_hci_and_controller_deinit() failed with error: %d", ret);
|
|
||||||
}
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
initialized = false;
|
|
||||||
m_synced = false;
|
|
||||||
|
|
||||||
if(clearAll) {
|
if(clearAll) {
|
||||||
#if defined(CONFIG_BT_NIMBLE_ROLE_PERIPHERAL)
|
#if defined(CONFIG_BT_NIMBLE_ROLE_PERIPHERAL)
|
||||||
if(NimBLEDevice::m_pServer != nullptr) {
|
if(NimBLEDevice::m_pServer != nullptr) {
|
||||||
|
@ -963,6 +949,20 @@ void NimBLEDevice::deinit(bool clearAll) {
|
||||||
#endif
|
#endif
|
||||||
m_ignoreList.clear();
|
m_ignoreList.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ret = nimble_port_stop();
|
||||||
|
if (ret == 0) {
|
||||||
|
nimble_port_deinit();
|
||||||
|
#ifdef CONFIG_NIMBLE_CPP_IDF
|
||||||
|
# if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0)
|
||||||
|
ret = esp_nimble_hci_and_controller_deinit();
|
||||||
|
if (ret != ESP_OK) {
|
||||||
|
NIMBLE_LOGE(LOG_TAG, "esp_nimble_hci_and_controller_deinit() failed with error: %d", ret);
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
initialized = false;
|
||||||
|
m_synced = false;
|
||||||
}
|
}
|
||||||
} // deinit
|
} // deinit
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue