mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-12-25 06:23:53 +01:00
Merge pull request #16859 from haukepetersen/fix_nimble_addr_byteorder
nimble/addr|scanlist: fix nimble_addr_sprint() and use in nimble_scanlist_print()
This commit is contained in:
commit
bcb46460b7
@ -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';
|
||||
}
|
||||
|
||||
@ -23,24 +23,10 @@
|
||||
#include <assert.h>
|
||||
|
||||
#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",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user