BLE: Remove uses of tr_as_array in favour of to_string.

pull/14198/head
Vincent Coubard 2021-01-27 12:14:47 +00:00 committed by Paul Szczepanek
parent c674990820
commit 65c61a1ca9
4 changed files with 25 additions and 31 deletions

View File

@ -39,12 +39,6 @@ const char* att_client_callback_event_to_string(uint8_t code);
const char* att_error_code_to_string(uint8_t code); const char* att_error_code_to_string(uint8_t code);
#endif //MBED_CONF_MBED_TRACE_ENABLE #endif //MBED_CONF_MBED_TRACE_ENABLE
template<typename T>
const char* tr_as_array(T item)
{
return (mbed_trace_array)((const uint8_t*)&item, sizeof(item));
}
template<size_t size> template<size_t size>
const char* to_string(const ble::byte_array_t<size> &array) const char* to_string(const ble::byte_array_t<size> &array)
{ {

View File

@ -186,7 +186,7 @@ void FileSecurityDb::set_entry_local_ltk(
entry->flags.ltk_sent = true; entry->flags.ltk_sent = true;
tr_info("Write DB entry %d: local ltk %s", get_index(db_handle), tr_as_array(ltk)); tr_info("Write DB entry %d: local ltk %s", get_index(db_handle), to_string(ltk));
db_write(&ltk, entry->file_offset + DB_STORE_OFFSET_LOCAL_KEYS_LTK); db_write(&ltk, entry->file_offset + DB_STORE_OFFSET_LOCAL_KEYS_LTK);
} }
@ -201,7 +201,7 @@ void FileSecurityDb::set_entry_local_ediv_rand(
return; return;
} }
tr_info("Write DB entry %d: local ediv %s rand %s", get_index(db_handle), tr_as_array(ediv), tr_as_array(rand)); tr_info("Write DB entry %d: local ediv %s rand %s", get_index(db_handle), to_string(ediv), to_string(rand));
db_write(&ediv, entry->file_offset + DB_STORE_OFFSET_LOCAL_KEYS_EDIV); db_write(&ediv, entry->file_offset + DB_STORE_OFFSET_LOCAL_KEYS_EDIV);
db_write(&rand, entry->file_offset + DB_STORE_OFFSET_LOCAL_KEYS_RAND); db_write(&rand, entry->file_offset + DB_STORE_OFFSET_LOCAL_KEYS_RAND);
} }
@ -222,7 +222,7 @@ void FileSecurityDb::set_entry_peer_ltk(
entry->flags.ltk_stored = true; entry->flags.ltk_stored = true;
tr_info("Write DB entry %d: peer ltk %s", get_index(db_handle), tr_as_array(ltk)); tr_info("Write DB entry %d: peer ltk %s", get_index(db_handle), to_string(ltk));
db_write(&ltk, entry->file_offset + DB_STORE_OFFSET_PEER_KEYS_LTK); db_write(&ltk, entry->file_offset + DB_STORE_OFFSET_PEER_KEYS_LTK);
} }
@ -237,7 +237,7 @@ void FileSecurityDb::set_entry_peer_ediv_rand(
return; return;
} }
tr_info("Write DB entry %d: peer ediv %s rand %s", get_index(db_handle), tr_as_array(ediv), tr_as_array(rand)); tr_info("Write DB entry %d: peer ediv %s rand %s", get_index(db_handle), to_string(ediv), to_string(rand));
db_write(&ediv, entry->file_offset + DB_STORE_OFFSET_PEER_KEYS_EDIV); db_write(&ediv, entry->file_offset + DB_STORE_OFFSET_PEER_KEYS_EDIV);
db_write(&rand, entry->file_offset + DB_STORE_OFFSET_PEER_KEYS_RAND); db_write(&rand, entry->file_offset + DB_STORE_OFFSET_PEER_KEYS_RAND);
} }
@ -254,7 +254,7 @@ void FileSecurityDb::set_entry_peer_irk(
entry->flags.irk_stored = true; entry->flags.irk_stored = true;
tr_info("Write DB entry %d: peer irk %s", get_index(db_handle), tr_as_array(irk)); tr_info("Write DB entry %d: peer irk %s", get_index(db_handle), to_string(irk));
db_write(&irk, entry->file_offset + DB_STORE_OFFSET_PEER_IDENTITY_IRK); db_write(&irk, entry->file_offset + DB_STORE_OFFSET_PEER_IDENTITY_IRK);
} }
@ -269,7 +269,7 @@ void FileSecurityDb::set_entry_peer_bdaddr(
return; return;
} }
tr_info("Write DB entry %d: %s peer address %s", get_index(db_handle), address_is_public? "public" : "private", tr_as_array(peer_address)); tr_info("Write DB entry %d: %s peer address %s", get_index(db_handle), address_is_public? "public" : "private", to_string(peer_address));
db_write(&peer_address, entry->file_offset + DB_STORE_OFFSET_PEER_IDENTITY_ADDRESS); db_write(&peer_address, entry->file_offset + DB_STORE_OFFSET_PEER_IDENTITY_ADDRESS);
db_write(&address_is_public, entry->file_offset + DB_STORE_OFFSET_PEER_IDENTITY_ADDRESS_IS_PUBLIC); db_write(&address_is_public, entry->file_offset + DB_STORE_OFFSET_PEER_IDENTITY_ADDRESS_IS_PUBLIC);
} }
@ -286,7 +286,7 @@ void FileSecurityDb::set_entry_peer_csrk(
entry->flags.csrk_stored = true; entry->flags.csrk_stored = true;
tr_info("Write DB entry %d: peer csrk %s", get_index(db_handle), tr_as_array(csrk)); tr_info("Write DB entry %d: peer csrk %s", get_index(db_handle), to_string(csrk));
db_write(&csrk, entry->file_offset + DB_STORE_OFFSET_PEER_SIGNING); db_write(&csrk, entry->file_offset + DB_STORE_OFFSET_PEER_SIGNING);
} }
@ -307,7 +307,7 @@ void FileSecurityDb::set_local_csrk(
{ {
this->SecurityDb::set_local_csrk(csrk); this->SecurityDb::set_local_csrk(csrk);
tr_info("Write DB: local csrk %s", tr_as_array(csrk)); tr_info("Write DB: local csrk %s", to_string(csrk));
db_write(&_local_csrk, DB_OFFSET_LOCAL_CSRK); db_write(&_local_csrk, DB_OFFSET_LOCAL_CSRK);
} }
@ -319,7 +319,7 @@ void FileSecurityDb::set_local_identity(
{ {
this->SecurityDb::set_local_identity(irk, identity_address, public_address); this->SecurityDb::set_local_identity(irk, identity_address, public_address);
tr_info("Write DB: %s peer address %s", public_address? "public" : "private", tr_as_array(identity_address)); tr_info("Write DB: %s peer address %s", public_address? "public" : "private", to_string(identity_address));
db_write(&_local_identity, DB_OFFSET_LOCAL_IDENTITY); db_write(&_local_identity, DB_OFFSET_LOCAL_IDENTITY);
} }

View File

@ -150,7 +150,7 @@ void KVStoreSecurityDb::set_entry_local_ltk(
SecurityEntryKeys_t* current_entry = read_in_entry_local_keys(db_handle); SecurityEntryKeys_t* current_entry = read_in_entry_local_keys(db_handle);
current_entry->ltk = ltk; current_entry->ltk = ltk;
tr_info("Write DB entry %d: local ltk %s", get_index(db_handle), tr_as_array(ltk)); tr_info("Write DB entry %d: local ltk %s", get_index(db_handle), to_string(ltk));
db_write_entry(current_entry, DB_ENTRY_LOCAL_KEYS, get_index(entry)); db_write_entry(current_entry, DB_ENTRY_LOCAL_KEYS, get_index(entry));
} }
@ -169,7 +169,7 @@ void KVStoreSecurityDb::set_entry_local_ediv_rand(
current_entry->ediv = ediv; current_entry->ediv = ediv;
current_entry->rand = rand; current_entry->rand = rand;
tr_info("Write DB entry %d: local ediv %s rand %s", get_index(db_handle), tr_as_array(ediv), tr_as_array(rand)); tr_info("Write DB entry %d: local ediv %s rand %s", get_index(db_handle), to_string(ediv), to_string(rand));
db_write_entry(current_entry, DB_ENTRY_LOCAL_KEYS, get_index(entry)); db_write_entry(current_entry, DB_ENTRY_LOCAL_KEYS, get_index(entry));
} }
@ -192,7 +192,7 @@ void KVStoreSecurityDb::set_entry_peer_ltk(
SecurityEntryKeys_t* current_entry = read_in_entry_peer_keys(db_handle); SecurityEntryKeys_t* current_entry = read_in_entry_peer_keys(db_handle);
current_entry->ltk = ltk; current_entry->ltk = ltk;
tr_info("Write DB entry %d: peer ltk %s", get_index(db_handle), tr_as_array(ltk)); tr_info("Write DB entry %d: peer ltk %s", get_index(db_handle), to_string(ltk));
db_write_entry(current_entry, DB_ENTRY_PEER_KEYS, get_index(entry)); db_write_entry(current_entry, DB_ENTRY_PEER_KEYS, get_index(entry));
} }
@ -211,7 +211,7 @@ void KVStoreSecurityDb::set_entry_peer_ediv_rand(
current_entry->ediv = ediv; current_entry->ediv = ediv;
current_entry->rand = rand; current_entry->rand = rand;
tr_info("Write DB entry %d: peer ediv %s rand %s", get_index(db_handle), tr_as_array(ediv), tr_as_array(rand)); tr_info("Write DB entry %d: peer ediv %s rand %s", get_index(db_handle), to_string(ediv), to_string(rand));
db_write_entry(current_entry, DB_ENTRY_PEER_KEYS, get_index(entry)); db_write_entry(current_entry, DB_ENTRY_PEER_KEYS, get_index(entry));
} }
@ -230,7 +230,7 @@ void KVStoreSecurityDb::set_entry_peer_irk(
SecurityEntryIdentity_t* current_entry = read_in_entry_peer_identity(db_handle); SecurityEntryIdentity_t* current_entry = read_in_entry_peer_identity(db_handle);
current_entry->irk = irk; current_entry->irk = irk;
tr_info("Write DB entry %d: peer irk %s", get_index(db_handle), tr_as_array(irk)); tr_info("Write DB entry %d: peer irk %s", get_index(db_handle), to_string(irk));
db_write_entry(current_entry, DB_ENTRY_PEER_IDENTITY, get_index(entry)); db_write_entry(current_entry, DB_ENTRY_PEER_IDENTITY, get_index(entry));
} }
@ -249,7 +249,7 @@ void KVStoreSecurityDb::set_entry_peer_bdaddr(
current_entry->identity_address = peer_address; current_entry->identity_address = peer_address;
current_entry->identity_address_is_public = address_is_public; current_entry->identity_address_is_public = address_is_public;
tr_info("Write DB entry %d: %s peer address %s", get_index(db_handle), address_is_public? "public" : "private", tr_as_array(peer_address)); tr_info("Write DB entry %d: %s peer address %s", get_index(db_handle), address_is_public? "public" : "private", to_string(peer_address));
db_write_entry(current_entry, DB_ENTRY_PEER_IDENTITY, get_index(entry)); db_write_entry(current_entry, DB_ENTRY_PEER_IDENTITY, get_index(entry));
} }
@ -268,7 +268,7 @@ void KVStoreSecurityDb::set_entry_peer_csrk(
SecurityEntrySigning_t* current_entry = read_in_entry_peer_signing(db_handle); SecurityEntrySigning_t* current_entry = read_in_entry_peer_signing(db_handle);
current_entry->csrk = csrk; current_entry->csrk = csrk;
tr_info("Write DB entry %d: peer csrk %s", get_index(db_handle), tr_as_array(csrk)); tr_info("Write DB entry %d: peer csrk %s", get_index(db_handle), to_string(csrk));
db_write_entry(current_entry, DB_ENTRY_PEER_SIGNING, get_index(entry)); db_write_entry(current_entry, DB_ENTRY_PEER_SIGNING, get_index(entry));
} }
@ -288,7 +288,7 @@ void KVStoreSecurityDb::set_local_csrk(
) )
{ {
this->SecurityDb::set_local_csrk(csrk); this->SecurityDb::set_local_csrk(csrk);
tr_info("Write DB: local csrk %s", tr_as_array(csrk)); tr_info("Write DB: local csrk %s", to_string(csrk));
db_write(&_local_csrk, DB_LOCAL_CSRK); db_write(&_local_csrk, DB_LOCAL_CSRK);
} }
@ -299,7 +299,7 @@ void KVStoreSecurityDb::set_local_identity(
) )
{ {
this->SecurityDb::set_local_identity(irk, identity_address, public_address); this->SecurityDb::set_local_identity(irk, identity_address, public_address);
tr_info("Write DB: %s peer address %s", public_address? "public" : "private", tr_as_array(identity_address)); tr_info("Write DB: %s peer address %s", public_address? "public" : "private", to_string(identity_address));
db_write(&_local_identity, DB_LOCAL_IDENTITY); db_write(&_local_identity, DB_LOCAL_IDENTITY);
} }

View File

@ -76,7 +76,7 @@ public:
) override { ) override {
entry_t *entry = as_entry(db_handle); entry_t *entry = as_entry(db_handle);
if (entry) { if (entry) {
tr_info("Write DB entry %d: local ltk %s", get_index(db_handle), tr_as_array(ltk)); tr_info("Write DB entry %d: local ltk %s", get_index(db_handle), to_string(ltk));
entry->flags.ltk_sent = true; entry->flags.ltk_sent = true;
entry->local_keys.ltk = ltk; entry->local_keys.ltk = ltk;
} }
@ -89,7 +89,7 @@ public:
) override { ) override {
entry_t *entry = as_entry(db_handle); entry_t *entry = as_entry(db_handle);
if (entry) { if (entry) {
tr_info("Write DB entry %d: local ediv %s rand %s", get_index(db_handle), tr_as_array(ediv), tr_as_array(rand)); tr_info("Write DB entry %d: local ediv %s rand %s", get_index(db_handle), to_string(ediv), to_string(rand));
entry->local_keys.ediv = ediv; entry->local_keys.ediv = ediv;
entry->local_keys.rand = rand; entry->local_keys.rand = rand;
} }
@ -105,7 +105,7 @@ public:
) override { ) override {
entry_t *entry = as_entry(db_handle); entry_t *entry = as_entry(db_handle);
if (entry) { if (entry) {
tr_info("Write DB entry %d: peer ltk %s", get_index(db_handle), tr_as_array(ltk)); tr_info("Write DB entry %d: peer ltk %s", get_index(db_handle), to_string(ltk));
entry->peer_keys.ltk = ltk; entry->peer_keys.ltk = ltk;
entry->flags.ltk_stored = true; entry->flags.ltk_stored = true;
} }
@ -118,7 +118,7 @@ public:
) override { ) override {
entry_t *entry = as_entry(db_handle); entry_t *entry = as_entry(db_handle);
if (entry) { if (entry) {
tr_info("Write DB entry %d: peer ediv %s rand %s", get_index(db_handle), tr_as_array(ediv), tr_as_array(rand)); tr_info("Write DB entry %d: peer ediv %s rand %s", get_index(db_handle), to_string(ediv), to_string(rand));
entry->peer_keys.ediv = ediv; entry->peer_keys.ediv = ediv;
entry->peer_keys.rand = rand; entry->peer_keys.rand = rand;
} }
@ -130,7 +130,7 @@ public:
) override { ) override {
entry_t *entry = as_entry(db_handle); entry_t *entry = as_entry(db_handle);
if (entry) { if (entry) {
tr_info("Write DB entry %d: peer irk %s", get_index(db_handle), tr_as_array(irk)); tr_info("Write DB entry %d: peer irk %s", get_index(db_handle), to_string(irk));
entry->peer_identity.irk = irk; entry->peer_identity.irk = irk;
entry->flags.irk_stored = true; entry->flags.irk_stored = true;
} }
@ -143,7 +143,7 @@ public:
) override { ) override {
entry_t *entry = as_entry(db_handle); entry_t *entry = as_entry(db_handle);
if (entry) { if (entry) {
tr_info("Write DB entry %d: %s peer address %s", get_index(db_handle), address_is_public? "public" : "private", tr_as_array(peer_address)); tr_info("Write DB entry %d: %s peer address %s", get_index(db_handle), address_is_public? "public" : "private", to_string(peer_address));
entry->peer_identity.identity_address = peer_address; entry->peer_identity.identity_address = peer_address;
entry->peer_identity.identity_address_is_public = address_is_public; entry->peer_identity.identity_address_is_public = address_is_public;
} }
@ -155,7 +155,7 @@ public:
) override { ) override {
entry_t *entry = as_entry(db_handle); entry_t *entry = as_entry(db_handle);
if (entry) { if (entry) {
tr_info("Write DB entry %d: peer csrk %s", get_index(db_handle), tr_as_array(csrk)); tr_info("Write DB entry %d: peer csrk %s", get_index(db_handle), to_string(csrk));
entry->flags.csrk_stored = true; entry->flags.csrk_stored = true;
entry->peer_signing.csrk = csrk; entry->peer_signing.csrk = csrk;
} }