2014-03-13 11:58:37

by Ravi kumar Veeramally

[permalink] [raw]
Subject: [PATCH_v2 00/15] 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

--
1.8.3.2



2014-03-14 12:37:23

by Szymon Janc

[permalink] [raw]
Subject: Re: [PATCH_v2 00/15] Add HDP profile support at HAL side

Hi Ravi,

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
>
> 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.

--
Best regards,
Szymon Janc

2014-03-13 11:58:39

by Ravi kumar Veeramally

[permalink] [raw]
Subject: [PATCH_v2 02/15] android/hal-msg: Add HDP app unregistration struct

---
android/hal-msg.h | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/android/hal-msg.h b/android/hal-msg.h
index 0c63216..77c2757 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -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

--
1.8.3.2


2014-03-13 11:58:41

by Ravi kumar Veeramally

[permalink] [raw]
Subject: [PATCH_v2 04/15] android/hal-msg: Add HDP destroy channel struct

---
android/hal-msg.h | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/android/hal-msg.h b/android/hal-msg.h
index 2db87ac..57069b3 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -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
--
1.8.3.2


2014-03-13 11:58:42

by Ravi kumar Veeramally

[permalink] [raw]
Subject: [PATCH_v2 05/15] android/hal-msg: Add HDP app registration state event struct

---
android/hal-msg.h | 11 +++++++++++
1 file changed, 11 insertions(+)

diff --git a/android/hal-msg.h b/android/hal-msg.h
index 57069b3..3f119de 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -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
--
1.8.3.2


2014-03-13 11:58:44

by Ravi kumar Veeramally

[permalink] [raw]
Subject: [PATCH_v2 07/15] android/hal-health: Add hal-health.c with initial get interface call

---
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

diff --git a/android/Android.mk b/android/Android.mk
index 49bf108..0352beb 100644
--- a/android/Android.mk
+++ b/android/Android.mk
@@ -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) \
diff --git a/android/Makefile.am b/android/Makefile.am
index bbd3d2f..d2cfed6 100644
--- a/android/Makefile.am
+++ b/android/Makefile.am
@@ -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 \
diff --git a/android/hal-bluetooth.c b/android/hal-bluetooth.c
index 2bc089e..fcf02f6 100644
--- a/android/hal-bluetooth.c
+++ b/android/hal-bluetooth.c
@@ -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;
}

diff --git a/android/hal-health.c b/android/hal-health.c
new file mode 100644
index 0000000..59f8cca
--- /dev/null
+++ b/android/hal-health.c
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2014 Intel Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <stdbool.h>
+#include <stddef.h>
+#include <string.h>
+#include <stdlib.h>
+
+#include "hal-log.h"
+#include "hal.h"
+#include "hal-msg.h"
+#include "ipc-common.h"
+#include "hal-ipc.h"
+
+static bthl_interface_t health_if = {
+ .size = sizeof(health_if),
+ .init = NULL,
+ .register_application = NULL,
+ .unregister_application = NULL,
+ .connect_channel = NULL,
+ .destroy_channel = NULL,
+ .cleanup = NULL
+};
+
+bthl_interface_t *bt_get_health_interface(void)
+{
+ return &health_if;
+}
diff --git a/android/hal.h b/android/hal.h
index b1c0216..6998e9a 100644
--- a/android/hal.h
+++ b/android/hal.h
@@ -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);
--
1.8.3.2


2014-03-13 11:58:43

by Ravi kumar Veeramally

[permalink] [raw]
Subject: [PATCH_v2 06/15] android/hal-msg: Add HDP app channel state event struct

---
android/hal-msg.h | 16 ++++++++++++++++
1 file changed, 16 insertions(+)

diff --git a/android/hal-msg.h b/android/hal-msg.h
index 3f119de..0b8924e 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -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
--
1.8.3.2


2014-03-13 11:58:52

by Ravi kumar Veeramally

[permalink] [raw]
Subject: [PATCH_v2 15/15] android/health: Add health.c|h file with basic calls

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

diff --git a/android/Android.mk b/android/Android.mk
index 0352beb..34e21ea 100644
--- a/android/Android.mk
+++ b/android/Android.mk
@@ -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 \
diff --git a/android/Makefile.am b/android/Makefile.am
index d2cfed6..adfb14c 100644
--- a/android/Makefile.am
+++ b/android/Makefile.am
@@ -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
diff --git a/android/health.c b/android/health.c
new file mode 100644
index 0000000..6359b11
--- /dev/null
+++ b/android/health.c
@@ -0,0 +1,115 @@
+/*
+ *
+ * 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
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdint.h>
+#include <stdbool.h>
+#include <errno.h>
+#include <unistd.h>
+#include <glib.h>
+
+#include "lib/bluetooth.h"
+#include "lib/sdp.h"
+#include "lib/sdp_lib.h"
+#include "src/log.h"
+
+#include "hal-msg.h"
+#include "ipc-common.h"
+#include "ipc.h"
+#include "utils.h"
+#include "bluetooth.h"
+#include "health.h"
+
+static bdaddr_t adapter_addr;
+static struct ipc *hal_ipc = NULL;
+
+static void bt_health_register_app(const void *buf, uint16_t len)
+{
+ DBG("Not implemented");
+
+ ipc_send_rsp(hal_ipc, HAL_SERVICE_ID_HEALTH, HAL_OP_HEALTH_REG_APP,
+ HAL_STATUS_UNSUPPORTED);
+}
+
+static void bt_health_unregister_app(const void *buf, uint16_t len)
+{
+ DBG("Not implemented");
+
+ ipc_send_rsp(hal_ipc, HAL_SERVICE_ID_HEALTH, HAL_OP_HEALTH_UNREG_APP,
+ HAL_STATUS_UNSUPPORTED);
+}
+
+static void bt_health_connect_channel(const void *buf, uint16_t len)
+{
+ DBG("Not implemented");
+
+ ipc_send_rsp(hal_ipc, HAL_SERVICE_ID_HEALTH,
+ HAL_OP_HEALTH_CONNECT_CHANNEL, HAL_STATUS_UNSUPPORTED);
+}
+
+static void bt_health_destroy_channel(const void *buf, uint16_t len)
+{
+ DBG("Not implemented");
+
+ ipc_send_rsp(hal_ipc, HAL_SERVICE_ID_HEALTH,
+ HAL_OP_HEALTH_DESTROY_CHANNEL, HAL_STATUS_UNSUPPORTED);
+}
+
+static const struct ipc_handler cmd_handlers[] = {
+ /* HAL_OP_HEALTH_REG_APP */
+ { bt_health_register_app, false,
+ sizeof(struct hal_cmd_health_reg_app) },
+ /* HAL_OP_HEALTH_UNREG_APP */
+ { bt_health_unregister_app, false,
+ sizeof(struct hal_cmd_health_unreg_app) },
+ /* HAL_OP_HEALTH_CONNECT_CHANNEL */
+ { bt_health_connect_channel, false,
+ sizeof(struct hal_cmd_health_connect_channel) },
+ /* HAL_OP_HEALTH_DESTROY_CHANNEL */
+ { bt_health_destroy_channel, false,
+ sizeof(struct hal_cmd_health_destroy_channel) },
+};
+
+bool bt_health_register(struct ipc *ipc, const bdaddr_t *addr, uint8_t mode)
+{
+ DBG("");
+
+ bacpy(&adapter_addr, addr);
+
+ hal_ipc = ipc;
+ ipc_register(hal_ipc, HAL_SERVICE_ID_HEALTH, cmd_handlers,
+ G_N_ELEMENTS(cmd_handlers));
+
+ return true;
+}
+
+void bt_health_unregister(void)
+{
+ DBG("");
+
+ ipc_unregister(hal_ipc, HAL_SERVICE_ID_HEALTH);
+ hal_ipc = NULL;
+}
diff --git a/android/health.h b/android/health.h
new file mode 100644
index 0000000..38a58c0
--- /dev/null
+++ b/android/health.h
@@ -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);
diff --git a/android/main.c b/android/main.c
index a34f885..41aa112 100644
--- a/android/main.c
+++ b/android/main.c
@@ -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 */
--
1.8.3.2


2014-03-13 11:58:45

by Ravi kumar Veeramally

[permalink] [raw]
Subject: [PATCH_v2 08/15] android/hal-health: Add HDP .init method

---
android/hal-health.c | 43 ++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 42 insertions(+), 1 deletion(-)

diff --git a/android/hal-health.c b/android/hal-health.c
index 59f8cca..d099ae2 100644
--- a/android/hal-health.c
+++ b/android/hal-health.c
@@ -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,
--
1.8.3.2


2014-03-13 11:58:47

by Ravi kumar Veeramally

[permalink] [raw]
Subject: [PATCH_v2 10/15] android/hal-health: Add HDP .register_application method

---
android/hal-health.c | 94 +++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 93 insertions(+), 1 deletion(-)

diff --git a/android/hal-health.c b/android/hal-health.c
index 918fb69..b4871ee 100644
--- a/android/hal-health.c
+++ b/android/hal-health.c
@@ -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,
--
1.8.3.2


2014-03-13 11:58:51

by Ravi kumar Veeramally

[permalink] [raw]
Subject: [PATCH_v2 14/15] android/hal-health: Add app state and channel state event handlers

---
android/hal-health.c | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)

diff --git a/android/hal-health.c b/android/hal-health.c
index 5939663..2914a2c 100644
--- a/android/hal-health.c
+++ b/android/hal-health.c
@@ -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)
--
1.8.3.2


2014-03-13 11:58:50

by Ravi kumar Veeramally

[permalink] [raw]
Subject: [PATCH_v2 13/15] android/hal-health: Add HDP .destroy_channel method

---
android/hal-health.c | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/android/hal-health.c b/android/hal-health.c
index 58524ad..5939663 100644
--- a/android/hal-health.c
+++ b/android/hal-health.c
@@ -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
};

--
1.8.3.2


2014-03-13 11:58:46

by Ravi kumar Veeramally

[permalink] [raw]
Subject: [PATCH_v2 09/15] android/hal-health: Add HDP .cleanup method

---
android/hal-health.c | 21 ++++++++++++++++++++-
1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/android/hal-health.c b/android/hal-health.c
index d099ae2..918fb69 100644
--- a/android/hal-health.c
+++ b/android/hal-health.c
@@ -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)
--
1.8.3.2


2014-03-13 11:58:48

by Ravi kumar Veeramally

[permalink] [raw]
Subject: [PATCH_v2 11/15] android/hal-health: Add HDP .unregister_application method

---
android/hal-health.c | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/android/hal-health.c b/android/hal-health.c
index b4871ee..9d46b63 100644
--- a/android/hal-health.c
+++ b/android/hal-health.c
@@ -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
--
1.8.3.2


2014-03-13 11:58:49

by Ravi kumar Veeramally

[permalink] [raw]
Subject: [PATCH_v2 12/15] android/hal-health: Add HDP .connect_channel method

---
android/hal-health.c | 32 +++++++++++++++++++++++++++++++-
1 file changed, 31 insertions(+), 1 deletion(-)

diff --git a/android/hal-health.c b/android/hal-health.c
index 9d46b63..58524ad 100644
--- a/android/hal-health.c
+++ b/android/hal-health.c
@@ -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
};
--
1.8.3.2


2014-03-13 11:58:38

by Ravi kumar Veeramally

[permalink] [raw]
Subject: [PATCH_v2 01/15] android/hal-msg: Add HDP app registration struct

---
android/hal-msg.h | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)

diff --git a/android/hal-msg.h b/android/hal-msg.h
index 0abbbe6..0c63216 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -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
--
1.8.3.2


2014-03-13 11:58:40

by Ravi kumar Veeramally

[permalink] [raw]
Subject: [PATCH_v2 03/15] android/hal-msg: Add HDP connect channel struct

---
android/hal-msg.h | 11 +++++++++++
1 file changed, 11 insertions(+)

diff --git a/android/hal-msg.h b/android/hal-msg.h
index 77c2757..2db87ac 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -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
--
1.8.3.2