summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2020-09-20 23:43:12 +0200
committerSven Gothel <[email protected]>2020-09-20 23:43:12 +0200
commitc765a62fcce39b7f8048bed15a7ec53dc52f0ca7 (patch)
tree17701ff9eca5d965c58270afcca9033e8dc0634a
parent346d92d0a6ff088188fbe99cff5a01d133113757 (diff)
GATT*::toString(): Encapsulate resulting string with '[]'; Examples: Use clear type names: CharDef and CharVal
-rw-r--r--examples/direct_bt_scanner10/dbt_scanner10.cpp8
-rw-r--r--examples/java/ScannerTinyB10.java8
-rw-r--r--src/direct_bt/GATTCharacteristic.cpp8
-rw-r--r--src/direct_bt/GATTDescriptor.cpp4
-rw-r--r--src/direct_bt/GATTService.cpp8
5 files changed, 18 insertions, 18 deletions
diff --git a/examples/direct_bt_scanner10/dbt_scanner10.cpp b/examples/direct_bt_scanner10/dbt_scanner10.cpp
index 03cc7296..0c08dc25 100644
--- a/examples/direct_bt_scanner10/dbt_scanner10.cpp
+++ b/examples/direct_bt_scanner10/dbt_scanner10.cpp
@@ -327,14 +327,14 @@ static void processConnectedDevice(std::shared_ptr<DBTDevice> device) {
for(size_t j=0; j<serviceCharacteristics.size(); j++) {
GATTCharacteristic & serviceChar = *serviceCharacteristics.at(j);
if( !SILENT_GATT ) {
- fprintf(stderr, " [%2.2d.%2.2d] Decla: %s\n", (int)i, (int)j, serviceChar.toString().c_str());
+ fprintf(stderr, " [%2.2d.%2.2d] CharDef: %s\n", (int)i, (int)j, serviceChar.toString().c_str());
}
if( serviceChar.hasProperties(GATTCharacteristic::PropertyBitVal::Read) ) {
POctets value(GATTHandler::number(GATTHandler::Defaults::MAX_ATT_MTU), 0);
if( serviceChar.readValue(value) ) {
std::string sval = dfa_utf8_decode(value.get_ptr(), value.getSize());
if( !SILENT_GATT ) {
- fprintf(stderr, " [%2.2d.%2.2d] Value: %s ('%s')\n", (int)i, (int)j, value.toString().c_str(), sval.c_str());
+ fprintf(stderr, " [%2.2d.%2.2d] CharVal: %s ('%s')\n", (int)i, (int)j, value.toString().c_str(), sval.c_str());
}
}
}
@@ -501,8 +501,8 @@ int main(int argc, char *argv[])
fprintf(stderr, "Run with '[-dev_id <adapter-index>] [-btmode LE|BREDR|DUAL] "
"[-disconnect] [-count <number>] [-single] [-show_update_events] [-silent_gatt] "
"(-mac <device_address>)* (-wl <device_address>)* "
- "[-dbt_verbose [true|false]] "
- "[-dbt_debug [true|false|adapter.event,gatt.data,hci.event,mgmt.event]] "
+ "[-dbt_verbose true|false] "
+ "[-dbt_debug true|false|adapter.event,gatt.data,hci.event,mgmt.event] "
"[-dbt_mgmt cmd.timeout=3000,ringsize=64,... "
"[-dbt_hci cmd.complete.timeout=10000,cmd.status.timeout=3000,ringsize=64,... "
"[-dbt_gatt cmd.read.timeout=500,cmd.write.timeout=500,cmd.init.timeout=2500,ringsize=128,... "
diff --git a/examples/java/ScannerTinyB10.java b/examples/java/ScannerTinyB10.java
index 8c5f8ac7..4ef7c055 100644
--- a/examples/java/ScannerTinyB10.java
+++ b/examples/java/ScannerTinyB10.java
@@ -337,14 +337,14 @@ public class ScannerTinyB10 {
for(final Iterator<BluetoothGattCharacteristic> charIter = serviceCharacteristics.iterator(); charIter.hasNext(); j++) {
final BluetoothGattCharacteristic serviceChar = charIter.next();
if( !SILENT_GATT ) {
- printf(" [%02d.%02d] Decla: %s\n", i, j, serviceChar.toString());
+ printf(" [%02d.%02d] CharDec: %s\n", i, j, serviceChar.toString());
}
final List<String> properties = Arrays.asList(serviceChar.getFlags());
if( properties.contains("read") ) {
final byte[] value = serviceChar.readValue();
final String svalue = BluetoothUtils.decodeUTF8String(value, 0, value.length);
if( !SILENT_GATT ) {
- printf(" [%02d.%02d] Value: %s ('%s')\n",
+ printf(" [%02d.%02d] CharVal: %s ('%s')\n",
i, j, BluetoothUtils.bytesHexString(value, true, true), svalue);
}
}
@@ -577,8 +577,8 @@ public class ScannerTinyB10 {
"[-disconnect] [-count <number>] [-single] (-char <uuid>)* [-show_update_events] [-silent_gatt]"+
"(-mac <device_address>)* (-wl <device_address>)* "+
"[-verbose] [-debug] "+
- "[-dbt_verbose [true|false]] "+
- "[-dbt_debug [true|false|adapter.event,gatt.data,hci.event,mgmt.event]] "+
+ "[-dbt_verbose true|false] "+
+ "[-dbt_debug true|false|adapter.event,gatt.data,hci.event,mgmt.event] "+
"[-dbt_mgmt cmd.timeout=3000,ringsize=64,... "+
"[-dbt_hci cmd.complete.timeout=10000,cmd.status.timeout=3000,ringsize=64,... "+
"[-dbt_gatt cmd.read.timeout=500,cmd.write.timeout=500,cmd.init.timeout=2500,ringsize=128,... "+
diff --git a/src/direct_bt/GATTCharacteristic.cpp b/src/direct_bt/GATTCharacteristic.cpp
index cb3c3f0c..450f7caa 100644
--- a/src/direct_bt/GATTCharacteristic.cpp
+++ b/src/direct_bt/GATTCharacteristic.cpp
@@ -131,11 +131,11 @@ std::string GATTCharacteristic::toString() const noexcept {
desc_str += cd->toString() + ", ";
}
desc_str += " ]";
- return "handle "+uint16HexString(handle)+", props "+uint8HexString(properties)+" "+getPropertiesString()+
+ return "[handle "+uint16HexString(handle)+", props "+uint8HexString(properties)+" "+getPropertiesString()+
", value[type 0x"+value_type->toString()+", handle "+uint16HexString(value_handle)+char_name+desc_str+
"], service[type 0x"+service_uuid_str+
", handle[ "+uint16HexString(service_handle)+".."+uint16HexString(service_handle_end)+" ]"+
- service_name+", enabled[notify "+std::to_string(enabledNotifyState)+", indicate "+std::to_string(enabledIndicateState)+"] ]";
+ service_name+", enabled[notify "+std::to_string(enabledNotifyState)+", indicate "+std::to_string(enabledIndicateState)+"] ] ]";
}
std::string GATTCharacteristic::toShortString() const noexcept {
@@ -145,11 +145,11 @@ std::string GATTCharacteristic::toShortString() const noexcept {
const uint16_t uuid16 = (static_cast<const uuid16_t*>(value_type.get()))->value;
char_name = ", "+GattCharacteristicTypeToString(static_cast<GattCharacteristicType>(uuid16));
}
- return "handle "+uint16HexString(handle)+", props "+uint8HexString(properties)+" "+getPropertiesString()+
+ return "[handle "+uint16HexString(handle)+", props "+uint8HexString(properties)+" "+getPropertiesString()+
", value[handle "+uint16HexString(value_handle)+char_name+
"], service["+
", handle[ "+uint16HexString(service_handle)+".. ]"+
- ", enabled[notify "+std::to_string(enabledNotifyState)+", indicate "+std::to_string(enabledIndicateState)+"] ]";
+ ", enabled[notify "+std::to_string(enabledNotifyState)+", indicate "+std::to_string(enabledIndicateState)+"] ] ]";
}
std::shared_ptr<GATTService> GATTCharacteristic::getServiceChecked() const {
diff --git a/src/direct_bt/GATTDescriptor.cpp b/src/direct_bt/GATTDescriptor.cpp
index 2b7c1a37..b77b97f0 100644
--- a/src/direct_bt/GATTDescriptor.cpp
+++ b/src/direct_bt/GATTDescriptor.cpp
@@ -78,9 +78,9 @@ bool GATTDescriptor::writeValue() {
}
std::string GATTDescriptor::toString() const noexcept {
- return "[type 0x"+type->toString()+", handle "+uint16HexString(handle)+", value["+value.toString()+"]]";
+ return "[type 0x"+type->toString()+", handle "+uint16HexString(handle)+", value["+value.toString()+"] ]";
}
std::string GATTDescriptor::toShortString() const noexcept {
- return "[handle "+uint16HexString(handle)+", value["+value.toString()+"]]";
+ return "[handle "+uint16HexString(handle)+", value["+value.toString()+"] ]";
}
diff --git a/src/direct_bt/GATTService.cpp b/src/direct_bt/GATTService.cpp
index 7efb380d..b4af9a4e 100644
--- a/src/direct_bt/GATTService.cpp
+++ b/src/direct_bt/GATTService.cpp
@@ -66,8 +66,8 @@ std::string GATTService::toString() const noexcept {
const uint16_t uuid16 = (static_cast<const uuid16_t*>(type.get()))->value;
name = " - "+GattServiceTypeToString(static_cast<GattServiceType>(uuid16));
}
- return "type 0x"+type->toString()+", handle ["+uint16HexString(startHandle, true)+".."+uint16HexString(endHandle, true)+"]"+
- name+", "+std::to_string(characteristicList.size())+" characteristics";
+ return "[type 0x"+type->toString()+", handle ["+uint16HexString(startHandle, true)+".."+uint16HexString(endHandle, true)+"]"+
+ name+", "+std::to_string(characteristicList.size())+" characteristics]";
}
std::string GATTService::toShortString() const noexcept {
@@ -76,6 +76,6 @@ std::string GATTService::toShortString() const noexcept {
const uint16_t uuid16 = (static_cast<const uuid16_t*>(type.get()))->value;
name = " - "+GattServiceTypeToString(static_cast<GattServiceType>(uuid16));
}
- return "handle ["+uint16HexString(startHandle, true)+".."+uint16HexString(endHandle, true)+"]"+
- name+", "+std::to_string(characteristicList.size())+" characteristics";
+ return "[handle ["+uint16HexString(startHandle, true)+".."+uint16HexString(endHandle, true)+"]"+
+ name+", "+std::to_string(characteristicList.size())+" characteristics]";
}