diff --git a/lib/bluetooth.c b/lib/bluetooth.c
index a1b4c13..72ee456 100644
--- a/lib/bluetooth.c
+++ b/lib/bluetooth.c
bdaddr_t *strtoba(const char *str)
{
- const char *ptr = str;
- int i;
-
- uint8_t *ba = bt_malloc(sizeof(bdaddr_t));
- if (!ba)
- return NULL;
+ bdaddr_t b;
+ bdaddr_t *ba = bt_malloc(sizeof(*ba));
- for (i = 0; i < 6; i++) {
- ba[i] = (uint8_t) strtol(ptr, NULL, 16);
- if (i != 5 && !(ptr = strchr(ptr,':')))
- ptr = ":00:00:00:00:00";
- ptr++;
+ if (ba) {
+ str2ba(str, &b);
+ baswap(ba, &b);
}
- return (bdaddr_t *) ba;
+ return ba;
}
int ba2str(const bdaddr_t *ba, char *str)