diff --git a/pkg/nimble/addr/nimble_addr.c b/pkg/nimble/addr/nimble_addr.c index 6b534d9122dc..d2dc1dd2fb1c 100644 --- a/pkg/nimble/addr/nimble_addr.c +++ b/pkg/nimble/addr/nimble_addr.c @@ -33,7 +33,9 @@ void nimble_addr_print(const ble_addr_t *addr) void nimble_addr_sprint(char *buf, const ble_addr_t *addr) { - bluetil_addr_sprint(buf, addr->val); + uint8_t addrn[BLE_ADDR_LEN]; + bluetil_addr_swapped_cp(addr->val, addrn); + bluetil_addr_sprint(buf, addrn); const char *type; switch (addr->type) { case BLE_ADDR_PUBLIC: type = " (public) "; break; @@ -43,5 +45,5 @@ void nimble_addr_sprint(char *buf, const ble_addr_t *addr) default: type = " (unknown)"; break; } memcpy(&buf[BLUETIL_ADDR_STRLEN - 1], type, 10); - buf[BLUETIL_ADDR_STRLEN - 1] = '\0'; + buf[NIMBLE_ADDR_STRLEN - 1] = '\0'; } diff --git a/pkg/nimble/scanlist/nimble_scanlist_print.c b/pkg/nimble/scanlist/nimble_scanlist_print.c index b594e6f5d042..edbecad599e7 100644 --- a/pkg/nimble/scanlist/nimble_scanlist_print.c +++ b/pkg/nimble/scanlist/nimble_scanlist_print.c @@ -23,24 +23,10 @@ #include #include "net/bluetil/ad.h" +#include "nimble_addr.h" #include "nimble_scanlist.h" #include "nimble/hci_common.h" -static void _print_addr(const ble_addr_t *addr) -{ - printf("%02x", (int)addr->val[5]); - for (int i = 4; i >= 0; i--) { - printf(":%02x", addr->val[i]); - } - switch (addr->type) { - case BLE_ADDR_PUBLIC: printf(" (PUBLIC)"); break; - case BLE_ADDR_RANDOM: printf(" (RANDOM)"); break; - case BLE_ADDR_PUBLIC_ID: printf(" (PUB_ID)"); break; - case BLE_ADDR_RANDOM_ID: printf(" (RAND_ID)"); break; - default: printf(" (UNKNOWN)"); break; - } -} - static void _print_type(uint8_t type) { switch (type) { @@ -92,7 +78,7 @@ void nimble_scanlist_print_entry(nimble_scanlist_entry_t *e) strncpy(name, "undefined", sizeof(name)); } - _print_addr(&e->addr); + nimble_addr_print(&e->addr); _print_type(e->type); unsigned adv_int = ((e->last_update - e->first_update) / e->adv_msg_cnt); printf(" \"%s\", adv_msg_cnt: %u, adv_int: %uus, last_rssi: %i\n",