From: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
To: linux-bluetooth@vger.kernel.org
Cc: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
Subject: [PATCH_v2 10/15] android/hal-health: Add HDP .register_application method
Date: Thu, 13 Mar 2014 13:58:47 +0200 [thread overview]
Message-ID: <1394711932-16560-11-git-send-email-ravikumar.veeramally@linux.intel.com> (raw)
In-Reply-To: <1394711932-16560-1-git-send-email-ravikumar.veeramally@linux.intel.com>
---
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
next prev parent reply other threads:[~2014-03-13 11:58 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-13 11:58 [PATCH_v2 00/15] Add HDP profile support at HAL side Ravi kumar Veeramally
2014-03-13 11:58 ` [PATCH_v2 01/15] android/hal-msg: Add HDP app registration struct Ravi kumar Veeramally
2014-03-13 11:58 ` [PATCH_v2 02/15] android/hal-msg: Add HDP app unregistration struct Ravi kumar Veeramally
2014-03-13 11:58 ` [PATCH_v2 03/15] android/hal-msg: Add HDP connect channel struct Ravi kumar Veeramally
2014-03-13 11:58 ` [PATCH_v2 04/15] android/hal-msg: Add HDP destroy " Ravi kumar Veeramally
2014-03-13 11:58 ` [PATCH_v2 05/15] android/hal-msg: Add HDP app registration state event struct Ravi kumar Veeramally
2014-03-13 11:58 ` [PATCH_v2 06/15] android/hal-msg: Add HDP app channel " Ravi kumar Veeramally
2014-03-13 11:58 ` [PATCH_v2 07/15] android/hal-health: Add hal-health.c with initial get interface call Ravi kumar Veeramally
2014-03-13 11:58 ` [PATCH_v2 08/15] android/hal-health: Add HDP .init method Ravi kumar Veeramally
2014-03-13 11:58 ` [PATCH_v2 09/15] android/hal-health: Add HDP .cleanup method Ravi kumar Veeramally
2014-03-13 11:58 ` Ravi kumar Veeramally [this message]
2014-03-13 11:58 ` [PATCH_v2 11/15] android/hal-health: Add HDP .unregister_application method Ravi kumar Veeramally
2014-03-13 11:58 ` [PATCH_v2 12/15] android/hal-health: Add HDP .connect_channel method Ravi kumar Veeramally
2014-03-13 11:58 ` [PATCH_v2 13/15] android/hal-health: Add HDP .destroy_channel method Ravi kumar Veeramally
2014-03-13 11:58 ` [PATCH_v2 14/15] android/hal-health: Add app state and channel state event handlers Ravi kumar Veeramally
2014-03-13 11:58 ` [PATCH_v2 15/15] android/health: Add health.c|h file with basic calls Ravi kumar Veeramally
2014-03-14 12:37 ` [PATCH_v2 00/15] Add HDP profile support at HAL side Szymon Janc
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1394711932-16560-11-git-send-email-ravikumar.veeramally@linux.intel.com \
--to=ravikumar.veeramally@linux.intel.com \
--cc=linux-bluetooth@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox