From 77274745cbfa4932eeccd5e82e526662ad43ed18 Mon Sep 17 00:00:00 2001 From: William C Bonner Date: Tue, 5 Dec 2023 10:29:21 -0800 Subject: [PATCH] switch to std::random --- CMakeLists.txt | 2 +- goveebttemplogger.cpp | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 86003c5..200339b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,7 +42,7 @@ if (CMAKE_VERSION VERSION_GREATER 3.22) endif() project (GoveeBTTempLogger - VERSION 2.20231201.0 + VERSION 2.20231201.1 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 6142d1d..bc13e78 100644 --- a/goveebttemplogger.cpp +++ b/goveebttemplogger.cpp @@ -76,6 +76,7 @@ #include #include #include +#include #include #include #include @@ -259,9 +260,9 @@ int hci_le_set_ext_scan_enable(int dd, uint8_t enable, uint8_t filter_dup, int t int hci_le_set_random_address(int dd, int to) { le_set_random_address_cp scan_cp{ 0 }; - srand(time(NULL) + getpid()); + std::default_random_engine generator(std::chrono::system_clock::now().time_since_epoch().count()); // 2023-12-01 switch to c++ std library for (auto & b : scan_cp.bdaddr.b) - b = rand() % 256; + b = generator() % 256; uint8_t status; struct hci_request rq; memset(&rq, 0, sizeof(rq));