The library function batostr() computes incorrect results because it does not swap byte-ordering before converting the address. This patch fixes this behaviour. It tries to make batostr() look like ba2str() to be consistent. Patch is also attached as x-patch file. Patch is done against most recent git version. diff --git a/lib/bluetooth.c b/lib/bluetooth.c index 4af2ef6..dd7ca06 100644 --- a/lib/bluetooth.c +++ b/lib/bluetooth.c @@ -50,13 +50,14 @@ void baswap(bdaddr_t *dst, const bdaddr_t *src) char *batostr(const bdaddr_t *ba) { + uint8_t b[6]; char *str = bt_malloc(18); if (!str) return NULL; + baswap((bdaddr_t *) b, ba); sprintf(str, "%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X", - ba->b[0], ba->b[1], ba->b[2], - ba->b[3], ba->b[4], ba->b[5]); + b[0], b[1], b[2], b[3], b[4], b[5]); return str; }
diff --git a/lib/bluetooth.c b/lib/bluetooth.c index 4af2ef6..dd7ca06 100644 --- a/lib/bluetooth.c +++ b/lib/bluetooth.c @@ -50,13 +50,14 @@ void baswap(bdaddr_t *dst, const bdaddr_t *src) char *batostr(const bdaddr_t *ba) { + uint8_t b[6]; char *str = bt_malloc(18); if (!str) return NULL; + baswap((bdaddr_t *) b, ba); sprintf(str, "%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X", - ba->b[0], ba->b[1], ba->b[2], - ba->b[3], ba->b[4], ba->b[5]); + b[0], b[1], b[2], b[3], b[4], b[5]); return str; }