Skip to contentSkip to conversation

Add HDP profile support at HAL side

PATCH In review Ravi kumar Veeramally 2 participants 17 messages Mar 13, 2014 – Mar 14, 2014 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

cover Add HDP profile support at HAL side

v2: Solved Luiz, Szymon, Andrzej and Grzegorz comments.

v1: Patch set contains HDP profile support at HAL side and initial profile registration support at daemon side.

Ravi kumar Veeramally (15):
android/hal-msg: Add HDP app registration struct android/hal-msg: Add HDP app unregistration struct android/hal-msg: Add HDP connect channel struct android/hal-msg: Add HDP destroy channel struct android/hal-msg: Add HDP app registration state event struct android/hal-msg: Add HDP app channel state event struct android/hal-health: Add hal-health.c with initial get interface call android/hal-health: Add HDP .init method android/hal-health: Add HDP .cleanup method android/hal-health: Add HDP .register_application method android/hal-health: Add HDP .unregister_application method android/hal-health: Add HDP .connect_channel method android/hal-health: Add HDP .destroy_channel method android/hal-health: Add app state and channel state event handlers android/health: Add health.c|h file with basic calls

 android/Android.mk      |   2 +
 android/Makefile.am     |   2 +
 android/hal-bluetooth.c |   3 +
 android/hal-health.c    | 283 ++++++++++++++++++++++++++++++++++++++++++++++++
 android/hal-msg.h       |  72 ++++++++++++
 android/hal.h           |   2 +
 android/health.c        | 115 ++++++++++++++++++++
 android/health.h        |  25 +++++
 android/main.c          |  11 ++
 9 files changed, 515 insertions(+)
 create mode 100644 android/hal-health.c
 create mode 100644 android/health.c
 create mode 100644 android/health.h
Signature · 1 line
1.8.3.2
#1 lore raw

PATCH 1/15 android/hal-msg: Add HDP app registration struct

---
 android/hal-msg.h | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
android/hal-msg.h +25 -0
index 0abbbe6..0c63216 100644
@@ -383,6 +383,31 @@ struct hal_cmd_pan_disconnect {
 	uint8_t bdaddr[6];
 } __attribute__((packed));
 
+struct hal_string {
+	uint8_t len;
+	uint8_t data[0];
+};
+
+#define HAL_OP_HEALTH_REG_APP		0x01
+struct hal_cmd_health_reg_app {
+	struct hal_string app_name;
+	struct hal_string provider_name;
+	struct hal_string service_name;
+	struct hal_string service_descr;
+	uint8_t num_of_mdep;
+
+	struct {
+		uint8_t role;
+		uint8_t data_type;
+		uint8_t channel_type;
+		struct  hal_string descr;
+	} mdep_cfg[0];
+} __attribute__((packed));
+
+struct hal_rsp_health_reg_app {
+	uint16_t app_id;
+} __attribute__((packed));
+
 /* Handsfree HAL API */
 
 #define HAL_MODE_HANDSFREE_HSP_ONLY		0x01
Signature · 1 line
1.8.3.2
#2 lore raw

PATCH 2/15 android/hal-msg: Add HDP app unregistration struct

In reply to Ravi kumar Veeramally
---
 android/hal-msg.h | 4 ++++
 1 file changed, 4 insertions(+)
android/hal-msg.h +4 -0
index 0c63216..77c2757 100644
@@ -1071,6 +1071,10 @@ struct hal_ev_handsfree_chld {
 	uint8_t chld;
 } __attribute__((packed));
 
+#define HAL_OP_HEALTH_UNREG_APP		0x02
+struct hal_cmd_health_unreg_app {
+	uint16_t app_id;
+} __attribute__((packed));
 
 #define HAL_EV_HANDSFREE_CNUM		0x8B
 
Signature · 1 line
1.8.3.2
#3 lore raw

PATCH 3/15 android/hal-msg: Add HDP connect channel struct

In reply to Ravi kumar Veeramally
---
 android/hal-msg.h | 11 +++++++++++
 1 file changed, 11 insertions(+)
android/hal-msg.h +11 -0
index 77c2757..2db87ac 100644
@@ -408,6 +408,17 @@ struct hal_rsp_health_reg_app {
 	uint16_t app_id;
 } __attribute__((packed));
 
+#define HAL_OP_HEALTH_CONNECT_CHANNEL	0x03
+struct hal_cmd_health_connect_channel {
+	uint16_t app_id;
+	uint8_t  bdaddr[6];
+	uint8_t  mdep_index;
+} __attribute__((packed));
+
+struct hal_rsp_health_connect_channel {
+	uint16_t  channel_id;
+} __attribute__((packed));
+
 /* Handsfree HAL API */
 
 #define HAL_MODE_HANDSFREE_HSP_ONLY		0x01
Signature · 1 line
1.8.3.2
#4 lore raw

PATCH 4/15 android/hal-msg: Add HDP destroy channel struct

In reply to Ravi kumar Veeramally
---
 android/hal-msg.h | 5 +++++
 1 file changed, 5 insertions(+)
android/hal-msg.h +5 -0
index 2db87ac..57069b3 100644
@@ -419,6 +419,11 @@ struct hal_rsp_health_connect_channel {
 	uint16_t  channel_id;
 } __attribute__((packed));
 
+#define HAL_OP_HEALTH_DESTROY_CHANNEL	0x04
+struct hal_cmd_health_destroy_channel {
+	uint16_t channel_id;
+} __attribute__((packed));
+
 /* Handsfree HAL API */
 
 #define HAL_MODE_HANDSFREE_HSP_ONLY		0x01
Signature · 1 line
1.8.3.2
#5 lore raw

PATCH 5/15 android/hal-msg: Add HDP app registration state event struct

In reply to Ravi kumar Veeramally
---
 android/hal-msg.h | 11 +++++++++++
 1 file changed, 11 insertions(+)
android/hal-msg.h +11 -0
index 57069b3..3f119de 100644
@@ -996,6 +996,17 @@ struct hal_ev_pan_conn_state {
 	uint8_t  remote_role;
 } __attribute__((packed));
 
+#define HAL_HEALTH_APP_REG_SUCCESS		0x00
+#define HAL_HEALTH_APP_REG_FAILED		0x01
+#define HAL_HEALTH_APP_DEREG_SUCCESS		0x02
+#define HAL_HEALTH_APP_DEREG_FAILED		0x03
+
+#define HAL_EV_HEALTH_APP_REG_STATE		0x81
+struct hal_ev_health_app_reg_state {
+	uint16_t id;
+	uint8_t  state;
+} __attribute__((packed));
+
 #define HAL_A2DP_STATE_DISCONNECTED		0x00
 #define HAL_A2DP_STATE_CONNECTING		0x01
 #define HAL_A2DP_STATE_CONNECTED		0x02
Signature · 1 line
1.8.3.2
#6 lore raw

PATCH 6/15 android/hal-msg: Add HDP app channel state event struct

In reply to Ravi kumar Veeramally
---
 android/hal-msg.h | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
android/hal-msg.h +16 -0
index 3f119de..0b8924e 100644
@@ -1001,12 +1001,28 @@ struct hal_ev_pan_conn_state {
 #define HAL_HEALTH_APP_DEREG_SUCCESS		0x02
 #define HAL_HEALTH_APP_DEREG_FAILED		0x03
 
+#define HAL_HEALTH_CHANNEL_CONNECTING		0x00
+#define HAL_HEALTH_CHANNEL_CONNECTED		0x01
+#define HAL_HEALTH_CHANNEL_DISCONNECTING	0x02
+#define HAL_HEALTH_CHANNEL_DISCONNECTED		0x03
+#define HAL_HEALTH_CHANNEL_DESTROYED		0x04
+
 #define HAL_EV_HEALTH_APP_REG_STATE		0x81
 struct hal_ev_health_app_reg_state {
 	uint16_t id;
 	uint8_t  state;
 } __attribute__((packed));
 
+#define HAL_EV_HEALTH_CHANNEL_STATE		0x82
+struct hal_ev_health_channel_state {
+	uint16_t app_id;
+	uint8_t  bdaddr[6];
+	uint8_t  mdep_index;
+	uint16_t channel_id;
+	uint8_t  channel_state;
+	uint32_t file_descr;
+} __attribute__((packed));
+
 #define HAL_A2DP_STATE_DISCONNECTED		0x00
 #define HAL_A2DP_STATE_CONNECTING		0x01
 #define HAL_A2DP_STATE_CONNECTED		0x02
Signature · 1 line
1.8.3.2
#7 lore raw

PATCH 7/15 android/hal-health: Add hal-health.c with initial get interface call

In reply to Ravi kumar Veeramally
---
 android/Android.mk      |  1 +
 android/Makefile.am     |  1 +
 android/hal-bluetooth.c |  3 +++
 android/hal-health.c    | 42 ++++++++++++++++++++++++++++++++++++++++++
 android/hal.h           |  2 ++
 5 files changed, 49 insertions(+)
 create mode 100644 android/hal-health.c
android/Android.mk +1 -0
index 49bf108..0352beb 100644
@@ -121,6 +121,7 @@ LOCAL_SRC_FILES := \
 	bluez/android/hal-handsfree.c \
 	bluez/android/hal-gatt.c \
 	bluez/android/hal-utils.c \
+	bluez/android/hal-health.c \
 
 LOCAL_C_INCLUDES += \
 	$(call include-path-for, system-core) \
android/Makefile.am +1 -0
index bbd3d2f..d2cfed6 100644
@@ -52,6 +52,7 @@ plugin_LTLIBRARIES += android/bluetooth.default.la
 android_bluetooth_default_la_SOURCES = android/hal.h android/hal-bluetooth.c \
 					android/hal-socket.c \
 					android/hal-hidhost.c \
+					android/hal-health.c \
 					android/hal-pan.c \
 					android/hal-a2dp.c \
 					android/hal-avrcp.c \
android/hal-bluetooth.c +3 -0
index 2bc089e..fcf02f6 100644
@@ -777,6 +777,9 @@ static const void *get_profile_interface(const char *profile_id)
 	if (!strcmp(profile_id, BT_PROFILE_GATT_ID))
 		return bt_get_gatt_interface();
 
+	if (!strcmp(profile_id, BT_PROFILE_HEALTH_ID))
+		return bt_get_health_interface();
+
 	return NULL;
 }
 
android/hal-health.c new file +42 -0

42 lines not on this page · raw message

android/hal.h +2 -0
index b1c0216..6998e9a 100644
@@ -25,6 +25,7 @@
 #include <hardware/bt_gatt.h>
 #include <hardware/bt_gatt_client.h>
 #include <hardware/bt_gatt_server.h>
+#include <hardware/bt_hl.h>
 
 btsock_interface_t *bt_get_socket_interface(void);
 bthh_interface_t *bt_get_hidhost_interface(void);
@@ -33,6 +34,7 @@ btav_interface_t *bt_get_a2dp_interface(void);
 btrc_interface_t *bt_get_avrcp_interface(void);
 bthf_interface_t *bt_get_handsfree_interface(void);
 btgatt_interface_t *bt_get_gatt_interface(void);
+bthl_interface_t *bt_get_health_interface(void);
 
 void bt_thread_associate(void);
 void bt_thread_disassociate(void);
Signature · 1 line
1.8.3.2
#8 lore raw

PATCH 8/15 android/hal-health: Add HDP .init method

In reply to Ravi kumar Veeramally
---
 android/hal-health.c | 43 ++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 42 insertions(+), 1 deletion(-)
android/hal-health.c +42 -1
index 59f8cca..d099ae2 100644
@@ -26,9 +26,50 @@
 #include "ipc-common.h"
 #include "hal-ipc.h"
 
+static const bthl_callbacks_t *cbacks = NULL;
+
+static bool interface_ready(void)
+{
+	return cbacks != NULL;
+}
+
+/* handlers will be called from notification thread context,
+ * index in table equals to 'opcode - HAL_MINIMUM_EVENT' */
+static const struct hal_ipc_handler ev_handlers[] = {
+};
+
+static bt_status_t init(bthl_callbacks_t *callbacks)
+{
+	struct hal_cmd_register_module cmd;
+	int ret;
+
+	DBG("");
+
+	if (interface_ready())
+		return BT_STATUS_DONE;
+
+	/* store reference to user callbacks */
+	cbacks = callbacks;
+
+	hal_ipc_register(HAL_SERVICE_ID_HEALTH, ev_handlers,
+				sizeof(ev_handlers)/sizeof(ev_handlers[0]));
+
+	cmd.service_id = HAL_SERVICE_ID_HEALTH;
+
+	ret = hal_ipc_cmd(HAL_SERVICE_ID_CORE, HAL_OP_REGISTER_MODULE,
+					sizeof(cmd), &cmd, 0, NULL, NULL);
+
+	if (ret != BT_STATUS_SUCCESS) {
+		cbacks = NULL;
+		hal_ipc_unregister(HAL_SERVICE_ID_HEALTH);
+	}
+
+	return ret;
+}
+
 static bthl_interface_t health_if = {
 	.size = sizeof(health_if),
-	.init = NULL,
+	.init = init,
 	.register_application = NULL,
 	.unregister_application = NULL,
 	.connect_channel = NULL,
Signature · 1 line
1.8.3.2
#9 lore raw

PATCH 9/15 android/hal-health: Add HDP .cleanup method

In reply to Ravi kumar Veeramally
---
 android/hal-health.c | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)
android/hal-health.c +20 -1
index d099ae2..918fb69 100644
@@ -67,6 +67,25 @@ static bt_status_t init(bthl_callbacks_t *callbacks)
 	return ret;
 }
 
+static void cleanup(void)
+{
+	struct hal_cmd_unregister_module cmd;
+
+	DBG("");
+
+	if (!interface_ready())
+		return;
+
+	cbacks = NULL;
+
+	cmd.service_id = HAL_SERVICE_ID_HEALTH;
+
+	hal_ipc_cmd(HAL_SERVICE_ID_CORE, HAL_OP_UNREGISTER_MODULE,
+					sizeof(cmd), &cmd, 0, NULL, NULL);
+
+	hal_ipc_unregister(HAL_SERVICE_ID_HEALTH);
+}
+
 static bthl_interface_t health_if = {
 	.size = sizeof(health_if),
 	.init = init,
@@ -74,7 +93,7 @@ static bthl_interface_t health_if = {
 	.unregister_application = NULL,
 	.connect_channel = NULL,
 	.destroy_channel = NULL,
-	.cleanup = NULL
+	.cleanup = cleanup
 };
 
 bthl_interface_t *bt_get_health_interface(void)
Signature · 1 line
1.8.3.2
#10 lore raw

PATCH 10/15 android/hal-health: Add HDP .register_application method

In reply to Ravi kumar Veeramally
---
 android/hal-health.c | 94 +++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 93 insertions(+), 1 deletion(-)
android/hal-health.c +93 -1
index 918fb69..b4871ee 100644
@@ -38,6 +38,98 @@ static bool interface_ready(void)
 static const struct hal_ipc_handler ev_handlers[] = {
 };
 
+static bt_status_t register_application(bthl_reg_param_t *reg, int *app_id)
+{
+	char buf[IPC_MTU];
+	struct hal_cmd_health_reg_app *cmd = (void *) buf;
+	struct hal_rsp_health_reg_app rsp;
+	size_t len = sizeof(rsp);
+	bt_status_t status;
+	ssize_t cmd_len;
+	uint8_t i;
+
+	DBG("");
+
+	if (!interface_ready())
+		return BT_STATUS_NOT_READY;
+
+	if (!reg || !app_id)
+		return BT_STATUS_PARM_INVALID;
+
+
+	cmd_len = sizeof(*cmd);
+
+	if (reg->application_name)
+		cmd_len += strlen(reg->application_name);
+
+	if (reg->provider_name)
+		cmd_len += strlen(reg->provider_name);
+
+	if (reg->srv_name)
+		cmd_len += strlen(reg->srv_name);
+
+	if (reg->srv_desp)
+		cmd_len += strlen(reg->srv_desp);
+
+	if (reg->number_of_mdeps > 0 && reg->mdep_cfg[0].mdep_description)
+			cmd_len += strlen(reg->mdep_cfg[0].mdep_description);
+
+	for (i = 1; i < reg->number_of_mdeps; i++)
+		cmd_len += sizeof(cmd->mdep_cfg) +
+				strlen(reg->mdep_cfg[i].mdep_description);
+
+	if (cmd_len > IPC_MTU)
+		return BT_STATUS_PARM_INVALID;
+
+	if (reg->application_name) {
+		cmd->app_name.len = strlen(reg->application_name);
+		memcpy(cmd->app_name.data, reg->application_name,
+						cmd->app_name.len);
+	}
+
+	if (reg->provider_name) {
+		cmd->provider_name.len = strlen(reg->provider_name);
+		memcpy(cmd->provider_name.data, reg->provider_name,
+						cmd->provider_name.len);
+	}
+
+	if (reg->srv_name) {
+		cmd->service_name.len = strlen(reg->srv_name);
+		memcpy(cmd->service_name.data, reg->srv_name,
+						cmd->service_name.len);
+	}
+
+	if (reg->srv_desp) {
+		cmd->service_descr.len = strlen(reg->srv_desp);
+		memcpy(cmd->service_descr.data, reg->srv_desp,
+						cmd->service_descr.len);
+	}
+
+	cmd->num_of_mdep = reg->number_of_mdeps;
+
+	if (reg->mdep_cfg && reg->number_of_mdeps > 0) {
+		for (i = 0; i < reg->number_of_mdeps; i++) {
+			cmd->mdep_cfg[i].role = reg->mdep_cfg[i].mdep_role;
+			cmd->mdep_cfg[i].data_type = reg->mdep_cfg[i].data_type;
+			cmd->mdep_cfg[i].channel_type =
+						reg->mdep_cfg[i].channel_type;
+			cmd->mdep_cfg[i].descr.len =
+				strlen(reg->mdep_cfg[i].mdep_description);
+			memcpy(cmd->mdep_cfg[i].descr.data,
+					reg->mdep_cfg[i].mdep_description,
+						cmd->mdep_cfg[i].descr.len);
+		}
+	}
+
+	status = hal_ipc_cmd(HAL_SERVICE_ID_HEALTH, HAL_OP_HEALTH_REG_APP,
+						cmd_len, cmd, &len, &rsp, NULL);
+
+	if (status == HAL_STATUS_SUCCESS)
+		*app_id = rsp.app_id;
+
+	return status;
+}
+
 static bt_status_t init(bthl_callbacks_t *callbacks)
 {
 	struct hal_cmd_register_module cmd;
@@ -89,7 +181,7 @@ static void cleanup(void)
 static bthl_interface_t health_if = {
 	.size = sizeof(health_if),
 	.init = init,
-	.register_application = NULL,
+	.register_application = register_application,
 	.unregister_application = NULL,
 	.connect_channel = NULL,
 	.destroy_channel = NULL,
Signature · 1 line
1.8.3.2
#11 lore raw

PATCH 11/15 android/hal-health: Add HDP .unregister_application method

In reply to Ravi kumar Veeramally
---
 android/hal-health.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)
android/hal-health.c +16 -1
index b4871ee..9d46b63 100644
@@ -130,6 +130,21 @@ static bt_status_t register_application(bthl_reg_param_t *reg, int *app_id)
 	return status;
 }
 
+static bt_status_t unregister_application(int app_id)
+{
+	struct hal_cmd_health_unreg_app cmd;
+
+	DBG("");
+
+	if (!interface_ready())
+		return BT_STATUS_NOT_READY;
+
+	cmd.app_id = app_id;
+
+	return hal_ipc_cmd(HAL_SERVICE_ID_HEALTH, HAL_OP_HEALTH_UNREG_APP,
+					sizeof(cmd), &cmd, 0, NULL, NULL);
+}
+
 static bt_status_t init(bthl_callbacks_t *callbacks)
 {
 	struct hal_cmd_register_module cmd;
@@ -182,7 +197,7 @@ static bthl_interface_t health_if = {
 	.size = sizeof(health_if),
 	.init = init,
 	.register_application = register_application,
-	.unregister_application = NULL,
+	.unregister_application = unregister_application,
 	.connect_channel = NULL,
 	.destroy_channel = NULL,
 	.cleanup = cleanup
Signature · 1 line
1.8.3.2
#12 lore raw

PATCH 12/15 android/hal-health: Add HDP .connect_channel method

In reply to Ravi kumar Veeramally
---
 android/hal-health.c | 32 +++++++++++++++++++++++++++++++-
 1 file changed, 31 insertions(+), 1 deletion(-)
android/hal-health.c +31 -1
index 9d46b63..58524ad 100644
@@ -145,6 +145,36 @@ static bt_status_t unregister_application(int app_id)
 					sizeof(cmd), &cmd, 0, NULL, NULL);
 }
 
+static bt_status_t connect_channel(int app_id, bt_bdaddr_t *bd_addr,
+					int mdep_cfg_index, int *channel_id)
+{
+	struct hal_cmd_health_connect_channel cmd;
+	struct hal_rsp_health_connect_channel rsp;
+	size_t len = sizeof(rsp);
+	bt_status_t status;
+
+	DBG("");
+
+	if (!interface_ready())
+		return BT_STATUS_NOT_READY;
+
+	if (!bd_addr || !channel_id)
+		return BT_STATUS_PARM_INVALID;
+
+	cmd.app_id = app_id;
+	cmd.mdep_index = mdep_cfg_index;
+	memcpy(cmd.bdaddr, bd_addr, sizeof(cmd.bdaddr));
+
+	status = hal_ipc_cmd(HAL_SERVICE_ID_HEALTH,
+					HAL_OP_HEALTH_CONNECT_CHANNEL,
+					sizeof(cmd), &cmd, &len, &rsp, NULL);
+
+	if (status == HAL_STATUS_SUCCESS)
+		*channel_id = rsp.channel_id;
+
+	return status;
+}
+
 static bt_status_t init(bthl_callbacks_t *callbacks)
 {
 	struct hal_cmd_register_module cmd;
@@ -198,7 +228,7 @@ static bthl_interface_t health_if = {
 	.init = init,
 	.register_application = register_application,
 	.unregister_application = unregister_application,
-	.connect_channel = NULL,
+	.connect_channel = connect_channel,
 	.destroy_channel = NULL,
 	.cleanup = cleanup
 };
Signature · 1 line
1.8.3.2
#13 lore raw

PATCH 13/15 android/hal-health: Add HDP .destroy_channel method

In reply to Ravi kumar Veeramally
---
 android/hal-health.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)
android/hal-health.c +16 -1
index 58524ad..5939663 100644
@@ -175,6 +175,21 @@ static bt_status_t connect_channel(int app_id, bt_bdaddr_t *bd_addr,
 	return status;
 }
 
+static bt_status_t destroy_channel(int channel_id)
+{
+	struct hal_cmd_health_destroy_channel cmd;
+
+	DBG("");
+
+	if (!interface_ready())
+		return BT_STATUS_NOT_READY;
+
+	cmd.channel_id = channel_id;
+
+	return hal_ipc_cmd(HAL_SERVICE_ID_HEALTH, HAL_OP_HEALTH_DESTROY_CHANNEL,
+					sizeof(cmd), &cmd, 0, NULL, NULL);
+}
+
 static bt_status_t init(bthl_callbacks_t *callbacks)
 {
 	struct hal_cmd_register_module cmd;
@@ -229,7 +244,7 @@ static bthl_interface_t health_if = {
 	.register_application = register_application,
 	.unregister_application = unregister_application,
 	.connect_channel = connect_channel,
-	.destroy_channel = NULL,
+	.destroy_channel = destroy_channel,
 	.cleanup = cleanup
 };
 
Signature · 1 line
1.8.3.2
#14 lore raw

PATCH 14/15 android/hal-health: Add app state and channel state event handlers

In reply to Ravi kumar Veeramally
---
 android/hal-health.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)
android/hal-health.c +29 -0
index 5939663..2914a2c 100644
@@ -33,9 +33,38 @@ static bool interface_ready(void)
 	return cbacks != NULL;
 }
 
+static void handle_app_registration_state(void *buf, uint16_t len)
+{
+	struct hal_ev_health_app_reg_state *ev = buf;
+
+	if (cbacks->app_reg_state_cb)
+		cbacks->app_reg_state_cb(ev->id, ev->state);
+}
+
+static void handle_channel_state(void *buf, uint16_t len)
+{
+	struct hal_ev_health_channel_state *ev = buf;
+
+	if (cbacks->channel_state_cb)
+		cbacks->channel_state_cb(ev->app_id,
+					(bt_bdaddr_t *) ev->bdaddr,
+					ev->mdep_index, ev->channel_id,
+					ev->channel_state, ev->file_descr);
+}
+
 /* handlers will be called from notification thread context,
  * index in table equals to 'opcode - HAL_MINIMUM_EVENT' */
 static const struct hal_ipc_handler ev_handlers[] = {
+	{ /* HAL_EV_HEALTH_APP_REG_STATE */
+		.handler = handle_app_registration_state,
+		.var_len = false,
+		.data_len = sizeof(struct hal_ev_health_app_reg_state)
+	},
+	{ /* HAL_EV_HEALTH_CHANNEL_STATE */
+		.handler = handle_channel_state,
+		.var_len = false,
+		.data_len = sizeof(struct hal_ev_health_channel_state)
+	},
 };
 
 static bt_status_t register_application(bthl_reg_param_t *reg, int *app_id)
Signature · 1 line
1.8.3.2
#15 lore raw

PATCH 15/15 android/health: Add health.c|h file with basic calls

In reply to Ravi kumar Veeramally

Add health.c|h with basic calls for register and unregister profile.

---
 android/Android.mk  |   1 +
 android/Makefile.am |   1 +
 android/health.c    | 115 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 android/health.h    |  25 ++++++++++++
 android/main.c      |  11 +++++
 5 files changed, 153 insertions(+)
 create mode 100644 android/health.c
 create mode 100644 android/health.h
android/Android.mk +1 -0
index 0352beb..34e21ea 100644
@@ -43,6 +43,7 @@ LOCAL_SRC_FILES := \
 	bluez/android/pan.c \
 	bluez/android/handsfree.c \
 	bluez/android/gatt.c \
+	bluez/android/health.c \
 	bluez/src/log.c \
 	bluez/src/shared/mgmt.c \
 	bluez/src/shared/util.c \
android/Makefile.am +1 -0
index d2cfed6..adfb14c 100644
@@ -41,6 +41,7 @@ android_bluetoothd_SOURCES = android/main.c \
 				android/pan.h android/pan.c \
 				android/handsfree.h android/handsfree.c \
 				android/gatt.h android/gatt.c \
+				android/health.h android/health.c \
 				btio/btio.h btio/btio.c \
 				src/sdp-client.h src/sdp-client.c \
 				profiles/network/bnep.h profiles/network/bnep.c
android/health.c new file +115 -0

115 lines not on this page · raw message

android/health.h new file +25 -0
new file mode 100644
index 0000000..38a58c0
@@ -0,0 +1,25 @@
+/*
+ *
+ *  BlueZ - Bluetooth protocol stack for Linux
+ *
+ *  Copyright (C) 2013-2014  Intel Corporation. All rights reserved.
+ *
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2.1 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this library; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+bool bt_health_register(struct ipc *ipc, const bdaddr_t *addr, uint8_t mode);
+void bt_health_unregister(void);
android/main.c +11 -0
index a34f885..41aa112 100644
@@ -59,6 +59,7 @@
 #include "avrcp.h"
 #include "handsfree.h"
 #include "gatt.h"
+#include "health.h"
 
 #define STARTUP_GRACE_SECONDS 5
 #define SHUTDOWN_GRACE_SECONDS 10
@@ -134,6 +135,13 @@ static void service_register(const void *buf, uint16_t len)
 		}
 
 		break;
+	case HAL_SERVICE_ID_HEALTH:
+		if (!bt_health_register(hal_ipc, &adapter_bdaddr, m->mode)) {
+			status = HAL_STATUS_FAILED;
+			goto failed;
+		}
+
+		break;
 	default:
 		DBG("service %u not supported", m->service_id);
 		status = HAL_STATUS_FAILED;
@@ -186,6 +194,9 @@ static void service_unregister(const void *buf, uint16_t len)
 	case HAL_SERVICE_ID_GATT:
 		bt_gatt_unregister();
 		break;
+	case HAL_SERVICE_ID_HEALTH:
+		bt_health_unregister();
+		break;
 	default:
 		/* This would indicate bug in HAL, as unregister should not be
 		 * called in init failed */
Signature · 1 line
1.8.3.2
#16 lore raw
In reply to Ravi kumar Veeramally

Hi Ravi,

Quoted 22 lines · On Thursday 13 of March 2014 13:58:37 Ravi kumar Veeramally wrote:

v2: Solved Luiz, Szymon, Andrzej and Grzegorz comments.

v1: Patch set contains HDP profile support at HAL side and initial profile registration support at daemon side.

Ravi kumar Veeramally (15):
android/hal-msg: Add HDP app registration struct android/hal-msg: Add HDP app unregistration struct android/hal-msg: Add HDP connect channel struct android/hal-msg: Add HDP destroy channel struct android/hal-msg: Add HDP app registration state event struct android/hal-msg: Add HDP app channel state event struct android/hal-health: Add hal-health.c with initial get interface call android/hal-health: Add HDP .init method android/hal-health: Add HDP .cleanup method android/hal-health: Add HDP .register_application method android/hal-health: Add HDP .unregister_application method android/hal-health: Add HDP .connect_channel method android/hal-health: Add HDP .destroy_channel method android/hal-health: Add app state and channel state event handlers android/health: Add health.c|h file with basic calls

Quoted 15 lines
 android/Android.mk      |   2 +
 android/Makefile.am     |   2 +
 android/hal-bluetooth.c |   3 +
 android/hal-health.c    | 283 ++++++++++++++++++++++++++++++++++++++++++++++++
 android/hal-msg.h       |  72 ++++++++++++
 android/hal.h           |   2 +
 android/health.c        | 115 ++++++++++++++++++++
 android/health.h        |  25 +++++
 android/main.c          |  11 ++
 9 files changed, 515 insertions(+)
 create mode 100644 android/hal-health.c
 create mode 100644 android/health.c
 create mode 100644 android/health.h

Patches 1-9 and 15 are now pushed (with changes we discussed on IRC). Thanks.

Signature · 2 lines
Best regards, 
Szymon Janc