summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2020-05-31 05:25:57 +0200
committerSven Gothel <[email protected]>2020-05-31 05:25:57 +0200
commit18bfd4108c06669256c7d52d961fe6197eceb202 (patch)
tree4ef25b4cacc6bfbee4466d615571d442418f91dc /examples
parentccd04991b0c18079dab88b3335a8b20e22ab9629 (diff)
C++/Java Scanner 10: Refine found/connect criteria: Also in EUI48_ANY_DEVICE case, skip devices-in-processing
Diffstat (limited to 'examples')
-rw-r--r--examples/direct_bt_scanner10/dbt_scanner10.cpp17
-rw-r--r--examples/java/ScannerTinyB10.java14
2 files changed, 15 insertions, 16 deletions
diff --git a/examples/direct_bt_scanner10/dbt_scanner10.cpp b/examples/direct_bt_scanner10/dbt_scanner10.cpp
index 1197d50b..eb6222f2 100644
--- a/examples/direct_bt_scanner10/dbt_scanner10.cpp
+++ b/examples/direct_bt_scanner10/dbt_scanner10.cpp
@@ -120,10 +120,9 @@ class MyAdapterStatusListener : public AdapterStatusListener {
fprintf(stderr, "****** FOUND__-2: Skip non public LE %s\n", device->toString(true).c_str());
return;
}
- if( waitForDevice == EUI48_ANY_DEVICE ||
- ( waitForDevice == device->address &&
- !isDeviceProcessed(waitForDevice) &&
- !isDeviceProcessing(waitForDevice)
+ if( !isDeviceProcessing( device->getAddress() ) &&
+ ( waitForDevice == EUI48_ANY_DEVICE ||
+ ( waitForDevice == device->getAddress() && !isDeviceProcessed(waitForDevice) )
) )
{
fprintf(stderr, "****** FOUND__-0: Connecting %s\n", device->toString(true).c_str());
@@ -147,10 +146,9 @@ class MyAdapterStatusListener : public AdapterStatusListener {
return;
}
- if( waitForDevice == EUI48_ANY_DEVICE ||
- ( waitForDevice == device->address &&
- !isDeviceProcessed(waitForDevice) &&
- !isDeviceProcessing(waitForDevice)
+ if( !isDeviceProcessing( device->getAddress() ) &&
+ ( waitForDevice == EUI48_ANY_DEVICE ||
+ ( waitForDevice == device->getAddress() && !isDeviceProcessed(waitForDevice) )
) )
{
fprintf(stderr, "****** CONNECTED-0: Processing %s\n", device->toString(true).c_str());
@@ -299,6 +297,7 @@ exit:
device->getAdapter().startDiscovery( true );
}
removeFromDevicesProcessing(device->getAddress());
+
fprintf(stderr, "****** Processing Device: End: Success %d on %s\n", success, device->toString().c_str());
if( success ) {
addToDevicesProcessed(device->getAddress());
@@ -329,6 +328,8 @@ int main(int argc, char *argv[])
USE_WHITELIST = true;
}
}
+ fprintf(stderr, "pid %d\n", getpid());
+
fprintf(stderr, "Run with '[-dev_id <adapter-index>] [-mac <device_address>] (-wl <device_address>)*'");
fprintf(stderr, "USE_WHITELIST %d\n", USE_WHITELIST);
diff --git a/examples/java/ScannerTinyB10.java b/examples/java/ScannerTinyB10.java
index 1a97ea84..2f81f54d 100644
--- a/examples/java/ScannerTinyB10.java
+++ b/examples/java/ScannerTinyB10.java
@@ -91,10 +91,9 @@ public class ScannerTinyB10 {
System.err.println("****** FOUND__-2: Skip non public LE "+device.toString());
return;
}
- if( waitForDevice.equals(EUI48_ANY_DEVICE) ||
- ( waitForDevice.equals(device.getAddress()) &&
- !devicesProcessed.contains(waitForDevice) &&
- !devicesInProcessing.contains(waitForDevice)
+ if( !devicesInProcessing.contains( device.getAddress() ) &&
+ ( waitForDevice.equals(EUI48_ANY_DEVICE) ||
+ ( waitForDevice.equals(device.getAddress()) && !devicesProcessed.contains(waitForDevice) )
) )
{
System.err.println("****** FOUND__-0: Connecting "+device.toString());
@@ -125,10 +124,9 @@ public class ScannerTinyB10 {
return;
}
- if( waitForDevice.equals(EUI48_ANY_DEVICE) ||
- ( waitForDevice.equals(device.getAddress()) &&
- !devicesProcessed.contains(waitForDevice) &&
- !devicesInProcessing.contains(waitForDevice)
+ if( !devicesInProcessing.contains( device.getAddress() ) &&
+ ( waitForDevice.equals(EUI48_ANY_DEVICE) ||
+ ( waitForDevice.equals(device.getAddress()) && !devicesProcessed.contains(waitForDevice) )
) )
{
System.err.println("****** CONNECTED-0: Processing "+device.toString());