diff options
author | Sven Gothel <[email protected]> | 2020-02-18 03:00:13 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2020-02-18 03:00:13 +0100 |
commit | 1c0ce39b94794e2afa38dfe85c918ff09c5be958 (patch) | |
tree | 8525759bdd636c0855d63e70d5f0b6ce951279d7 /examples | |
parent | 3e453f81505f68f19825adb087db7ef43e4eb25e (diff) |
HCIAdapter::discovery: Fix regression: Double bookkeeping scannedDevices + discoveredDevices; Move le_connect -> HCIDevice; Misc.
Commit 04a7c96c0ec448da8af44a1f342f79b620c7d598, which added discovery criteria caused to lose information
of 'not yet matched' EInfoReport scanned.
Solution is to track all devices (scannedDevices) and hence all pre-matching info,
to only add matched devices (discoveredDevices) if appropriate.
HCIAdapter: Refined some method named, adding 'Discovered'.
Moved le_connect to HCIDevice where it belongs.
Diffstat (limited to 'examples')
-rw-r--r-- | examples/HCIScanner.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/examples/HCIScanner.cpp b/examples/HCIScanner.cpp index 1f3931aa..43adf7d2 100644 --- a/examples/HCIScanner.cpp +++ b/examples/HCIScanner.cpp @@ -90,18 +90,18 @@ int main(int argc, char *argv[]) if( ok && 0 < deviceCount ) { const uint64_t t1 = tinyb_hci::getCurrentMilliseconds(); - std::vector<std::shared_ptr<tinyb_hci::HCIDevice>> discoveredDevices = adapter.getDevices(); + std::vector<std::shared_ptr<tinyb_hci::HCIDevice>> discoveredDevices = adapter.getDiscoveredDevices(); int i=0, j=0, k=0; for(auto it = discoveredDevices.begin(); it != discoveredDevices.end(); it++) { i++; - std::shared_ptr<tinyb_hci::HCIDevice> p = *it; - const uint64_t lup = p->getLastUpdateAge(t1); + std::shared_ptr<tinyb_hci::HCIDevice> device = *it; + const uint64_t lup = device->getLastUpdateAge(t1); if( 2000 > lup ) { // less than 2s old .. j++; - const uint16_t handle = adapter.le_connect(*session, p->getAddress()); + const uint16_t handle = device->le_connect(*session); if( 0 == handle ) { - fprintf(stderr, "Connection: Failed %s\n", p->toString().c_str()); + fprintf(stderr, "Connection: Failed %s\n", device->toString().c_str()); } else { const uint64_t t3 = tinyb_hci::getCurrentMilliseconds(); const uint64_t td0 = t3 - t0; @@ -109,8 +109,8 @@ int main(int argc, char *argv[]) fprintf(stderr, "Connection: Success in connect-only %" PRIu64 " ms, discovered to post-connect %" PRIu64 " ms, total %" PRIu64 " ms, handle 0x%X\n", - td1, (t3 - p->getCreationTimestamp()), td0, handle); - fprintf(stderr, "Connection: Success to %s\n", p->toString().c_str()); + td1, (t3 - device->getCreationTimestamp()), td0, handle); + fprintf(stderr, "Connection: Success to %s\n", device->toString().c_str()); k++; done = true; } |