diff options
author | Sven Gothel <[email protected]> | 2021-01-17 18:56:02 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2021-01-17 18:56:02 +0100 |
commit | 30b4e5f0c1f62c92c40a6ccceda8878f88a9521a (patch) | |
tree | f932f2366a47d847ef4b4813c3a49d685c2351a1 /examples/direct_bt_scanner10 | |
parent | a93f3bd05b075095eebe44ec7784c1664dc68700 (diff) |
AdapterStatusListener::deviceFound: Resolve sharedDevices persistence of found device via return value
While we keep the device instance temporarily alive within discoveredDevices until next removeDiscoveredDevices() eg at startDiscover(),
we only keep it within persistent sharedDevices list if at least one deviceFound implementation returns true.
This allows user to minimize the sharedDevices footprint when rejecting the device
w/o being required to call device.remove().
Diffstat (limited to 'examples/direct_bt_scanner10')
-rw-r--r-- | examples/direct_bt_scanner10/dbt_scanner10.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/examples/direct_bt_scanner10/dbt_scanner10.cpp b/examples/direct_bt_scanner10/dbt_scanner10.cpp index 6e5b0ba0..c640072c 100644 --- a/examples/direct_bt_scanner10/dbt_scanner10.cpp +++ b/examples/direct_bt_scanner10/dbt_scanner10.cpp @@ -281,14 +281,14 @@ class MyAdapterStatusListener : public AdapterStatusListener { (void)timestamp; } - void deviceFound(std::shared_ptr<DBTDevice> device, const uint64_t timestamp) override { + bool deviceFound(std::shared_ptr<DBTDevice> device, const uint64_t timestamp) override { (void)timestamp; if( BDAddressType::BDADDR_LE_PUBLIC != device->getAddressAndType().type && BLERandomAddressType::STATIC_PUBLIC != device->getAddressAndType().getBLERandomAddressType() ) { // Requires BREDR or LE Secure Connection support: WIP fprintf(stderr, "****** FOUND__-2: Skip non 'public LE' and non 'random static public LE' %s\n", device->toString(true).c_str()); - return; + return false; } if( !isDeviceProcessing( device->getAddressAndType() ) && ( waitForDevices.empty() || @@ -305,8 +305,10 @@ class MyAdapterStatusListener : public AdapterStatusListener { } std::thread dc(::connectDiscoveredDevice, device); // @suppress("Invalid arguments") dc.detach(); + return true; } else { fprintf(stderr, "****** FOUND__-1: NOP %s\n", device->toString(true).c_str()); + return false; } } |