Skip to contentSkip to conversation

android: Add initial HID connect implementation

PATCH New Ravi kumar Veeramally 1 participant 2 messages Oct 29, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 android: Add initial HID connect implementation

Implemented basic HID connect method. Host connects to bt device at L2CAP level.
---
v2: Updated patches as per Luiz comments

v1: Patchset adds hid connect and disconnect mechanisms at
L2CAP level. It opens the control channel and interrupt channel and listens on io events. UHID, hid server and reconnect related features not yet done.

---
 Makefile.android   |    3 +-
 android/Android.mk |    1 +
 android/hid.c      |  245 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 248 insertions(+), 1 deletion(-)
Makefile.android +2 -1
index 2b57daa..22002be 100644
@@ -12,7 +12,8 @@ android_bluetoothd_SOURCES =	android/main.c \
 				android/adapter.h android/adapter.c \
 				android/hid.h android/hid.c \
 				android/ipc.h android/ipc.c \
-				android/socket.h android/socket.c
+				android/socket.h android/socket.c \
+				btio/btio.h btio/btio.c
 
 android_bluetoothd_LDADD = lib/libbluetooth-internal.la @GLIB_LIBS@
 
android/Android.mk +1 -0
index 22208e0..28ec465 100644
@@ -28,6 +28,7 @@ LOCAL_SRC_FILES := \
 	../lib/sdp.c \
 	../lib/bluetooth.c \
 	../lib/hci.c \
+	../btio/btio.c
 
 LOCAL_C_INCLUDES := \
 	$(call include-path-for, glib) \
android/hid.c +245 -0

267 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#1 lore raw

PATCH 2/2 android: Add initial HID disconnect implementation.

Implemented basic HID disconnect method. Host disconnects with bt device at L2CAP level.

---
 android/hid.c |   23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
android/hid.c +23 -0
index 7f9e386..0a26bfe 100644
@@ -278,6 +278,28 @@ static uint8_t bt_hid_connect(struct hal_cmd_hid_connect *cmd, uint16_t len)
 	return HAL_STATUS_SUCCESS;
 }
 
+static uint8_t bt_hid_disconnect(struct hal_cmd_hid_disconnect *cmd,
+								uint16_t len)
+{
+	GSList *l;
+	bdaddr_t dst;
+
+	DBG("");
+
+	if (len < sizeof(*cmd))
+		return HAL_STATUS_INVALID;
+
+	android2bdaddr((bdaddr_t *)&cmd->bdaddr, &dst);
+
+	l = g_slist_find_custom(devices, &dst, device_cmp);
+	if (!l)
+		return HAL_STATUS_FAILED;
+
+	hid_device_free(l->data);
+
+	return HAL_STATUS_SUCCESS;
+}
+
 void bt_hid_handle_cmd(GIOChannel *io, uint8_t opcode, void *buf, uint16_t len)
 {
 	uint8_t status = HAL_STATUS_FAILED;
@@ -287,6 +309,7 @@ void bt_hid_handle_cmd(GIOChannel *io, uint8_t opcode, void *buf, uint16_t len)
 		status = bt_hid_connect(buf, len);
 		break;
 	case HAL_OP_HID_DISCONNECT:
+		status = bt_hid_disconnect(buf,	len);
 		break;
 	default:
 		DBG("Unhandled command, opcode 0x%x", opcode);
Signature · 1 line
1.7.9.5