Fix descriptors not being deleted (#4104)

This commit is contained in:
J. Nick Koston
2022-11-29 07:49:41 +13:00
committed by GitHub
parent 1166d93805
commit 75573a3ed1
7 changed files with 26 additions and 6 deletions
@@ -76,6 +76,13 @@ void BLEClientBase::disconnect() {
}
}
void BLEClientBase::release_services() {
for (auto &svc : this->services_)
delete svc; // NOLINT(cppcoreguidelines-owning-memory)
this->services_.clear();
esp_ble_gattc_cache_clean(this->remote_bda_);
}
bool BLEClientBase::gattc_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_t esp_gattc_if,
esp_ble_gattc_cb_param_t *param) {
if (event == ESP_GATTC_REG_EVT && this->app_id != param->reg.app_id)
@@ -132,10 +139,7 @@ bool BLEClientBase::gattc_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_
return false;
ESP_LOGV(TAG, "[%d] [%s] ESP_GATTC_DISCONNECT_EVT, reason %d", this->connection_index_,
this->address_str_.c_str(), param->disconnect.reason);
for (auto &svc : this->services_)
delete svc; // NOLINT(cppcoreguidelines-owning-memory)
this->services_.clear();
esp_ble_gattc_cache_clean(this->remote_bda_);
this->release_services();
this->set_state(espbt::ClientState::IDLE);
break;
}