From 6883ab8b713c0c49da69e22c230480333a627466 Mon Sep 17 00:00:00 2001 From: William C Bonner Date: Mon, 15 Jul 2024 20:39:48 -0700 Subject: [PATCH] List Available Bluetooth Controllers --- CMakeLists.txt | 2 +- goveebttemplogger.cpp | 25 +++++++++++++++++++++++-- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 91d03ff..b493a6d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,7 +21,7 @@ if (POLICY CMP0115) endif() project (GoveeBTTempLogger - VERSION 2.20240710.0 + VERSION 2.20240715.0 DESCRIPTION "Listen and log Govee Thermometer Bluetooth Low Energy Advertisments" HOMEPAGE_URL https://github.com/wcbonner/GoveeBTTempLogger ) diff --git a/goveebttemplogger.cpp b/goveebttemplogger.cpp index 99e565f..ab2ab44 100644 --- a/goveebttemplogger.cpp +++ b/goveebttemplogger.cpp @@ -2320,6 +2320,26 @@ int bt_LEScan(int BlueToothDevice_Handle, const bool enable, const std::set 0) + std::cout << "[ ] Host Controller Address: " << ba2string(hci_devs[i].bdaddr) << " BlueTooth Device ID: " << hci_devs[i].dev_id << " HCI Name: " << hci_devs[i].name << std::endl; + else + std::cerr << "Host Controller Address: " << ba2string(hci_devs[i].bdaddr) << " BlueTooth Device ID: " << hci_devs[i].dev_id << " HCI Name: " << hci_devs[i].name << std::endl; +} +///////////////////////////////////////////////////////////////////////////// // Connect to a Govee Thermometer device over Bluetooth and download its historical data. time_t ConnectAndDownload(int BlueToothDevice_Handle, const bdaddr_t GoveeBTAddress, const time_t GoveeLastReadTime = 0, const int BatteryToRecord = 0) { @@ -3138,6 +3158,7 @@ int main(int argc, char **argv) } } /////////////////////////////////////////////////////////////////////////////////////////////// + bt_ListDevices(); int BlueToothDevice_ID; if (ControllerAddress.empty()) BlueToothDevice_ID = hci_get_route(NULL); @@ -3231,7 +3252,7 @@ int main(int argc, char **argv) if (ConsoleVerbosity > 0) { if (!ControllerAddress.empty()) - std::cout << "[" << getTimeISO8601() << "] Controller Address: " << ControllerAddress << std::endl; + std::cout << "[" << getTimeISO8601() << "] Using Controller Address: " << ControllerAddress << std::endl; std::cout << "[" << getTimeISO8601() << "] LocalName: " << LocalName << std::endl; if (BT_WhiteList.empty()) std::cout << "[" << getTimeISO8601() << "] No BlueTooth Address Filter" << std::endl; @@ -3245,7 +3266,7 @@ int main(int argc, char **argv) } else if (!ControllerAddress.empty()) - std::cerr << "Controller Address: " << ControllerAddress << std::endl; + std::cerr << "Using Controller Address: " << ControllerAddress << std::endl; auto btRVal = bt_LEScan(BlueToothDevice_Handle, true, BT_WhiteList); if (btRVal < 0)