From 726759140057843ed86fa2fdf212fd176ff38ebe Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 13 Oct 2021 05:34:08 +0200 Subject: [BT|DB]GattChar::toString(): Add UTF8 user-description if available --- api/direct_bt/DBGattServer.hpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'api/direct_bt/DBGattServer.hpp') diff --git a/api/direct_bt/DBGattServer.hpp b/api/direct_bt/DBGattServer.hpp index 8971e18a..3b737502 100644 --- a/api/direct_bt/DBGattServer.hpp +++ b/api/direct_bt/DBGattServer.hpp @@ -37,6 +37,7 @@ #include #include #include +#include #include "BTTypes0.hpp" #include "ATTPDUTypes.hpp" @@ -203,13 +204,19 @@ namespace direct_bt { bool hasProperties(const BTGattChar::PropertyBitVal v) const noexcept { return v == ( properties & v ); } std::string toString() const noexcept { - std::string notify_str; + std::string char_name, notify_str; + { + const DBGattDesc* ud = getUserDescription(); + if( nullptr != ud ) { + char_name = ", '" + jau::dfa_utf8_decode( ud->value.get_ptr(), ud->value.size() ) + "'"; + } + } 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 ["+jau::to_hexstring(handle)+".."+jau::to_hexstring(end_handle)+ "], props "+jau::to_hexstring(properties)+" "+BTGattChar::getPropertiesString(properties)+ - ", value[type 0x"+value_type->toString()+", handle "+jau::to_hexstring(value_handle)+", "+value.toString()+ + char_name+", value[type 0x"+value_type->toString()+", handle "+jau::to_hexstring(value_handle)+", "+value.toString()+ "], ccd-idx "+std::to_string(clientCharConfigIndex)+notify_str+"]"; } -- cgit v1.2.3