From e96d7483b3acec403cb1cec25ae0ff8b8656d282 Mon Sep 17 00:00:00 2001 From: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Date: Tue, 25 Oct 2022 12:54:10 +1300 Subject: [PATCH] Update bluetooth proxy limit as soon as connection requested (#3935) --- esphome/components/bluetooth_proxy/bluetooth_proxy.cpp | 3 +++ esphome/components/esp32_ble_tracker/esp32_ble_tracker.h | 2 ++ 2 files changed, 5 insertions(+) diff --git a/esphome/components/bluetooth_proxy/bluetooth_proxy.cpp b/esphome/components/bluetooth_proxy/bluetooth_proxy.cpp index cc1c178b08..5dfdc06070 100644 --- a/esphome/components/bluetooth_proxy/bluetooth_proxy.cpp +++ b/esphome/components/bluetooth_proxy/bluetooth_proxy.cpp @@ -209,6 +209,9 @@ void BluetoothProxy::bluetooth_device_request(const api::BluetoothDeviceRequest switch (msg.request_type) { case api::enums::BLUETOOTH_DEVICE_REQUEST_TYPE_CONNECT: { this->address_ = msg.address; + this->set_state(espbt::ClientState::SEARCHING); + api::global_api_server->send_bluetooth_connections_free(this->get_bluetooth_connections_free(), + this->get_bluetooth_connections_limit()); break; } case api::enums::BLUETOOTH_DEVICE_REQUEST_TYPE_DISCONNECT: { diff --git a/esphome/components/esp32_ble_tracker/esp32_ble_tracker.h b/esphome/components/esp32_ble_tracker/esp32_ble_tracker.h index 45abcd63fa..dd08f07fd7 100644 --- a/esphome/components/esp32_ble_tracker/esp32_ble_tracker.h +++ b/esphome/components/esp32_ble_tracker/esp32_ble_tracker.h @@ -145,6 +145,8 @@ class ESPBTDeviceListener { enum class ClientState { // Connection is idle, no device detected. IDLE, + // Searching for device. + SEARCHING, // Device advertisement found. DISCOVERED, // Connection in progress.