summaryrefslogtreecommitdiffstats
path: root/examples/direct_bt_scanner10/dbt_scanner10.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'examples/direct_bt_scanner10/dbt_scanner10.cpp')
-rw-r--r--examples/direct_bt_scanner10/dbt_scanner10.cpp25
1 files changed, 16 insertions, 9 deletions
diff --git a/examples/direct_bt_scanner10/dbt_scanner10.cpp b/examples/direct_bt_scanner10/dbt_scanner10.cpp
index e04294e1..54569039 100644
--- a/examples/direct_bt_scanner10/dbt_scanner10.cpp
+++ b/examples/direct_bt_scanner10/dbt_scanner10.cpp
@@ -52,7 +52,7 @@ using namespace direct_bt;
static int64_t timestamp_t0;
-static int MULTI_MEASUREMENTS = 8;
+static std::atomic<int> MULTI_MEASUREMENTS = 8;
static bool KEEP_CONNECTED = true;
static bool GATT_PING_ENABLED = false;
@@ -424,11 +424,6 @@ exit:
device->getAdapter().printSharedPtrListOfDevices();
}
- if( 0 < MULTI_MEASUREMENTS ) {
- MULTI_MEASUREMENTS--;
- fprintf(stderr, "****** Processing Device: MULTI_MEASUREMENTS left %d: %s\n", MULTI_MEASUREMENTS, device->getAddressString().c_str());
- }
-
fprintf(stderr, "****** Processing Device: End: Success %d on %s; devInProc %zd\n",
success, device->toString().c_str(), devicesInProcessing.size());
@@ -444,6 +439,11 @@ exit:
device->getAdapter().startDiscovery( true );
}
}
+
+ if( 0 < MULTI_MEASUREMENTS ) {
+ MULTI_MEASUREMENTS--;
+ fprintf(stderr, "****** Processing Device: MULTI_MEASUREMENTS left %d: %s\n", MULTI_MEASUREMENTS.load(), device->getAddressString().c_str());
+ }
}
static void removeDevice(std::shared_ptr<DBTDevice> device) {
@@ -501,7 +501,7 @@ void test(int dev_id) {
)
{
fprintf(stderr, "****** EOL Test MULTI_MEASUREMENTS left %d, processed %zd/%zd\n",
- MULTI_MEASUREMENTS, devicesProcessed.size(), waitForDevices.size());
+ MULTI_MEASUREMENTS.load(), devicesProcessed.size(), waitForDevices.size());
printList("****** WaitForDevice ", waitForDevices);
printList("****** DevicesProcessed ", devicesProcessed);
done = true;
@@ -581,7 +581,7 @@ int main(int argc, char *argv[])
"[-dbt_l2cap reader.timeout=10000,restart.count=0,...] "
"\n");
- fprintf(stderr, "MULTI_MEASUREMENTS %d\n", MULTI_MEASUREMENTS);
+ fprintf(stderr, "MULTI_MEASUREMENTS %d\n", MULTI_MEASUREMENTS.load());
fprintf(stderr, "KEEP_CONNECTED %d\n", KEEP_CONNECTED);
fprintf(stderr, "GATT_PING_ENABLED %d\n", GATT_PING_ENABLED);
fprintf(stderr, "REMOVE_DEVICE %d\n", REMOVE_DEVICE);
@@ -598,6 +598,13 @@ int main(int argc, char *argv[])
}
fprintf(stderr, "****** TEST start\n");
test(dev_id);
- std::this_thread::sleep_for(std::chrono::milliseconds(3000));
fprintf(stderr, "****** TEST end\n");
+ if( true ) {
+ // Just for testing purpose, i.e. triggering DBTManager::close() within the test controlled app,
+ // instead of program shutdown.
+ fprintf(stderr, "****** Manager close start\n");
+ DBTManager & mngr = DBTManager::get(BTMode::NONE); // already existing
+ mngr.close();
+ fprintf(stderr, "****** Manager close end\n");
+ }
}