From e6edf02c4d9f89866c5666ec64beb1d2ee797234 Mon Sep 17 00:00:00 2001 From: William C Bonner Date: Tue, 13 Aug 2024 14:44:23 -0700 Subject: [PATCH] BT_WhiteList working with DBus --- goveebttemplogger.cpp | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/goveebttemplogger.cpp b/goveebttemplogger.cpp index 89b16da..94fe9d7 100644 --- a/goveebttemplogger.cpp +++ b/goveebttemplogger.cpp @@ -3871,25 +3871,29 @@ int main(int argc, char **argv) bluez_dbus_msg_InterfacesAdded(dbus_msg, localBTAddress, localTemp); else if (!dbus_msg_Member.compare("PropertiesChanged")) bluez_dbus_msg_PropertiesChanged(dbus_msg, localBTAddress, localTemp); - if (localTemp.IsValid()) + auto BT_AddressInWhitelist = BT_WhiteList.find(localBTAddress); + if (BT_WhiteList.empty() || (BT_AddressInWhitelist != BT_WhiteList.end())) { - std::ostringstream ConsoleOutLine; - ConsoleOutLine << "[" << getTimeISO8601() << "]"; - char addr[19] = { 0 }; - ba2str(&localBTAddress, addr); - ConsoleOutLine << " [" << addr << "]"; - ConsoleOutLine << " (Temp) " << std::dec << localTemp.GetTemperature() << "\u00B0" << "C"; - ConsoleOutLine << " (Humidity) " << localTemp.GetHumidity() << "%"; - ConsoleOutLine << " (Battery) " << localTemp.GetBattery() << "%"; - ConsoleOutLine << " " << localTemp.GetModelAsString(); - ConsoleOutLine << std::endl; - std::queue foo; - auto ret = GoveeTemperatures.insert(std::pair>(localBTAddress, foo)); - ret.first->second.push(localTemp); // puts the measurement in the queue to be written to the log file - UpdateMRTGData(localBTAddress, localTemp); // puts the measurement in the fake MRTG data structure - GoveeLastDownload.insert(std::pair(localBTAddress, 0)); // Makes sure the Bluetooth Address is in the list to get downloaded historical data - if (ConsoleVerbosity > 0) - std::cout << ConsoleOutLine.str(); + if (localTemp.IsValid()) + { + std::ostringstream ConsoleOutLine; + ConsoleOutLine << "[" << getTimeISO8601() << "]"; + char addr[19] = { 0 }; + ba2str(&localBTAddress, addr); + ConsoleOutLine << " [" << addr << "]"; + ConsoleOutLine << " (Temp) " << std::dec << localTemp.GetTemperature() << "\u00B0" << "C"; + ConsoleOutLine << " (Humidity) " << localTemp.GetHumidity() << "%"; + ConsoleOutLine << " (Battery) " << localTemp.GetBattery() << "%"; + ConsoleOutLine << " " << localTemp.GetModelAsString(); + ConsoleOutLine << std::endl; + std::queue foo; + auto ret = GoveeTemperatures.insert(std::pair>(localBTAddress, foo)); + ret.first->second.push(localTemp); // puts the measurement in the queue to be written to the log file + UpdateMRTGData(localBTAddress, localTemp); // puts the measurement in the fake MRTG data structure + GoveeLastDownload.insert(std::pair(localBTAddress, 0)); // Makes sure the Bluetooth Address is in the list to get downloaded historical data + if (ConsoleVerbosity > 0) + std::cout << ConsoleOutLine.str(); + } } } dbus_message_unref(dbus_msg); // Free the message