diff options
author | Sven Gothel <[email protected]> | 2021-11-09 23:00:05 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2021-11-09 23:00:05 +0100 |
commit | b131b42ebfb64ee66e59fe9c41ee66840a9f7bf1 (patch) | |
tree | 160904279a3d0a8929f39349818f7cc02da5533d /examples | |
parent | 470a1cce76c9b128b6e9a4b1c34bf2b4571331d6 (diff) |
Align early Direct-BT version output in main function and use fprintf_td() / BTUtils.*print*()
Diffstat (limited to 'examples')
-rw-r--r-- | examples/dbt_peripheral00.cpp | 28 | ||||
-rw-r--r-- | examples/dbt_scanner10.cpp | 46 | ||||
-rw-r--r-- | examples/java/DBTPeripheral00.java | 5 |
3 files changed, 39 insertions, 40 deletions
diff --git a/examples/dbt_peripheral00.cpp b/examples/dbt_peripheral00.cpp index 120b0ef7..5489dcb4 100644 --- a/examples/dbt_peripheral00.cpp +++ b/examples/dbt_peripheral00.cpp @@ -621,8 +621,6 @@ static bool myChangedAdapterSetFunc(const bool added, std::shared_ptr<BTAdapter> void test() { bool done = false; - fprintf_td(stderr, "DirectBT Native Version %s (API %s)\n", DIRECT_BT_VERSION, DIRECT_BT_VERSION_API); - timestamp_t0 = getCurrentMilliseconds(); dbGattServer->addListener( std::make_shared<MyGATTServerListener>() ); @@ -642,6 +640,8 @@ int main(int argc, char *argv[]) { bool waitForEnter=false; + fprintf_td(stderr, "DirectBT Native Version %s (API %s)\n", DIRECT_BT_VERSION, DIRECT_BT_VERSION_API); + for(int i=1; i<argc; i++) { if( !strcmp("-dbt_debug", argv[i]) && argc > (i+1) ) { setenv("direct_bt.debug", argv[++i], 1 /* overwrite */); @@ -673,9 +673,9 @@ int main(int argc, char *argv[]) dbGattServer->max_att_mtu = atoi(argv[++i]); } } - fprintf(stderr, "pid %d\n", getpid()); + fprintf_td(stderr, "pid %d\n", getpid()); - fprintf(stderr, "Run with '[-btmode LE|BREDR|DUAL] [-use_sc 0|1] " + fprintf_td(stderr, "Run with '[-btmode LE|BREDR|DUAL] [-use_sc 0|1] " "[-adapter <adapter_address>] " "[-name <adapter_name>] " "[-short_name <adapter_short_name>] " @@ -688,19 +688,19 @@ int main(int argc, char *argv[]) "[-dbt_l2cap reader.timeout=10000,restart.count=0,...] " "\n"); - fprintf(stderr, "SHOW_UPDATE_EVENTS %d\n", SHOW_UPDATE_EVENTS); - fprintf(stderr, "adapter %s\n", useAdapter.toString().c_str()); - fprintf(stderr, "btmode %s\n", to_string(btMode).c_str()); - fprintf(stderr, "name %s (short %s)\n", adapter_name.c_str(), adapter_short_name.c_str()); - fprintf(stderr, "GattServer %s\n", dbGattServer->toString().c_str()); - fprintf(stderr, "GattServer.services: %s\n", dbGattServer->services.get_info().c_str()); - fprintf(stderr, "GattService.characteristics: %s\n", dbGattServer->services[0].characteristics.get_info().c_str()); + fprintf_td(stderr, "SHOW_UPDATE_EVENTS %d\n", SHOW_UPDATE_EVENTS); + fprintf_td(stderr, "adapter %s\n", useAdapter.toString().c_str()); + fprintf_td(stderr, "btmode %s\n", to_string(btMode).c_str()); + fprintf_td(stderr, "name %s (short %s)\n", adapter_name.c_str(), adapter_short_name.c_str()); + fprintf_td(stderr, "GattServer %s\n", dbGattServer->toString().c_str()); + fprintf_td(stderr, "GattServer.services: %s\n", dbGattServer->services.get_info().c_str()); + fprintf_td(stderr, "GattService.characteristics: %s\n", dbGattServer->services[0].characteristics.get_info().c_str()); if( waitForEnter ) { - fprintf(stderr, "Press ENTER to continue\n"); + fprintf_td(stderr, "Press ENTER to continue\n"); getchar(); } - fprintf(stderr, "****** TEST start\n"); + fprintf_td(stderr, "****** TEST start\n"); test(); - fprintf(stderr, "****** TEST end\n"); + fprintf_td(stderr, "****** TEST end\n"); } diff --git a/examples/dbt_scanner10.cpp b/examples/dbt_scanner10.cpp index 10ee6d08..35e25555 100644 --- a/examples/dbt_scanner10.cpp +++ b/examples/dbt_scanner10.cpp @@ -715,8 +715,6 @@ static bool myChangedAdapterSetFunc(const bool added, std::shared_ptr<BTAdapter> void test() { bool done = false; - fprintf_td(stderr, "DirectBT Native Version %s (API %s)\n", DIRECT_BT_VERSION, DIRECT_BT_VERSION_API); - timestamp_t0 = getCurrentMilliseconds(); BTManager & mngr = BTManager::get(); @@ -765,6 +763,8 @@ int main(int argc, char *argv[]) { bool waitForEnter=false; + fprintf_td(stderr, "DirectBT Native Version %s (API %s)\n", DIRECT_BT_VERSION, DIRECT_BT_VERSION_API); + for(int i=1; i<argc; i++) { fprintf(stderr, "arg[%d/%d]: '%s'\n", i, argc, argv[i]); @@ -841,9 +841,9 @@ int main(int argc, char *argv[]) RESET_ADAPTER_EACH_CONN = atoi(argv[++i]); } } - fprintf(stderr, "pid %d\n", getpid()); + fprintf_td(stderr, "pid %d\n", getpid()); - fprintf(stderr, "Run with '[-btmode LE|BREDR|DUAL] " + fprintf_td(stderr, "Run with '[-btmode LE|BREDR|DUAL] " "[-disconnect] [-enableGATTPing] [-count <number>] [-single] [-show_update_events] [-quiet] " "[-scanPassive]" "[-resetEachCon connectionCount] " @@ -862,36 +862,36 @@ int main(int argc, char *argv[]) "[-dbt_l2cap reader.timeout=10000,restart.count=0,...] " "\n"); - fprintf(stderr, "MULTI_MEASUREMENTS %d\n", MULTI_MEASUREMENTS.load()); - fprintf(stderr, "KEEP_CONNECTED %d\n", KEEP_CONNECTED); - fprintf(stderr, "RESET_ADAPTER_EACH_CONN %d\n", RESET_ADAPTER_EACH_CONN); - fprintf(stderr, "GATT_PING_ENABLED %d\n", GATT_PING_ENABLED); - fprintf(stderr, "REMOVE_DEVICE %d\n", REMOVE_DEVICE); - fprintf(stderr, "USE_WHITELIST %d\n", USE_WHITELIST); - fprintf(stderr, "SHOW_UPDATE_EVENTS %d\n", SHOW_UPDATE_EVENTS); - fprintf(stderr, "QUIET %d\n", QUIET); - fprintf(stderr, "adapter %s\n", useAdapter.toString().c_str()); - fprintf(stderr, "btmode %s\n", to_string(btMode).c_str()); - fprintf(stderr, "scanActive %s\n", to_string(le_scan_active).c_str()); - fprintf(stderr, "Command: cmd %s, arg 0x%X\n rsp %s\n", + fprintf_td(stderr, "MULTI_MEASUREMENTS %d\n", MULTI_MEASUREMENTS.load()); + fprintf_td(stderr, "KEEP_CONNECTED %d\n", KEEP_CONNECTED); + fprintf_td(stderr, "RESET_ADAPTER_EACH_CONN %d\n", RESET_ADAPTER_EACH_CONN); + fprintf_td(stderr, "GATT_PING_ENABLED %d\n", GATT_PING_ENABLED); + fprintf_td(stderr, "REMOVE_DEVICE %d\n", REMOVE_DEVICE); + fprintf_td(stderr, "USE_WHITELIST %d\n", USE_WHITELIST); + fprintf_td(stderr, "SHOW_UPDATE_EVENTS %d\n", SHOW_UPDATE_EVENTS); + fprintf_td(stderr, "QUIET %d\n", QUIET); + fprintf_td(stderr, "adapter %s\n", useAdapter.toString().c_str()); + fprintf_td(stderr, "btmode %s\n", to_string(btMode).c_str()); + fprintf_td(stderr, "scanActive %s\n", to_string(le_scan_active).c_str()); + fprintf_td(stderr, "Command: cmd %s, arg 0x%X\n rsp %s\n", nullptr != cmd_uuid ? cmd_uuid->toString().c_str() : "n/a", cmd_arg, nullptr != cmd_rsp_uuid ? cmd_rsp_uuid->toString().c_str() : "n/a"); - fprintf(stderr, "security-details: %s\n", BTSecurityRegistry::allToString().c_str()); - fprintf(stderr, "waitForDevice: %s\n", BTDeviceRegistry::getWaitForDevicesString().c_str()); + fprintf_td(stderr, "security-details: %s\n", BTSecurityRegistry::allToString().c_str()); + fprintf_td(stderr, "waitForDevice: %s\n", BTDeviceRegistry::getWaitForDevicesString().c_str()); if( waitForEnter ) { - fprintf(stderr, "Press ENTER to continue\n"); + fprintf_td(stderr, "Press ENTER to continue\n"); getchar(); } - fprintf(stderr, "****** TEST start\n"); + fprintf_td(stderr, "****** TEST start\n"); test(); - fprintf(stderr, "****** TEST end\n"); + fprintf_td(stderr, "****** TEST end\n"); if( true ) { // Just for testing purpose, i.e. triggering BTManager::close() within the test controlled app, // instead of program shutdown. - fprintf(stderr, "****** Manager close start\n"); + fprintf_td(stderr, "****** Manager close start\n"); BTManager & mngr = BTManager::get(); // already existing mngr.close(); - fprintf(stderr, "****** Manager close end\n"); + fprintf_td(stderr, "****** Manager close end\n"); } } diff --git a/examples/java/DBTPeripheral00.java b/examples/java/DBTPeripheral00.java index f8707e9f..7aa482f0 100644 --- a/examples/java/DBTPeripheral00.java +++ b/examples/java/DBTPeripheral00.java @@ -607,9 +607,6 @@ public class DBTPeripheral00 { public void runTest(final BTManager manager) { final boolean done = false; - BTUtils.println(System.err, "DirectBT Native Version "+BTFactory.getNativeVersion()+" (API "+BTFactory.getNativeAPIVersion()+")"); - BTUtils.println(System.err, "DirectBT Java Version "+BTFactory.getImplVersion()+" (API "+BTFactory.getAPIVersion()+")"); - timestamp_t0 = BTUtils.currentTimeMillis(); dbGattServer.addListener( new MyGATTServerListener() ); @@ -660,6 +657,8 @@ public class DBTPeripheral00 { return; } BTUtils.println(System.err, "DirectBT BluetoothManager initialized!"); + BTUtils.println(System.err, "DirectBT Native Version "+BTFactory.getNativeVersion()+" (API "+BTFactory.getNativeAPIVersion()+")"); + BTUtils.println(System.err, "DirectBT Java Version "+BTFactory.getImplVersion()+" (API "+BTFactory.getAPIVersion()+")"); final DBTPeripheral00 test = new DBTPeripheral00(); |