diff options
author | Sven Gothel <[email protected]> | 2020-10-13 02:56:28 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2020-10-13 02:56:28 +0200 |
commit | e710b13bac1723ea8d5d4bae9e6a361cc7eadc3e (patch) | |
tree | 1952cd7293219aacca76aaf962955d1e7239b548 /examples | |
parent | fb9d0436163d8251fc3620b2c8bf6779afe27e39 (diff) |
DBTAdapter::reset(): Utilize HCI host implementation specific reset procedure incl bring-up back into POWERED functional state
Notable: DBTAdapter::poweredOff() shall not close the HCI connection,
as the unique host HCI channel will survive.
Diffstat (limited to 'examples')
-rw-r--r-- | examples/direct_bt_scanner10/dbt_scanner10.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/examples/direct_bt_scanner10/dbt_scanner10.cpp b/examples/direct_bt_scanner10/dbt_scanner10.cpp index 2ec21995..a8a60646 100644 --- a/examples/direct_bt_scanner10/dbt_scanner10.cpp +++ b/examples/direct_bt_scanner10/dbt_scanner10.cpp @@ -225,7 +225,8 @@ class MyAdapterStatusListener : public AdapterStatusListener { ) ) { - fprintf(stderr, "****** CONNECTED-0: Processing %s\n", device->toString(true).c_str()); + connectionCount++; + fprintf(stderr, "****** CONNECTED-0: Processing[%d] %s\n", connectionCount.load(), device->toString(true).c_str()); { const uint64_t td = getCurrentMilliseconds() - timestamp_t0; // adapter-init -> now fprintf(stderr, "PERF: adapter-init -> CONNECTED-0 %" PRIu64 " ms\n", td); @@ -249,9 +250,8 @@ class MyAdapterStatusListener : public AdapterStatusListener { } else { removeFromDevicesProcessing(device->getAddress()); } - connectionCount++; - if( 0 == connectionCount % RESET_ADAPTER_EACH_CONN ) { - std::thread dc(::resetAdapter, &device->getAdapter()); // @suppress("Invalid arguments") + if( 0 < RESET_ADAPTER_EACH_CONN && 0 == connectionCount % RESET_ADAPTER_EACH_CONN ) { + std::thread dc(::resetAdapter, &device->getAdapter(), 1); // @suppress("Invalid arguments") dc.detach(); } } @@ -468,6 +468,9 @@ exit: removeFromDevicesProcessing(device->getAddress()); device->remove(); + if( 0 < RESET_ADAPTER_EACH_CONN && 0 == connectionCount % RESET_ADAPTER_EACH_CONN ) { + resetAdapter(&device->getAdapter(), 2); + } if( !USE_WHITELIST && 0 == getDeviceProcessingCount() ) { const HCIStatusCode r = device->getAdapter().startDiscovery( true ); fprintf(stderr, "****** Processing Device: startDiscovery.1 result %s\n", getHCIStatusCodeString(r).c_str()); |