2014-03-12 15:10:43

by Ravi kumar Veeramally

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

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 file
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-health.c | 243 +++++++++++++++++++++++++++++++++++++++++++++++++++
android/hal-msg.h | 68 ++++++++++++++
android/hal.h | 2 +
android/health.c | 115 ++++++++++++++++++++++++
android/health.h | 25 ++++++
android/main.c | 10 +++
8 files changed, 467 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-13 09:22:28

by Ravi kumar Veeramally

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

Hi Szymon,

On 03/12/2014 10:05 PM, Szymon Janc wrote:
> Hi Ravi,
>
> On Wednesday 12 March 2014 17:10:55 Ravi kumar Veeramally wrote:
>> ---
>> android/hal-health.c | 31 ++++++++++++++++++++++++++++++-
>> 1 file changed, 30 insertions(+), 1 deletion(-)
>>
>> diff --git a/android/hal-health.c b/android/hal-health.c
>> index 007a37a..0d10d98 100644
>> --- a/android/hal-health.c
>> +++ b/android/hal-health.c
>> @@ -106,6 +106,35 @@ 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)
>> + return BT_STATUS_PARM_INVALID;
> Verify channel_id pointer as well here.
>
>> +
>> + 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);
>> +
>> + *channel_id = rsp.channel_id;
> if (status == HAL_STATUS_SUCCESS)
> *channel_id = rsp.channel_id;
>
> Otherwise you might assign garbage.

Ok, I will fix all your comments.
>> +
>> + return status;
>> +}
>> +
>> static bt_status_t init(bthl_callbacks_t *callbacks)
>> {
>> struct hal_cmd_register_module cmd;
>> @@ -159,7 +188,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
>> };

Thanks,
Ravi.

2014-03-12 20:05:30

by Szymon Janc

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

Hi Ravi,

On Wednesday 12 March 2014 17:10:55 Ravi kumar Veeramally wrote:
> ---
> android/hal-health.c | 31 ++++++++++++++++++++++++++++++-
> 1 file changed, 30 insertions(+), 1 deletion(-)
>
> diff --git a/android/hal-health.c b/android/hal-health.c
> index 007a37a..0d10d98 100644
> --- a/android/hal-health.c
> +++ b/android/hal-health.c
> @@ -106,6 +106,35 @@ 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)
> + return BT_STATUS_PARM_INVALID;

Verify channel_id pointer as well here.

> +
> + 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);
> +
> + *channel_id = rsp.channel_id;

if (status == HAL_STATUS_SUCCESS)
*channel_id = rsp.channel_id;

Otherwise you might assign garbage.

> +
> + return status;
> +}
> +
> static bt_status_t init(bthl_callbacks_t *callbacks)
> {
> struct hal_cmd_register_module cmd;
> @@ -159,7 +188,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
> };

--
Szymon K. Janc
[email protected]

2014-03-12 19:56:28

by Szymon Janc

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

Hi Ravi,

On Wednesday 12 March 2014 17:10:51 Ravi kumar Veeramally wrote:
> ---
> 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 55db7f6..649661e 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;

Please explicitly initialize it to 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,

--
Szymon K. Janc
[email protected]

2014-03-12 19:53:39

by Szymon Janc

[permalink] [raw]
Subject: Re: [PATCH 07/15] android/hal-health: Add hal-health file

Hi Ravi,

On Wednesday 12 March 2014 17:10:50 Ravi kumar Veeramally wrote:
> Add hal-health.c and initial get interface method.
> ---
> android/Android.mk | 1 +
> android/Makefile.am | 1 +
> android/hal-health.c | 42 ++++++++++++++++++++++++++++++++++++++++++
> android/hal.h | 2 ++
> 4 files changed, 46 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-health.c b/android/hal-health.c
> new file mode 100644
> index 0000000..55db7f6
> --- /dev/null
> +++ b/android/hal-health.c
> @@ -0,0 +1,42 @@
> +/*
> + * Copyright (C) 2013 Intel Corporation

Shouldn't that be 2014?

> + *
> + * 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);
>

This should be called from get_profile_interface() in hal-bluetooth.c

> void bt_thread_associate(void);
> void bt_thread_disassociate(void);

--
Szymon K. Janc
[email protected]

2014-03-12 17:39:03

by Ravi kumar Veeramally

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

Hi,

On 03/12/2014 05:39 PM, Luiz Augusto von Dentz wrote:
> Hi Ravi,
>
> On Wed, Mar 12, 2014 at 5:10 PM, Ravi kumar Veeramally
> <[email protected]> wrote:
>> ---
>> android/hal-msg.h | 21 +++++++++++++++++++++
>> 1 file changed, 21 insertions(+)
>>
>> diff --git a/android/hal-msg.h b/android/hal-msg.h
>> index 0abbbe6..b1942de 100644
>> --- a/android/hal-msg.h
>> +++ b/android/hal-msg.h
>> @@ -383,6 +383,27 @@ struct hal_cmd_pan_disconnect {
>> uint8_t bdaddr[6];
>> } __attribute__((packed));
>>
>> +#define HAL_OP_HEALTH_REG_APP 0x01
>> +struct hal_cmd_health_reg_app {
>> + uint8_t app_name[255];
>> + uint8_t provider_name[255];
>> + uint8_t service_name[255];
>> + uint8_t service_descr[200];
>> + uint8_t num_of_mdep;
>> +
>> + struct {
>> + uint8_t role;
>> + uint8_t data_type;
>> + uint8_t channel_type;
>> + uint8_t descr[255];
>> + } mdep_cfg[20];
>> +} __attribute__((packed));
>> +
>> +struct hal_rsp_health_reg_app {
>> + uint16_t app_id;
>> +} __attribute__((packed));
> This most likely will not fit in our MTU which currently is 1024 bytes
> and given that you have 20 cfgs this is going to be huge. We should
> probably define a hal_string e.g:
>
> struct hal_string {
> uint8_t len;
> uint8_t data[0];
> };
Ok, I will update it.
> Also we do not need to send the 20 cfgs every time so that should
> probably be set to 0 and we write only num_of_mdep, if that still
> doesn't fit in our MTU perhaps we should consider a bigger size.
>
Ok.

Thanks,
Ravi.

2014-03-12 17:37:46

by Ravi kumar Veeramally

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

Hi,

On 03/12/2014 05:18 PM, Grzegorz Kolodziejczyk wrote:
> On 12 March 2014 16:10, Ravi kumar Veeramally
> <[email protected]> wrote:
>> 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 | 10 +++++
>> 5 files changed, 152 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..9423619 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
>> @@ -133,6 +134,12 @@ static void service_register(const void *buf, uint16_t len)
>> goto failed;
>> }
> Missing brake here.
Ok, I will fix it.

Thanks,
Ravi.

>> + 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);
>> @@ -186,6 +193,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
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
>> the body of a message to [email protected]
>> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Best regards,
> Grzegorz Kolodziejczyk
>
> On 12 March 2014 16:10, Ravi kumar Veeramally
> <[email protected]> wrote:
>> 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 | 10 +++++
>> 5 files changed, 152 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..9423619 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
>> @@ -133,6 +134,12 @@ static void service_register(const void *buf, uint16_t len)
>> goto failed;
>> }
>>
>> + 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);
>> @@ -186,6 +193,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
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
>> the body of a message to [email protected]
>> More majordomo info at http://vger.kernel.org/majordomo-info.html


2014-03-12 17:36:24

by Ravi kumar Veeramally

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

Hi,

On 03/12/2014 05:57 PM, Andrzej Kaczmarek wrote:
> Hi Ravi,
>
> On 12 March 2014 16:10, Ravi kumar Veeramally
> <[email protected]> wrote:
>> ---
>> android/hal-msg.h | 16 ++++++++++++++++
>> 1 file changed, 16 insertions(+)
>>
>> diff --git a/android/hal-msg.h b/android/hal-msg.h
>> index 694529f..0139543 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_CHANL_STATE_CONNECTING 0x00
>> +#define HAL_HEALTH_CHANL_STATE_CONNECTED 0x01
>> +#define HAL_HEALTH_CHANL_STATE_DISCONNECTING 0x02
>> +#define HAL_HEALTH_CHANL_STATE_DISCONNECTED 0x03
>> +#define HAL_HEALTH_CHANL_STATE_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_CHNL_STATE 0x82
> You have CHNL here and CHANL in states definitions - better have them
> consistent. I guess either CHAN or CHANNEL would be actually better.
Ok, I will fix.
>> +struct hal_ev_health_chnl_state {
>> + uint16_t app_id;
>> + uint8_t bdaddr[6];
>> + uint8_t mdep_index;
>> + uint16_t chnl_id;
>> + uint8_t chnl_state;
> Same here - chan or channel.
>
>> + uint32_t file_descr;
> fd shall be passed as auxiliary data - there's parameter for this in
> IPC calls. Now you just pass plain int value which is useless as fd.
OK.

Thanks,
Ravi.

2014-03-12 15:57:28

by Andrzej Kaczmarek

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

Hi Ravi,

On 12 March 2014 16:10, Ravi kumar Veeramally
<[email protected]> wrote:
> ---
> android/hal-msg.h | 16 ++++++++++++++++
> 1 file changed, 16 insertions(+)
>
> diff --git a/android/hal-msg.h b/android/hal-msg.h
> index 694529f..0139543 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_CHANL_STATE_CONNECTING 0x00
> +#define HAL_HEALTH_CHANL_STATE_CONNECTED 0x01
> +#define HAL_HEALTH_CHANL_STATE_DISCONNECTING 0x02
> +#define HAL_HEALTH_CHANL_STATE_DISCONNECTED 0x03
> +#define HAL_HEALTH_CHANL_STATE_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_CHNL_STATE 0x82

You have CHNL here and CHANL in states definitions - better have them
consistent. I guess either CHAN or CHANNEL would be actually better.

> +struct hal_ev_health_chnl_state {
> + uint16_t app_id;
> + uint8_t bdaddr[6];
> + uint8_t mdep_index;
> + uint16_t chnl_id;
> + uint8_t chnl_state;

Same here - chan or channel.

> + uint32_t file_descr;

fd shall be passed as auxiliary data - there's parameter for this in
IPC calls. Now you just pass plain int value which is useless as fd.

BR,
Andrzej

2014-03-12 15:39:31

by Luiz Augusto von Dentz

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

Hi Ravi,

On Wed, Mar 12, 2014 at 5:10 PM, Ravi kumar Veeramally
<[email protected]> wrote:
> ---
> android/hal-msg.h | 21 +++++++++++++++++++++
> 1 file changed, 21 insertions(+)
>
> diff --git a/android/hal-msg.h b/android/hal-msg.h
> index 0abbbe6..b1942de 100644
> --- a/android/hal-msg.h
> +++ b/android/hal-msg.h
> @@ -383,6 +383,27 @@ struct hal_cmd_pan_disconnect {
> uint8_t bdaddr[6];
> } __attribute__((packed));
>
> +#define HAL_OP_HEALTH_REG_APP 0x01
> +struct hal_cmd_health_reg_app {
> + uint8_t app_name[255];
> + uint8_t provider_name[255];
> + uint8_t service_name[255];
> + uint8_t service_descr[200];
> + uint8_t num_of_mdep;
> +
> + struct {
> + uint8_t role;
> + uint8_t data_type;
> + uint8_t channel_type;
> + uint8_t descr[255];
> + } mdep_cfg[20];
> +} __attribute__((packed));
> +
> +struct hal_rsp_health_reg_app {
> + uint16_t app_id;
> +} __attribute__((packed));

This most likely will not fit in our MTU which currently is 1024 bytes
and given that you have 20 cfgs this is going to be huge. We should
probably define a hal_string e.g:

struct hal_string {
uint8_t len;
uint8_t data[0];
};

Also we do not need to send the 20 cfgs every time so that should
probably be set to 0 and we write only num_of_mdep, if that still
doesn't fit in our MTU perhaps we should consider a bigger size.


--
Luiz Augusto von Dentz

2014-03-12 15:18:41

by Grzegorz Kolodziejczyk

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

On 12 March 2014 16:10, Ravi kumar Veeramally
<[email protected]> wrote:
> 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 | 10 +++++
> 5 files changed, 152 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..9423619 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
> @@ -133,6 +134,12 @@ static void service_register(const void *buf, uint16_t len)
> goto failed;
> }

Missing brake here.

>
> + 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);
> @@ -186,6 +193,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
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html

Best regards,
Grzegorz Kolodziejczyk

On 12 March 2014 16:10, Ravi kumar Veeramally
<[email protected]> wrote:
> 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 | 10 +++++
> 5 files changed, 152 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..9423619 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
> @@ -133,6 +134,12 @@ static void service_register(const void *buf, uint16_t len)
> goto failed;
> }
>
> + 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);
> @@ -186,6 +193,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
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html

2014-03-12 15:10:58

by Ravi kumar Veeramally

[permalink] [raw]
Subject: [PATCH 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 | 10 +++++
5 files changed, 152 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..9423619 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
@@ -133,6 +134,12 @@ static void service_register(const void *buf, uint16_t len)
goto failed;
}

+ 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);
@@ -186,6 +193,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-12 15:10:56

by Ravi kumar Veeramally

[permalink] [raw]
Subject: [PATCH 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 0d10d98..479fd94 100644
--- a/android/hal-health.c
+++ b/android/hal-health.c
@@ -135,6 +135,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;
@@ -189,7 +204,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-12 15:10:57

by Ravi kumar Veeramally

[permalink] [raw]
Subject: [PATCH 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 479fd94..a9ea8cb 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_chnl_state *ev = buf;
+
+ if (cbacks->channel_state_cb)
+ cbacks->channel_state_cb(ev->app_id,
+ (bt_bdaddr_t *) ev->bdaddr,
+ ev->mdep_index, ev->chnl_id,
+ ev->chnl_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_CHNL_STATE */
+ .handler = handle_channel_state,
+ .var_len = false,
+ .data_len = sizeof(struct hal_ev_health_chnl_state)
+ },
};

static bt_status_t register_application(bthl_reg_param_t *reg, int *app_id)
--
1.8.3.2


2014-03-12 15:10:55

by Ravi kumar Veeramally

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

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

diff --git a/android/hal-health.c b/android/hal-health.c
index 007a37a..0d10d98 100644
--- a/android/hal-health.c
+++ b/android/hal-health.c
@@ -106,6 +106,35 @@ 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)
+ 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);
+
+ *channel_id = rsp.channel_id;
+
+ return status;
+}
+
static bt_status_t init(bthl_callbacks_t *callbacks)
{
struct hal_cmd_register_module cmd;
@@ -159,7 +188,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-12 15:10:46

by Ravi kumar Veeramally

[permalink] [raw]
Subject: [PATCH 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 cf2d353..4be4ae2 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -408,6 +408,17 @@ struct hal_cmd_health_unreg_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


2014-03-12 15:10:44

by Ravi kumar Veeramally

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

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

diff --git a/android/hal-msg.h b/android/hal-msg.h
index 0abbbe6..b1942de 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -383,6 +383,27 @@ struct hal_cmd_pan_disconnect {
uint8_t bdaddr[6];
} __attribute__((packed));

+#define HAL_OP_HEALTH_REG_APP 0x01
+struct hal_cmd_health_reg_app {
+ uint8_t app_name[255];
+ uint8_t provider_name[255];
+ uint8_t service_name[255];
+ uint8_t service_descr[200];
+ uint8_t num_of_mdep;
+
+ struct {
+ uint8_t role;
+ uint8_t data_type;
+ uint8_t channel_type;
+ uint8_t descr[255];
+ } mdep_cfg[20];
+} __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-12 15:10:51

by Ravi kumar Veeramally

[permalink] [raw]
Subject: [PATCH 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 55db7f6..649661e 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;
+
+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-12 15:10:47

by Ravi kumar Veeramally

[permalink] [raw]
Subject: [PATCH 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 4be4ae2..f4e513b 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-12 15:10:53

by Ravi kumar Veeramally

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

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

diff --git a/android/hal-health.c b/android/hal-health.c
index 50adcc9..8a610a2 100644
--- a/android/hal-health.c
+++ b/android/hal-health.c
@@ -38,6 +38,59 @@ 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)
+{
+ struct hal_cmd_health_reg_app cmd;
+ struct hal_rsp_health_reg_app rsp;
+ size_t len = sizeof(rsp);
+ bt_status_t status;
+ uint8_t i;
+
+ DBG("");
+
+ if (!interface_ready())
+ return BT_STATUS_NOT_READY;
+
+ memset(&cmd, 0, sizeof(cmd));
+
+ if (reg->application_name)
+ memcpy(cmd.app_name, reg->application_name,
+ strlen(reg->application_name));
+
+ if (reg->provider_name)
+ memcpy(cmd.provider_name, reg->provider_name,
+ strlen(reg->provider_name));
+
+ if (reg->srv_name)
+ memcpy(cmd.service_name, reg->srv_name,
+ strlen(reg->srv_name));
+
+ if (reg->srv_desp)
+ memcpy(cmd.service_descr, reg->srv_desp,
+ strlen(reg->srv_desp));
+
+ 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;
+ memcpy(cmd.mdep_cfg[i].descr,
+ reg->mdep_cfg[i].mdep_description,
+ strlen(reg->mdep_cfg[i].mdep_description));
+ }
+ }
+
+ status = hal_ipc_cmd(HAL_SERVICE_ID_HEALTH, HAL_OP_HEALTH_REG_APP,
+ sizeof(cmd), &cmd, &len, &rsp, NULL);
+
+ *app_id = rsp.app_id;
+
+ return status;
+}
+
static bt_status_t init(bthl_callbacks_t *callbacks)
{
struct hal_cmd_register_module cmd;
@@ -89,7 +142,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-12 15:10:49

by Ravi kumar Veeramally

[permalink] [raw]
Subject: [PATCH 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 694529f..0139543 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_CHANL_STATE_CONNECTING 0x00
+#define HAL_HEALTH_CHANL_STATE_CONNECTED 0x01
+#define HAL_HEALTH_CHANL_STATE_DISCONNECTING 0x02
+#define HAL_HEALTH_CHANL_STATE_DISCONNECTED 0x03
+#define HAL_HEALTH_CHANL_STATE_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_CHNL_STATE 0x82
+struct hal_ev_health_chnl_state {
+ uint16_t app_id;
+ uint8_t bdaddr[6];
+ uint8_t mdep_index;
+ uint16_t chnl_id;
+ uint8_t chnl_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-12 15:10:50

by Ravi kumar Veeramally

[permalink] [raw]
Subject: [PATCH 07/15] android/hal-health: Add hal-health file

Add hal-health.c and initial get interface method.
---
android/Android.mk | 1 +
android/Makefile.am | 1 +
android/hal-health.c | 42 ++++++++++++++++++++++++++++++++++++++++++
android/hal.h | 2 ++
4 files changed, 46 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-health.c b/android/hal-health.c
new file mode 100644
index 0000000..55db7f6
--- /dev/null
+++ b/android/hal-health.c
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2013 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-12 15:10:54

by Ravi kumar Veeramally

[permalink] [raw]
Subject: [PATCH 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 8a610a2..007a37a 100644
--- a/android/hal-health.c
+++ b/android/hal-health.c
@@ -91,6 +91,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;
@@ -143,7 +158,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-12 15:10:52

by Ravi kumar Veeramally

[permalink] [raw]
Subject: [PATCH 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 649661e..50adcc9 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-12 15:10:48

by Ravi kumar Veeramally

[permalink] [raw]
Subject: [PATCH 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 f4e513b..694529f 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-12 15:10:45

by Ravi kumar Veeramally

[permalink] [raw]
Subject: [PATCH 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 b1942de..cf2d353 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -403,6 +403,10 @@ struct hal_rsp_health_reg_app {
uint16_t app_id;
} __attribute__((packed));

+#define HAL_OP_HEALTH_UNREG_APP 0x02
+struct hal_cmd_health_unreg_app {
+ uint16_t app_id;
+} __attribute__((packed));

/* Handsfree HAL API */

--
1.8.3.2