Skip to contentSkip to conversation

android/hal-pan: Add implementation of .init

PATCH In review Luiz Augusto von Dentz 2 participants 6 messages Oct 28, 2013 Bluetooth drivers

lore
Share & tools
lore

Luiz Augusto von Dentz

author maintainer
#0 lore raw

PATCH 1/5 android/hal-pan: Add implementation of .init

From: Luiz Augusto von Dentz <[email protected]>

---
 android/hal-pan.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
android/hal-pan.c +7 -4
index 609bc1c..62fec00 100644
@@ -20,6 +20,8 @@
 
 #include "hal-log.h"
 #include "hal.h"
+#include "hal-msg.h"
+#include "hal-ipc.h"
 
 static const btpan_callbacks_t *cbs = NULL;
 
@@ -77,15 +79,16 @@ static bt_status_t pan_disconnect(const bt_bdaddr_t *bd_addr)
 
 static bt_status_t pan_init(const btpan_callbacks_t *callbacks)
 {
+	struct hal_cmd_register_module cmd;
+
 	DBG("");
 
 	cbs = callbacks;
 
-	/* TODO: start HID Host thread */
-
-	/* TODO: enable service */
+	cmd.service_id = HAL_SERVICE_ID_PAN;
 
-	return BT_STATUS_SUCCESS;
+	return hal_ipc_cmd(HAL_SERVICE_ID_CORE, HAL_OP_REGISTER_MODULE,
+					sizeof(cmd), &cmd, 0, NULL, NULL);
 }
 
 static void pan_cleanup()
Signature · 1 line
1.8.3.1
author maintainer
#1 lore raw

PATCH 2/5 android/hal-pan: Add implementation of .enable

From: Luiz Augusto von Dentz <[email protected]>

---
 android/hal-msg.h | 7 +++++++
 android/hal-pan.c | 7 ++++++-
 2 files changed, 13 insertions(+), 1 deletion(-)
android/hal-msg.h +7 -0
index a0a8390..0987eec 100644
@@ -290,6 +290,13 @@ struct hal_cmd_av_disconnect {
 	uint8_t bdaddr[6];
 } __attribute__((packed));
 
+/* PAN HAL API */
+
+#define HAL_OP_PAN_ENABLE	0x01
+struct hal_cmd_pan_enable {
+	uint8_t local_role;
+} __attribute__((packed));
+
 /* Notifications and confirmations */
 
 
android/hal-pan.c +6 -1
index 62fec00..8fb2563 100644
@@ -32,12 +32,17 @@ static bool interface_ready(void)
 
 static bt_status_t pan_enable(int local_role)
 {
+	struct hal_cmd_pan_enable cmd;
+
 	DBG("");
 
 	if (!interface_ready())
 		return BT_STATUS_NOT_READY;
 
-	return BT_STATUS_UNSUPPORTED;
+	cmd.local_role = local_role;
+
+	return hal_ipc_cmd(HAL_SERVICE_ID_PAN, HAL_OP_PAN_ENABLE,
+					sizeof(cmd), &cmd, 0, NULL, NULL);
 }
 
 static int pan_get_local_role(void)
Signature · 1 line
1.8.3.1
author maintainer
#2 lore raw

PATCH 3/5 android/hal-pan: Add implementation of .get_local_role

In reply to Luiz Augusto von Dentz

From: Luiz Augusto von Dentz <[email protected]>

---
 android/hal-msg.h |  5 +++++
 android/hal-pan.c | 11 ++++++++++-
 2 files changed, 15 insertions(+), 1 deletion(-)
android/hal-msg.h +5 -0
index 0987eec..350cec1 100644
@@ -297,6 +297,11 @@ struct hal_cmd_pan_enable {
 	uint8_t local_role;
 } __attribute__((packed));
 
+#define HAL_OP_PAN_GET_ROLE	0x02
+struct hal_rsp_pan_get_role {
+	uint8_t local_role;
+} __attribute__((packed));
+
 /* Notifications and confirmations */
 
 
android/hal-pan.c +10 -1
index 8fb2563..c8dcdec 100644
@@ -47,12 +47,21 @@ static bt_status_t pan_enable(int local_role)
 
 static int pan_get_local_role(void)
 {
+	struct hal_rsp_pan_get_role rsp;
+	size_t len = sizeof(rsp);
+	bt_status_t status;
+
 	DBG("");
 
 	if (!interface_ready())
 		return BTPAN_ROLE_NONE;
 
-	return BTPAN_ROLE_NONE;
+	status = hal_ipc_cmd(HAL_SERVICE_ID_PAN, HAL_OP_PAN_GET_ROLE, 0, NULL,
+							&len, &rsp, NULL);
+	if (status != BT_STATUS_SUCCESS)
+		return BTPAN_ROLE_NONE;
+
+	return rsp.local_role;
 }
 
 static bt_status_t pan_connect(const bt_bdaddr_t *bd_addr, int local_role,
Signature · 1 line
1.8.3.1
author maintainer
#3 lore raw

PATCH 4/5 android/hal-pan: Add implementation of .connect

In reply to Luiz Augusto von Dentz

From: Luiz Augusto von Dentz <[email protected]>

---
 android/hal-msg.h |  7 +++++++
 android/hal-pan.c | 11 ++++++++---
 2 files changed, 15 insertions(+), 3 deletions(-)
android/hal-msg.h +7 -0
index 350cec1..65f60dc 100644
@@ -302,6 +302,13 @@ struct hal_rsp_pan_get_role {
 	uint8_t local_role;
 } __attribute__((packed));
 
+#define HAL_OP_PAN_CONNECT	0x03
+struct hal_cmd_pan_connect {
+	uint8_t bdaddr[6];
+	uint8_t local_role;
+	uint8_t remote_role;
+} __attribute__((packed));
+
 /* Notifications and confirmations */
 
 
android/hal-pan.c +8 -3
index c8dcdec..3e23eb5 100644
@@ -17,6 +17,7 @@
 
 #include <stdbool.h>
 #include <stddef.h>
+#include <string.h>
 
 #include "hal-log.h"
 #include "hal.h"
@@ -67,15 +68,19 @@ static int pan_get_local_role(void)
 static bt_status_t pan_connect(const bt_bdaddr_t *bd_addr, int local_role,
 					int remote_role)
 {
+	struct hal_cmd_pan_connect cmd;
+
 	DBG("");
 
 	if (!interface_ready())
 		return BT_STATUS_NOT_READY;
 
-	if (!bd_addr)
-		return BT_STATUS_PARM_INVALID;
+	memcpy(cmd.bdaddr, bd_addr, sizeof(cmd.bdaddr));
+	cmd.local_role = local_role;
+	cmd.remote_role = remote_role;
 
-	return BT_STATUS_UNSUPPORTED;
+	return hal_ipc_cmd(HAL_SERVICE_ID_PAN, HAL_OP_PAN_CONNECT,
+					sizeof(cmd), &cmd, 0, NULL, NULL);
 }
 
 static bt_status_t pan_disconnect(const bt_bdaddr_t *bd_addr)
Signature · 1 line
1.8.3.1
author maintainer
#4 lore raw

PATCH 5/5 android/hal-pan: Add implementation of .disconnect

In reply to Luiz Augusto von Dentz

From: Luiz Augusto von Dentz <[email protected]>

---
 android/hal-msg.h | 5 +++++
 android/hal-pan.c | 8 +++++---
 2 files changed, 10 insertions(+), 3 deletions(-)
android/hal-msg.h +5 -0
index 65f60dc..bba031c 100644
@@ -309,6 +309,11 @@ struct hal_cmd_pan_connect {
 	uint8_t remote_role;
 } __attribute__((packed));
 
+#define HAL_OP_PAN_DISCONNECT	0x04
+struct hal_cmd_pan_disconnect {
+	uint8_t bdaddr[6];
+} __attribute__((packed));
+
 /* Notifications and confirmations */
 
 
android/hal-pan.c +5 -3
index 3e23eb5..cacc6c0 100644
@@ -85,15 +85,17 @@ static bt_status_t pan_connect(const bt_bdaddr_t *bd_addr, int local_role,
 
 static bt_status_t pan_disconnect(const bt_bdaddr_t *bd_addr)
 {
+	struct hal_cmd_pan_disconnect cmd;
+
 	DBG("");
 
 	if (!interface_ready())
 		return BT_STATUS_NOT_READY;
 
-	if (!bd_addr)
-		return BT_STATUS_PARM_INVALID;
+	memcpy(cmd.bdaddr, bd_addr, sizeof(cmd.bdaddr));
 
-	return BT_STATUS_UNSUPPORTED;
+	return hal_ipc_cmd(HAL_SERVICE_ID_PAN, HAL_OP_PAN_DISCONNECT,
+					sizeof(cmd), &cmd, 0, NULL, NULL);
 }
 
 static bt_status_t pan_init(const btpan_callbacks_t *callbacks)
Signature · 1 line
1.8.3.1