summaryrefslogtreecommitdiffstats
path: root/api
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2022-01-01 16:02:34 +0100
committerSven Gothel <[email protected]>2022-01-01 16:02:34 +0100
commit3bc58feea860b84d874ae604a56e1cc20427e423 (patch)
tree9ce68ea5cad691af55e1dc9cf3435399b405b731 /api
parente19a11a60d509a42a1a1167a2b7215345784e462 (diff)
MgmtTypes: LTK, IRK and LK: Add BDAddressAndType::getBLERandomAddressTypeString(..) in toString()
BLERandomAddressType std::string representation shall be added in basic key management, allowing easier debugging of invalid keys.
Diffstat (limited to 'api')
-rw-r--r--api/direct_bt/BTAddress.hpp14
-rw-r--r--api/direct_bt/MgmtTypes.hpp8
2 files changed, 18 insertions, 4 deletions
diff --git a/api/direct_bt/BTAddress.hpp b/api/direct_bt/BTAddress.hpp
index 593ee254..a99a7f88 100644
--- a/api/direct_bt/BTAddress.hpp
+++ b/api/direct_bt/BTAddress.hpp
@@ -232,6 +232,20 @@ namespace direct_bt {
static BLERandomAddressType getBLERandomAddressType(const jau::EUI48& address, const BDAddressType addressType) noexcept;
/**
+ * Returns the BLERandomAddressType std::string representation.
+ * <p>
+ * If ::BDAddressType is ::BDAddressType::BDADDR_LE_RANDOM,
+ * method shall return the given prefix and a valid string value other than ::BLERandomAddressType::UNDEFINED.
+ * </p>
+ * <p>
+ * If BDAddressType is not ::BDAddressType::BDADDR_LE_RANDOM,
+ * method shall return an empty string.
+ * </p>
+ * @since 2.5.3
+ */
+ static std::string getBLERandomAddressTypeString(const jau::EUI48& address, const BDAddressType addressType, const std::string& prefix) noexcept;
+
+ /**
* Returns the BLERandomAddressType.
* <p>
* If type is ::BDAddressType::BDADDR_LE_RANDOM},
diff --git a/api/direct_bt/MgmtTypes.hpp b/api/direct_bt/MgmtTypes.hpp
index fb11fcbe..1c778b60 100644
--- a/api/direct_bt/MgmtTypes.hpp
+++ b/api/direct_bt/MgmtTypes.hpp
@@ -197,7 +197,7 @@ namespace direct_bt {
jau::uint128_t ltk;
std::string toString() const noexcept { // hex-fmt aligned with btmon
- return "LTK[address["+address.toString()+", "+to_string(address_type)+
+ return "LTK[address["+address.toString()+", "+to_string(address_type)+BDAddressAndType::getBLERandomAddressTypeString(address, address_type, ", ")+
"], type "+to_string(key_type)+", master "+jau::to_hexstring(master)+
", enc_size "+std::to_string(enc_size)+
", ediv "+jau::bytesHexString(reinterpret_cast<const uint8_t *>(&ediv), 0, sizeof(ediv), true /* lsbFirst */)+
@@ -252,7 +252,7 @@ namespace direct_bt {
jau::uint128_t irk;
std::string toString() const noexcept {
- return "IRK[address["+address.toString()+", "+to_string(address_type)+
+ return "IRK[address["+address.toString()+", "+to_string(address_type)+BDAddressAndType::getBLERandomAddressTypeString(address, address_type, ", ")+
"], irk "+jau::bytesHexString(irk.data, 0, sizeof(irk), true /* lsbFirst */)+
"]";
}
@@ -271,7 +271,7 @@ namespace direct_bt {
jau::uint128_t csrk;
std::string toString() const noexcept {
- return "CSRK[address["+address.toString()+", "+to_string(address_type)+
+ return "CSRK[address["+address.toString()+", "+to_string(address_type)+BDAddressAndType::getBLERandomAddressTypeString(address, address_type, ", ")+
"], type "+to_string(key_type)+
", csrk "+jau::bytesHexString(csrk.data, 0, sizeof(csrk), true /* lsbFirst */)+
"]";
@@ -293,7 +293,7 @@ namespace direct_bt {
uint8_t pin_length;
std::string toString() const noexcept {
- return "LK[address["+address.toString()+", "+to_string(address_type)+
+ return "LK[address["+address.toString()+", "+to_string(address_type)+BDAddressAndType::getBLERandomAddressTypeString(address, address_type, ", ")+
"], type "+to_string(key_type)+
", key "+jau::bytesHexString(key.data, 0, sizeof(key), true /* lsbFirst */)+
", pinLen "+jau::to_hexstring(pin_length)+