core: Add bt_str2ba() to bluetooth.h
authorClaudio Takahasi <claudio.takahasi@openbossa.org>
Tue, 12 Mar 2013 12:42:05 +0000 (09:42 -0300)
committerDenis Kenzior <denkenz@gmail.com>
Mon, 18 Mar 2013 19:00:15 +0000 (14:00 -0500)
This patch adds a utility Bluetooth function to convert Bluetooth
address from string to bdaddr_t.

src/bluetooth.h
src/handsfree-audio.c

index 15841097700f36805afe8940a734d05ec87eb222..af6f02c18f33148cc4cf0635889c92fe49dc1a24 100644 (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);
+}
index 13f7c221180b3d048757dd66492c7b49a56da1f6..d96c7c4a2dfe65e1303b5f59e35df9729ebfe748 100644 (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>