diff options
author | Sven Gothel <[email protected]> | 2020-06-28 04:07:06 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2020-06-28 04:07:06 +0200 |
commit | e456a087c2e877df949f2dbd7fa95c25fe80a4ee (patch) | |
tree | df762f02cb4b96013ff8a5c8e6ca33437454b5ea | |
parent | 2119425671fbca7a7bd7ce6e5abdaa128ea4e9b6 (diff) |
ScannerTinyB10: Allow waiting for multiple devices.
-rw-r--r-- | examples/direct_bt_scanner10/dbt_scanner10.cpp | 2 | ||||
-rw-r--r-- | examples/java/ScannerTinyB10.java | 26 |
2 files changed, 14 insertions, 14 deletions
diff --git a/examples/direct_bt_scanner10/dbt_scanner10.cpp b/examples/direct_bt_scanner10/dbt_scanner10.cpp index 4c8c6864..2e11ffba 100644 --- a/examples/direct_bt_scanner10/dbt_scanner10.cpp +++ b/examples/direct_bt_scanner10/dbt_scanner10.cpp @@ -330,7 +330,7 @@ exit: device->remove(); removeFromDevicesProcessing(device->getAddress()); - fprintf(stderr, "****** Processing Device: End: Success %d on %s; devInProc %d\n", + fprintf(stderr, "****** Processing Device: End: Success %d on %s; devInProc %zd\n", success, device->toString().c_str(), devicesInProcessing.size()); if( !USE_WHITELIST && 0 == devicesInProcessing.size() ) { device->getAdapter().startDiscovery( true ); diff --git a/examples/java/ScannerTinyB10.java b/examples/java/ScannerTinyB10.java index 5c8b89e9..d93eacfb 100644 --- a/examples/java/ScannerTinyB10.java +++ b/examples/java/ScannerTinyB10.java @@ -56,7 +56,7 @@ public class ScannerTinyB10 { static final String EUI48_ANY_DEVICE = "00:00:00:00:00:00"; - String waitForDevice = EUI48_ANY_DEVICE; + final List<String> waitForDevices = new ArrayList<String>(); long timestamp_t0; @@ -98,9 +98,9 @@ public class ScannerTinyB10 { return; } if( !devicesInProcessing.contains( device.getAddress() ) && - ( waitForDevice.equals(EUI48_ANY_DEVICE) || - ( waitForDevice.equals(device.getAddress()) && - ( MULTI_MEASUREMENTS || !devicesProcessed.contains(waitForDevice) ) + ( waitForDevices.isEmpty() || + ( waitForDevices.contains(device.getAddress()) && + ( MULTI_MEASUREMENTS || !devicesProcessed.containsAll(waitForDevices) ) ) ) ) @@ -133,9 +133,9 @@ public class ScannerTinyB10 { @Override public void deviceConnected(final BluetoothDevice device, final long timestamp) { if( !devicesInProcessing.contains( device.getAddress() ) && - ( waitForDevice.equals(EUI48_ANY_DEVICE) || - ( waitForDevice.equals(device.getAddress()) && - ( MULTI_MEASUREMENTS || !devicesProcessed.contains(waitForDevice) ) + ( waitForDevices.isEmpty() || + ( waitForDevices.contains(device.getAddress()) && + ( MULTI_MEASUREMENTS || !devicesProcessed.containsAll(waitForDevices) ) ) ) ) @@ -345,11 +345,11 @@ public class ScannerTinyB10 { } while( !done ) { - if( !waitForDevice.equals(EUI48_ANY_DEVICE) && - !MULTI_MEASUREMENTS && devicesProcessed.contains(waitForDevice) + if( !waitForDevices.isEmpty() && + !MULTI_MEASUREMENTS && devicesProcessed.containsAll(waitForDevices) ) { - System.err.println("****** WaitForDevice processed "+waitForDevice); + System.err.println("****** WaitForDevice processed "+Arrays.toString(waitForDevices.toArray())); done = true; } try { @@ -379,7 +379,7 @@ public class ScannerTinyB10 { } else if( arg.equals("-dev_id") && args.length > (i+1) ) { test.dev_id = Integer.valueOf(args[++i]).intValue(); } else if( arg.equals("-mac") && args.length > (i+1) ) { - test.waitForDevice = args[++i]; + test.waitForDevices.add(args[++i]); } else if( arg.equals("-wl") && args.length > (i+1) ) { final String addr = args[++i]; System.err.println("Whitelist + "+addr); @@ -394,14 +394,14 @@ public class ScannerTinyB10 { } } - System.err.println("Run with '[-dev_id <adapter-index>] [-mac <device_address>] [-disconnect] [-single] (-wl <device_address>)* [-show_update_events] [-factory <BluetoothManager-Factory-Implementation-Class>]'"); + System.err.println("Run with '[-dev_id <adapter-index>] (-mac <device_address>)* [-disconnect] [-single] (-wl <device_address>)* [-show_update_events] [-factory <BluetoothManager-Factory-Implementation-Class>]'"); } System.err.println("MULTI_MEASUREMENTS "+test.MULTI_MEASUREMENTS); System.err.println("KEEP_CONNECTED "+test.KEEP_CONNECTED); System.err.println("USE_WHITELIST "+test.USE_WHITELIST); System.err.println("dev_id "+test.dev_id); - System.err.println("waitForDevice: "+test.waitForDevice); + System.err.println("waitForDevice: "+Arrays.toString(test.waitForDevices.toArray())); if( waitForEnter ) { System.err.println("Press ENTER to continue\n"); |