diff --git a/esphome/components/bluetooth_proxy/bluetooth_proxy.cpp b/esphome/components/bluetooth_proxy/bluetooth_proxy.cpp index 834901fbdc..eead2a8aea 100644 --- a/esphome/components/bluetooth_proxy/bluetooth_proxy.cpp +++ b/esphome/components/bluetooth_proxy/bluetooth_proxy.cpp @@ -52,6 +52,20 @@ void BluetoothProxy::dump_config() { ESP_LOGCONFIG(TAG, " Active: %s", YESNO(this->active_)); } +int BluetoothProxy::get_bluetooth_connections_free() { + int free = 0; + for (auto *connection : this->connections_) { + if (connection->address_ == 0) { + free++; + ESP_LOGV(TAG, "[%d] Free connection", connection->get_connection_index()); + } else { + ESP_LOGV(TAG, "[%d] Used connection by [%s]", connection->get_connection_index(), + connection->address_str().c_str()); + } + } + return free; +} + void BluetoothProxy::loop() { if (!api::global_api_server->is_connected()) { for (auto *connection : this->connections_) { diff --git a/esphome/components/bluetooth_proxy/bluetooth_proxy.h b/esphome/components/bluetooth_proxy/bluetooth_proxy.h index b33e084b70..b1353b13da 100644 --- a/esphome/components/bluetooth_proxy/bluetooth_proxy.h +++ b/esphome/components/bluetooth_proxy/bluetooth_proxy.h @@ -41,15 +41,7 @@ class BluetoothProxy : public esp32_ble_tracker::ESPBTDeviceListener, public Com void bluetooth_gatt_send_services(const api::BluetoothGATTGetServicesRequest &msg); void bluetooth_gatt_notify(const api::BluetoothGATTNotifyRequest &msg); - int get_bluetooth_connections_free() { - int free = 0; - for (auto *connection : this->connections_) { - if (connection->address_ == 0) { - free++; - } - } - return free; - } + int get_bluetooth_connections_free(); int get_bluetooth_connections_limit() { return this->connections_.size(); } void set_active(bool active) { this->active_ = active; }