Remove CONNECTED state from BLE

It looks like this is no longer used as we always set the state
to ESTABLISHED

Noticed while investigating https://github.com/esphome/issues/issues/5119
This commit is contained in:
J. Nick Koston 2023-11-20 14:47:15 +01:00
parent d462beea6e
commit 4b0bf70add
No known key found for this signature in database
3 changed files with 3 additions and 8 deletions

View file

@ -240,8 +240,7 @@ void BluetoothProxy::bluetooth_device_request(const api::BluetoothDeviceRequest
this->send_device_connection(msg.address, false); this->send_device_connection(msg.address, false);
return; return;
} }
if (connection->state() == espbt::ClientState::CONNECTED || if (connection->state() == espbt::ClientState::ESTABLISHED) {
connection->state() == espbt::ClientState::ESTABLISHED) {
ESP_LOGW(TAG, "[%d] [%s] Connection already established", connection->get_connection_index(), ESP_LOGW(TAG, "[%d] [%s] Connection already established", connection->get_connection_index(),
connection->address_str().c_str()); connection->address_str().c_str());
this->send_device_connection(msg.address, true); this->send_device_connection(msg.address, true);

View file

@ -147,8 +147,7 @@ bool BLEClientBase::gattc_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_
} }
if (this->connection_type_ == espbt::ConnectionType::V3_WITH_CACHE) { if (this->connection_type_ == espbt::ConnectionType::V3_WITH_CACHE) {
ESP_LOGI(TAG, "[%d] [%s] Connected", this->connection_index_, this->address_str_.c_str()); ESP_LOGI(TAG, "[%d] [%s] Connected", this->connection_index_, this->address_str_.c_str());
this->set_state(espbt::ClientState::CONNECTED); this->set_state(espbt::ClientState::ESTABLISHED);
this->state_ = espbt::ClientState::ESTABLISHED;
break; break;
} }
esp_ble_gattc_search_service(esp_gattc_if, param->cfg_mtu.conn_id, nullptr); esp_ble_gattc_search_service(esp_gattc_if, param->cfg_mtu.conn_id, nullptr);
@ -199,8 +198,7 @@ bool BLEClientBase::gattc_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_
this->address_str_.c_str(), svc->start_handle, svc->end_handle); this->address_str_.c_str(), svc->start_handle, svc->end_handle);
} }
ESP_LOGI(TAG, "[%d] [%s] Connected", this->connection_index_, this->address_str_.c_str()); ESP_LOGI(TAG, "[%d] [%s] Connected", this->connection_index_, this->address_str_.c_str());
this->set_state(espbt::ClientState::CONNECTED); this->set_state(espbt::ClientState::ESTABLISHED);
this->state_ = espbt::ClientState::ESTABLISHED;
break; break;
} }
case ESP_GATTC_REG_FOR_NOTIFY_EVT: { case ESP_GATTC_REG_FOR_NOTIFY_EVT: {

View file

@ -145,8 +145,6 @@ enum class ClientState {
READY_TO_CONNECT, READY_TO_CONNECT,
// Connection in progress. // Connection in progress.
CONNECTING, CONNECTING,
// Initial connection established.
CONNECTED,
// The client and sub-clients have completed setup. // The client and sub-clients have completed setup.
ESTABLISHED, ESTABLISHED,
}; };