From 619fd2c85d03fb8ab3bbf6c84ac3fc935ab4c9f3 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 24 Sep 2020 16:57:08 +0200 Subject: dbt_scanner10/ScannerTinyB10: Fix '!KEEP_CONNECT' case, i.e. remove device and start discovery in process* function to disconnect right away. --- examples/direct_bt_scanner10/dbt_scanner10.cpp | 9 +++++++++ examples/java/ScannerTinyB10.java | 11 +++++++++++ 2 files changed, 20 insertions(+) (limited to 'examples') diff --git a/examples/direct_bt_scanner10/dbt_scanner10.cpp b/examples/direct_bt_scanner10/dbt_scanner10.cpp index 370e712c..278cbdf0 100644 --- a/examples/direct_bt_scanner10/dbt_scanner10.cpp +++ b/examples/direct_bt_scanner10/dbt_scanner10.cpp @@ -435,6 +435,15 @@ exit: if( success ) { addToDevicesProcessed(device->getAddress()); } + + if( !KEEP_CONNECTED ) { + removeFromDevicesProcessing(device->getAddress()); + + device->remove(); + if( !USE_WHITELIST && 0 == devicesInProcessing.size() ) { + device->getAdapter().startDiscovery( true ); + } + } } static void removeDevice(std::shared_ptr device) { diff --git a/examples/java/ScannerTinyB10.java b/examples/java/ScannerTinyB10.java index 82d41a89..4b6591cb 100644 --- a/examples/java/ScannerTinyB10.java +++ b/examples/java/ScannerTinyB10.java @@ -472,6 +472,17 @@ public class ScannerTinyB10 { if( success ) { devicesProcessed.add(device.getAddress()); } + + if( !KEEP_CONNECTED ) { + devicesInProcessing.remove(device.getAddress()); + + device.remove(); + + if( !USE_WHITELIST && 0 == devicesInProcessing.size() ) { + final boolean r = device.getAdapter().startDiscovery( true ); + println("****** Processing Device: startDiscovery result "+r); + } + } } private void removeDevice(final BluetoothDevice device) { -- cgit v1.2.3