From 21f35e4e448a85cb6ba307e7a10db6bebb42c86b Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Mon, 23 Nov 2020 19:58:47 +0100 Subject: Fix dbt_scanner10.cpp (NPE) and align DBTScanner10.java .. --- examples/direct_bt_scanner10/dbt_scanner10.cpp | 9 +++++---- examples/java/DBTScanner10.java | 9 +++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/examples/direct_bt_scanner10/dbt_scanner10.cpp b/examples/direct_bt_scanner10/dbt_scanner10.cpp index c2773cf4..bcda886a 100644 --- a/examples/direct_bt_scanner10/dbt_scanner10.cpp +++ b/examples/direct_bt_scanner10/dbt_scanner10.cpp @@ -68,7 +68,7 @@ static bool REMOVE_DEVICE = true; static bool USE_WHITELIST = false; static std::vector WHITELIST; -static std::string charIdentifier = nullptr; +static std::string charIdentifier = ""; static int charValue = 0; static bool SHOW_UPDATE_EVENTS = false; @@ -423,7 +423,7 @@ static void processConnectedDevice(std::shared_ptr device) { { // WIP: Implement a simple Characteristic ping-pong writeValue <-> notify transmission for stress testing. DBTManager & manager = device->getAdapter().getManager(); - if( nullptr != charIdentifier ) { + if( nullptr != charIdentifier && charIdentifier.length() > 0 ) { GATTCharacteristic * char2 = (GATTCharacteristic*) nullptr; // manager.find(BluetoothType.GATT_CHARACTERISTIC, null, charIdentifier, device); fprintf(stderr, "Char UUID %s\n", charIdentifier.c_str()); @@ -788,8 +788,8 @@ int main(int argc, char *argv[]) "[-disconnect] [-enableGATTPing] [-count ] [-single] [-show_update_events] [-quiet] " "[-resetEachCon connectionCount] " "(-mac )* (-wl )* " - "[-seclevel ] [-iocap ] [-passkey ]" - "[-charid ] [-charval ]" + "[-seclevel ] [-iocap ] [-passkey ] " + "[-charid ] [-charval ] " "[-dbt_verbose true|false] " "[-dbt_debug true|false|adapter.event,gatt.data,hci.event,mgmt.event] " "[-dbt_mgmt cmd.timeout=3000,ringsize=64,...] " @@ -809,6 +809,7 @@ int main(int argc, char *argv[]) fprintf(stderr, "btmode %s\n", getBTModeString(btMode).c_str()); fprintf(stderr, "passkey %u\n", pairing_passkey); fprintf(stderr, "seclevel %s\n", getBTSecurityLevelString(sec_level).c_str()); + fprintf(stderr, "iocap %s\n", getSMPIOCapabilityString(io_capabilities).c_str()); fprintf(stderr, "characteristic-id: %s\n", charIdentifier.c_str()); fprintf(stderr, "characteristic-value: %d\n", charValue); diff --git a/examples/java/DBTScanner10.java b/examples/java/DBTScanner10.java index 44d7f9d6..33e799ca 100644 --- a/examples/java/DBTScanner10.java +++ b/examples/java/DBTScanner10.java @@ -373,7 +373,7 @@ public class DBTScanner10 { { // WIP: Implement a simple Characteristic ping-pong writeValue <-> notify transmission for stress testing. final BluetoothManager manager = device.getAdapter().getManager(); - if( null != charIdentifier ) { + if( null != charIdentifier && charIdentifier.length() > 0 ) { final BluetoothGattCharacteristic char2 = (BluetoothGattCharacteristic) manager.find(BluetoothType.GATT_CHARACTERISTIC, null, charIdentifier, device); println("Char UUID "+charIdentifier); @@ -762,11 +762,11 @@ public class DBTScanner10 { } println("Run with '[-btmode LE|BREDR|DUAL] "+ "[-bluetoothManager ] "+ - "[-disconnect] [-enableGATTPing] [-count ] [-single] [-show_update_events] [-quiet] "+ + "[-disconnect] [-enableGATTPing] [-count ] [-single] [-show_update_events] [-quiet] "+ "[-resetEachCon connectionCount] "+ "(-mac )* (-wl )* "+ - "[-seclevel ] [-iocap ] [-passkey ]" + - "[-charid ] [-charval ]"+ + "[-seclevel ] [-iocap ] [-passkey ] " + + "[-charid ] [-charval ] "+ "[-verbose] [-debug] "+ "[-dbt_verbose true|false] "+ "[-dbt_debug true|false|adapter.event,gatt.data,hci.event,mgmt.event] "+ @@ -787,6 +787,7 @@ public class DBTScanner10 { println("QUIET "+test.QUIET); println("passkey "+test.pairing_passkey); println("seclevel "+test.sec_level); + println("iocap "+test.io_capabilities); println("characteristic-id: "+test.charIdentifier); println("characteristic-value: "+test.charValue); -- cgit v1.2.3