core: Add bt_str2ba() to bluetooth.h

This patch adds a utility Bluetooth function to convert Bluetooth
address from string to bdaddr_t.
This commit is contained in:
Claudio Takahasi 2013-03-12 09:42:05 -03:00 committed by Denis Kenzior
parent afb4470558
commit 5d0ba72d04
2 changed files with 9 additions and 0 deletions

View File

@ -69,3 +69,11 @@ static inline int bt_bacmp(const bdaddr_t *ba1, const bdaddr_t *ba2)
{
return memcmp(ba1, ba2, sizeof(bdaddr_t));
}
static inline void bt_str2ba(const char *str, bdaddr_t *ba)
{
int i;
for (i = 5; i >= 0; i--, str += 3)
ba->b[i] = strtol(str, NULL, 16);
}

View File

@ -26,6 +26,7 @@
#include <errno.h>
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <unistd.h>