diff options
author | Sven Gothel <[email protected]> | 2020-02-16 01:08:35 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2020-02-16 01:08:35 +0100 |
commit | b957a7f332b78fb3631e118332a6a26ab03f75ed (patch) | |
tree | 9fdbdd294d9d56144b849328bafed911cc550ffa /examples | |
parent | cdaf51206a95494d8de43fd5461313efff6badd7 (diff) |
Cleanup discovery: Use new EInfoReport(for AD + EIR), add timestamp (creation + update), add ManufactureSpecificData and tx_power
Further, let the user be notified via listener for discovered devices (added or updated).
Diffstat (limited to 'examples')
-rw-r--r-- | examples/HCIScanner.cpp | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/examples/HCIScanner.cpp b/examples/HCIScanner.cpp index 47c57afe..31e192a3 100644 --- a/examples/HCIScanner.cpp +++ b/examples/HCIScanner.cpp @@ -25,6 +25,19 @@ #include <tinyb_hci/HCITypes.hpp> +class DeviceDiscoveryListener : public tinyb_hci::HCIDeviceDiscoveryListener { + void deviceAdded(tinyb_hci::HCIAdapter const &a, std::shared_ptr<tinyb_hci::HCIDevice> device) { + fprintf(stderr, "****** ADDED__: %s\n", device->toString().c_str()); + fprintf(stderr, "Status HCIAdapter:\n"); + fprintf(stderr, "%s\n", a.toString().c_str()); + } + void deviceUpdated(tinyb_hci::HCIAdapter const &a, std::shared_ptr<tinyb_hci::HCIDevice> device) { + fprintf(stderr, "****** UPDATED: %s\n", device->toString().c_str()); + fprintf(stderr, "Status HCIAdapter:\n"); + fprintf(stderr, "%s\n", a.toString().c_str()); + } +}; + int main(int argc, char *argv[]) { int err = 0; @@ -41,6 +54,8 @@ int main(int argc, char *argv[]) fprintf(stderr, "Adapter: device %s, address %s\n", adapter.getName().c_str(), adapter.getAddress().c_str()); + adapter.setDeviceDiscoveryListener(std::shared_ptr<tinyb_hci::HCIDeviceDiscoveryListener>(new DeviceDiscoveryListener())); + while( !err ) { std::shared_ptr<tinyb_hci::HCISession> session = adapter.startDiscovery(); if( nullptr == session ) { @@ -48,17 +63,11 @@ int main(int argc, char *argv[]) exit(1); } - // do something if( !adapter.discoverDevices(*session, 1000) ) { fprintf(stderr, "Adapter discovery failed.\n"); err = 1; } - fprintf(stderr, "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n"); - fprintf(stderr, "Discovery Results HCIAdapter:\n"); - fprintf(stderr, "%s\n", adapter.toString().c_str()); - fprintf(stderr, "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n"); - if( !adapter.stopDiscovery(*session) ) { fprintf(stderr, "Adapter stop discovery failed.\n"); err = 1; |