1
0
mirror of https://github.com/esphome/esphome.git synced 2025-03-15 15:18:16 +00:00

Debug disconnecting before connected

This commit is contained in:
J. Nick Koston 2025-02-21 18:30:29 -06:00
parent 5c9c8a11f6
commit f11f7af957
No known key found for this signature in database

View File

@ -130,10 +130,10 @@ void BLEClientBase::disconnect() {
this->set_state(espbt::ClientState::DISCONNECTING); this->set_state(espbt::ClientState::DISCONNECTING);
return; return;
} }
this->unconditional_disconnect(); this->_unconditional_disconnect();
} }
void BLEClientBase::unconditional_disconnect() { void BLEClientBase::_unconditional_disconnect() {
// Disconnect without checking the state. // Disconnect without checking the state.
ESP_LOGI(TAG, "[%d] [%s] Disconnecting.", this->connection_index_, this->address_str_.c_str()); ESP_LOGI(TAG, "[%d] [%s] Disconnecting.", this->connection_index_, this->address_str_.c_str());
auto err = esp_ble_gattc_close(this->gattc_if_, this->conn_id_); auto err = esp_ble_gattc_close(this->gattc_if_, this->conn_id_);
@ -203,7 +203,7 @@ bool BLEClientBase::gattc_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_
if (this->state == espbt::ClientState::DISCONNECTING) { if (this->state == espbt::ClientState::DISCONNECTING) {
// Disconnect we requested before after connecting started, // Disconnect we requested before after connecting started,
// but before the connection was established. // but before the connection was established.
this->unconditional_disconnect(); this->_unconditional_disconnect();
break; break;
} }
auto ret = esp_ble_gattc_send_mtu_req(this->gattc_if_, param->open.conn_id); auto ret = esp_ble_gattc_send_mtu_req(this->gattc_if_, param->open.conn_id);
@ -228,8 +228,7 @@ bool BLEClientBase::gattc_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_
if (this->state == espbt::ClientState::DISCONNECTING) { if (this->state == espbt::ClientState::DISCONNECTING) {
// Disconnect we requested before after connecting started, // Disconnect we requested before after connecting started,
// but before the connection was established. // but before the connection was established.
this->unconditional_disconnect(); this->_unconditional_disconnect();
break;
} }
break; break;
} }