Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add support for ba2str and str2ba to bluedroid.

Add missing structs from hci.h.

Change-Id: I4cebb3136cd832d5b61f4cd70bcf4504238e2531
  • Loading branch information...
commit a15c33f9aaf27f75a7f6fa02a539b54caace4d35 1 parent d439786
Nick Pelly authored
View
14 bluedroid/bluetooth.c
@@ -255,3 +255,17 @@ int bt_is_enabled() {
if (hci_sock >= 0) close(hci_sock);
return ret;
}
+
+int ba2str(const bdaddr_t *ba, char *str) {
+ return sprintf(str, "%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X",
+ ba->b[5], ba->b[4], ba->b[3], ba->b[2], ba->b[1], ba->b[0]);
+}
+
+int str2ba(const char *str, bdaddr_t *ba) {
+ int i;
+ for (i = 5; i >= 0; i--) {
+ ba->b[i] = (uint8_t) strtoul(str, &str, 16);
+ str++;
+ }
+ return 0;
+}
View
4 bluedroid/include/bluedroid/bluetooth.h
@@ -19,6 +19,7 @@
#ifdef __cplusplus
extern "C" {
#endif
+#include <bluetooth/bluetooth.h>
/* Enable the bluetooth interface.
*
@@ -41,6 +42,9 @@ int bt_disable();
/* Returns 1 if enabled, 0 if disabled, and -ve on error */
int bt_is_enabled();
+int ba2str(const bdaddr_t *ba, char *str);
+int str2ba(const char *str, bdaddr_t *ba);
+
#ifdef __cplusplus
}
#endif
View
14 bluez-clean-headers/bluetooth/hci.h
@@ -15,6 +15,7 @@
#ifdef __cplusplus
#endif
#include <sys/socket.h>
+#include <sys/ioctl.h>
#define HCI_MAX_DEV 16
#define HCI_MAX_ACL_SIZE 1024
#define HCI_MAX_SCO_SIZE 255
@@ -679,4 +680,17 @@ struct sockaddr_hci {
sa_family_t hci_family;
unsigned short hci_dev;
};
+struct hci_conn_info {
+ uint16_t handle;
+ bdaddr_t bdaddr;
+ uint8_t type;
+ uint8_t out;
+ uint16_t state;
+ uint32_t link_mode;
+};
+struct hci_conn_list_req {
+ uint16_t dev_id;
+ uint16_t conn_num;
+ struct hci_conn_info conn_info[0];
+};
#endif
View
4 tools/Android.mk
@@ -10,7 +10,9 @@ include $(CLEAR_VARS)
LOCAL_SRC_FILES := bttest.c
-LOCAL_C_INCLUDES := $(LOCAL_PATH)/../bluedroid/include
+LOCAL_C_INCLUDES := \
+ $(LOCAL_PATH)/../bluedroid/include \
+ system/bluetooth/bluez-clean-headers
LOCAL_SHARED_LIBRARIES := libbluedroid
Please sign in to comment.
Something went wrong with that request. Please try again.