aboutsummaryrefslogtreecommitdiffstats
path: root/src/direct_bt/BTGattChar.cpp
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2021-10-13 05:34:08 +0200
committerSven Gothel <[email protected]>2021-10-13 05:34:08 +0200
commit726759140057843ed86fa2fdf212fd176ff38ebe (patch)
tree64268d79c61d14c5b41653af5297a27d4a08ef70 /src/direct_bt/BTGattChar.cpp
parent28cc0bf0094bc736ea473c2a2906df34319e6346 (diff)
[BT|DB]GattChar::toString(): Add UTF8 user-description if available
Diffstat (limited to 'src/direct_bt/BTGattChar.cpp')
-rw-r--r--src/direct_bt/BTGattChar.cpp19
1 files changed, 16 insertions, 3 deletions
diff --git a/src/direct_bt/BTGattChar.cpp b/src/direct_bt/BTGattChar.cpp
index 96752e17..2099aaa0 100644
--- a/src/direct_bt/BTGattChar.cpp
+++ b/src/direct_bt/BTGattChar.cpp
@@ -32,6 +32,7 @@
#include <algorithm>
+#include <jau/dfa_utf8_decode.hpp>
#include <jau/debug.hpp>
#include "BTDevice.hpp"
@@ -139,6 +140,12 @@ std::string BTGattChar::toString() const noexcept {
const uint16_t uuid16 = (static_cast<const uuid16_t*>(value_type.get()))->value;
char_name = ", "+GattCharacteristicTypeToString(static_cast<GattCharacteristicType>(uuid16));
}
+ {
+ BTGattDescRef ud = getUserDescription();
+ if( nullptr != ud ) {
+ char_name.append( ", '" + dfa_utf8_decode( ud->value.get_ptr(), ud->value.size() ) + "'");
+ }
+ }
if( 0 < descriptorList.size() ) {
bool comma = false;
desc_str = ", descr[";
@@ -158,23 +165,29 @@ std::string BTGattChar::toString() const noexcept {
notify_str = ", enabled[notify "+std::to_string(enabledNotifyState)+", indicate "+std::to_string(enabledIndicateState)+"]";
}
return "Char[handle "+to_hexstring(handle)+", props "+to_hexstring(properties)+" "+getPropertiesString(properties)+
- ", value[type 0x"+value_type->toString()+", handle "+to_hexstring(value_handle)+char_name+desc_str+
+ char_name+", value[type 0x"+value_type->toString()+", handle "+to_hexstring(value_handle)+desc_str+
"], ccd-idx "+std::to_string(clientCharConfigIndex)+notify_str+"]";
}
std::string BTGattChar::toShortString() const noexcept {
- std::string char_name = "";
+ std::string char_name;
if( uuid_t::TypeSize::UUID16_SZ == value_type->getTypeSize() ) {
const uint16_t uuid16 = (static_cast<const uuid16_t*>(value_type.get()))->value;
char_name = ", "+GattCharacteristicTypeToString(static_cast<GattCharacteristicType>(uuid16));
}
+ {
+ BTGattDescRef ud = getUserDescription();
+ if( nullptr != ud ) {
+ char_name.append( ", '" + dfa_utf8_decode( ud->value.get_ptr(), ud->value.size() ) + "'");
+ }
+ }
std::string notify_str;
if( hasProperties(BTGattChar::PropertyBitVal::Notify) || hasProperties(BTGattChar::PropertyBitVal::Indicate) ) {
notify_str = ", enabled[notify "+std::to_string(enabledNotifyState)+", indicate "+std::to_string(enabledIndicateState)+"]";
}
return "Char[handle "+to_hexstring(handle)+", props "+to_hexstring(properties)+" "+getPropertiesString(properties)+
- ", value[handle "+to_hexstring(value_handle)+char_name+
+ char_name+", value[handle "+to_hexstring(value_handle)+
"], ccd-idx "+std::to_string(clientCharConfigIndex)+notify_str+"]";
}