diff options
Diffstat (limited to 'examples')
-rw-r--r-- | examples/dbt_peripheral00.cpp | 8 | ||||
-rw-r--r-- | examples/dbt_repeater00.cpp | 18 | ||||
-rw-r--r-- | examples/dbt_scanner10.cpp | 20 |
3 files changed, 23 insertions, 23 deletions
diff --git a/examples/dbt_peripheral00.cpp b/examples/dbt_peripheral00.cpp index 18aeccba..4fb75315 100644 --- a/examples/dbt_peripheral00.cpp +++ b/examples/dbt_peripheral00.cpp @@ -599,7 +599,7 @@ static void processDisconnectedDevice(BTDeviceRef device) { device->remove(); BTDeviceRegistry::removeFromProcessingDevices(device->getAddressAndType()); - std::this_thread::sleep_for(std::chrono::milliseconds(100)); // wait a little (FIXME: Fast restart of advertising error) + jau::sleep_for( 100_ms ); // wait a little (FIXME: Fast restart of advertising error) if( !RUN_ONLY_ONCE ) { startAdvertising(&device->getAdapter(), "device-disconnected"); @@ -723,11 +723,11 @@ void test() { std::shared_ptr<MyGATTServerListener> listener = std::make_shared<MyGATTServerListener>(); dbGattServer->addListener( listener ); - BTManager & mngr = BTManager::get(); - mngr.addChangedAdapterSetCallback(myChangedAdapterSetFunc); + std::shared_ptr<BTManager> mngr = BTManager::get(); + mngr->addChangedAdapterSetCallback(myChangedAdapterSetFunc); while( !RUN_ONLY_ONCE || 0 == servedConnections ) { - std::this_thread::sleep_for(std::chrono::milliseconds(2000)); + jau::sleep_for( 2_s ); } fprintf_td(stderr, "****** Test Shutdown.01 (DBGattServer.remove-listener)\n"); diff --git a/examples/dbt_repeater00.cpp b/examples/dbt_repeater00.cpp index a84a353e..0f74863a 100644 --- a/examples/dbt_repeater00.cpp +++ b/examples/dbt_repeater00.cpp @@ -713,7 +713,7 @@ static void processDisconnectedDeviceToClient(BTDeviceRef device) { // already unpaired stopAdvertisingToClient(adapterToClient, "processDisconnectedDeviceToClient"); BTDeviceRegistry::removeFromProcessingDevices(device->getAddressAndType()); - std::this_thread::sleep_for(std::chrono::milliseconds(100)); // wait a little (FIXME: Fast restart of advertising error) + jau::sleep_for( 100_ms ); // wait a little (FIXME: Fast restart of advertising error) BTDeviceRef devToServer; { @@ -891,11 +891,11 @@ static bool myChangedAdapterSetFunc(const bool added, std::shared_ptr<BTAdapter> void test() { timestamp_t0 = getCurrentMilliseconds(); - BTManager & mngr = BTManager::get(); - mngr.addChangedAdapterSetCallback(myChangedAdapterSetFunc); + std::shared_ptr<BTManager> mngr = BTManager::get(); + mngr->addChangedAdapterSetCallback(myChangedAdapterSetFunc); while( 0 == MAX_SERVED_CONNECTIONS || MAX_SERVED_CONNECTIONS > servedClientConnections ) { - std::this_thread::sleep_for(std::chrono::milliseconds(2000)); + jau::sleep_for( 2_s ); } adapterToServer = nullptr; adapterToClient = nullptr; @@ -903,17 +903,17 @@ void test() { // // just a manually controlled pull down to show status, not required // - jau::darray<std::shared_ptr<BTAdapter>> adapterList = mngr.getAdapters(); + jau::darray<std::shared_ptr<BTAdapter>> adapterList = mngr->getAdapters(); jau::for_each_const(adapterList, [](const std::shared_ptr<BTAdapter>& adapter) { fprintf_td(stderr, "****** EOL Adapter's Devices - pre close: %s\n", adapter->toString().c_str()); adapter->printDeviceLists(); }); { - int count = mngr.removeChangedAdapterSetCallback(myChangedAdapterSetFunc); + int count = mngr->removeChangedAdapterSetCallback(myChangedAdapterSetFunc); fprintf_td(stderr, "****** EOL Removed ChangedAdapterSetCallback %d\n", count); - mngr.close(); + mngr->close(); } jau::for_each_const(adapterList, [](const std::shared_ptr<BTAdapter>& adapter) { fprintf_td(stderr, "****** EOL Adapter's Devices - post close: %s\n", adapter->toString().c_str()); @@ -1040,8 +1040,8 @@ int main(int argc, char *argv[]) // Just for testing purpose, i.e. triggering BTManager::close() within the test controlled app, // instead of program shutdown. fprintf_td(stderr, "****** Manager close start\n"); - BTManager & mngr = BTManager::get(); // already existing - mngr.close(); + std::shared_ptr<BTManager> mngr = BTManager::get(); // already existing + mngr->close(); fprintf_td(stderr, "****** Manager close end\n"); } } diff --git a/examples/dbt_scanner10.cpp b/examples/dbt_scanner10.cpp index c3e28dad..b2bb29e8 100644 --- a/examples/dbt_scanner10.cpp +++ b/examples/dbt_scanner10.cpp @@ -570,7 +570,7 @@ static void processReadyDevice(BTDeviceRef device) { fprintf_td(stderr, "\n"); } // FIXME sleep 1s for potential callbacks .. - std::this_thread::sleep_for(std::chrono::milliseconds(1000)); + jau::sleep_for( 1_s ); success = true; } catch ( std::exception & e ) { fprintf_td(stderr, "****** Processing Ready Device: Exception caught for %s: %s\n", device->toString().c_str(), e.what()); @@ -589,7 +589,7 @@ exit: if( KEEP_CONNECTED && GATT_PING_ENABLED && success ) { while( device->pingGATT() ) { fprintf_td(stderr, "****** Processing Ready Device: pingGATT OK: %s\n", device->getAddressAndType().toString().c_str()); - std::this_thread::sleep_for(std::chrono::milliseconds(1000)); + jau::sleep_for( 1_s ); } fprintf_td(stderr, "****** Processing Ready Device: pingGATT failed, waiting for disconnect: %s\n", device->getAddressAndType().toString().c_str()); // Even w/ GATT_PING_ENABLED, we utilize disconnect event to clean up -> remove @@ -713,8 +713,8 @@ void test() { timestamp_t0 = jau::getCurrentMilliseconds(); - BTManager & mngr = BTManager::get(); - mngr.addChangedAdapterSetCallback(myChangedAdapterSetFunc); + std::shared_ptr<BTManager> mngr = BTManager::get(); + mngr->addChangedAdapterSetCallback(myChangedAdapterSetFunc); while( !done ) { if( 0 == MULTI_MEASUREMENTS || @@ -727,7 +727,7 @@ void test() { fprintf_td(stderr, "****** DevicesProcessed %s\n", BTDeviceRegistry::getProcessedDevicesString().c_str()); done = true; } else { - std::this_thread::sleep_for(std::chrono::milliseconds(2000)); + jau::sleep_for( 2_s ); } } chosenAdapter = nullptr; @@ -735,17 +735,17 @@ void test() { // // just a manually controlled pull down to show status, not required // - jau::darray<std::shared_ptr<BTAdapter>> adapterList = mngr.getAdapters(); + jau::darray<std::shared_ptr<BTAdapter>> adapterList = mngr->getAdapters(); jau::for_each_const(adapterList, [](const std::shared_ptr<BTAdapter>& adapter) { fprintf_td(stderr, "****** EOL Adapter's Devices - pre close: %s\n", adapter->toString().c_str()); adapter->printDeviceLists(); }); { - int count = mngr.removeChangedAdapterSetCallback(myChangedAdapterSetFunc); + int count = mngr->removeChangedAdapterSetCallback(myChangedAdapterSetFunc); fprintf_td(stderr, "****** EOL Removed ChangedAdapterSetCallback %d\n", count); - mngr.close(); + mngr->close(); } jau::for_each_const(adapterList, [](const std::shared_ptr<BTAdapter>& adapter) { fprintf_td(stderr, "****** EOL Adapter's Devices - post close: %s\n", adapter->toString().c_str()); @@ -883,8 +883,8 @@ int main(int argc, char *argv[]) // Just for testing purpose, i.e. triggering BTManager::close() within the test controlled app, // instead of program shutdown. fprintf_td(stderr, "****** Manager close start\n"); - BTManager & mngr = BTManager::get(); // already existing - mngr.close(); + std::shared_ptr<BTManager> mngr = BTManager::get(); // already existing + mngr->close(); fprintf_td(stderr, "****** Manager close end\n"); } } |