Add health profile support for haltest
cover Add health profile support for haltest
v1: Patch set contains fixes and health profile support for
haltest.
Ravi kumar Veeramally (11):
android/hal-health: Use correct enums android/hal-health: Fix copying empty string android/hal-msg: Add mdep role and channel type defines android/health: Fix wrong boolean value for command handler android/health: Add initial function for HAL_OP_HEALTH_MDEP command android/client: Add initial support for health profile android/client: Add register_application support to haltest android/client: Add unregister_application support to haltest android/client: Add connect_channel support to haltest android/client: Add destroy_channel support to haltest android/client: Add health callbacks support for haltest
android/Makefile.am | 1 + android/client/haltest.c | 1 + android/client/if-bt.c | 3 +- android/client/if-hl.c | 301 +++++++++++++++++++++++++++++++++++++++++++++++ android/client/if-main.h | 2 + android/hal-health.c | 14 ++- android/hal-msg.h | 7 ++ android/health.c | 13 +- 8 files changed, 334 insertions(+), 8 deletions(-) create mode 100644 android/client/if-hl.c
Signature · 1 line
1.8.3.2
PATCH 1/11 android/hal-health: Use correct enums
--- android/hal-health.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
android/hal-health.c +3 -3
@@ -93,7 +93,7 @@ static bt_status_t register_application(bthl_reg_param_t *reg, int *app_id)sizeof (*cmd) + cmd->len, &cmd, &rsp_len, &rsp, NULL); -if (status !=HAL_STATUS_SUCCESS ) +if (status !=BT_STATUS_SUCCESS )return status;for (i =0 ; i < reg->number_of_mdeps; i++) {
@@ -109,7 +109,7 @@ static bt_status_t register_application(bthl_reg_param_t *reg, int *app_id)sizeof (*mdep) + mdep->descr_len, buf, 0, NULL, NULL); -if (status !=HAL_STATUS_SUCCESS ) +if (status !=BT_STATUS_SUCCESS )return status; }
@@ -158,7 +158,7 @@ static bt_status_t connect_channel(int app_id, bt_bdaddr_t *bd_addr,HAL_OP_HEALTH_CONNECT_CHANNEL , sizeof(cmd), &cmd, &len, &rsp, NULL); -if (status ==HAL_STATUS_SUCCESS ) +if (status ==BT_STATUS_SUCCESS ) *channel_id = rsp.channel_id;return status;
Signature · 1 line
1.8.3.2
PATCH 2/11 android/hal-health: Fix copying empty string
In reply to Ravi kumar VeeramallyMDEP desciption is optional. So check before copying.
--- android/hal-health.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
android/hal-health.c +6 -2
@@ -101,9 +101,13 @@ static bt_status_t register_application(bthl_reg_param_t *reg, int *app_id) mdep->role = reg->mdep_cfg[i].mdep_role; mdep->data_type = reg->mdep_cfg[i].data_type; mdep->channel_type = reg->mdep_cfg[i].channel_type; - mdep->descr_len =strlen (reg->mdep_cfg[i].mdep_description) +1 ; -memcpy (mdep->descr, reg->mdep_cfg[i].mdep_description, + +if (reg->mdep_cfg[i].mdep_description) { + mdep->descr_len = +strlen (reg->mdep_cfg[i].mdep_description) +1 ; +memcpy (mdep->descr, reg->mdep_cfg[i].mdep_description, mdep->descr_len); + } status = hal_ipc_cmd(HAL_SERVICE_ID_HEALTH, HAL_OP_HEALTH_MDEP, sizeof(*mdep) + mdep->descr_len,
Signature · 1 line
1.8.3.2
PATCH 3/11 android/hal-msg: Add mdep role and channel type defines
In reply to Ravi kumar Veeramally--- android/hal-msg.h | 7 +++++++ 1 file changed, 7 insertions(+)
android/hal-msg.h +7 -0
@@ -383,6 +383,13 @@ struct hal_cmd_pan_disconnect {uint8_t bdaddr[6 ]; } __attribute__((packed)); +#define HAL_HEALTH_MDEP_ROLE_SOURCE 0x00 +#define HAL_HEALTH_MDEP_ROLE_SINK 0x01 + +#define HAL_HEALTH_CHANNEL_TYPE_RELIABLE 0x00 +#define HAL_HEALTH_CHANNEL_TYPE_STREAMING 0x01 +#define HAL_HEALTH_CHANNEL_TYPE_ANY 0x02 +#define HAL_OP_HEALTH_REG_APP 0x01struct hal_cmd_health_reg_app {uint8_t num_of_mdep;
Signature · 1 line
1.8.3.2
PATCH 4/11 android/health: Fix wrong boolean value for command handler
In reply to Ravi kumar Veeramallybt_health_register_app contains variable data.
--- android/health.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
android/health.c +1 -1
@@ -80,7 +80,7 @@ static void bt_health_destroy_channel(const void *buf, uint16_t len)static const struct ipc_handler cmd_handlers[] = {/* HAL_OP_HEALTH_REG_APP */ - { bt_health_register_app, false, + { bt_health_register_app, true,sizeof (struct hal_cmd_health_reg_app ) },/* HAL_OP_HEALTH_UNREG_APP */ { bt_health_unregister_app, false,
Signature · 1 line
1.8.3.2
PATCH 5/11 android/health: Add initial function for HAL_OP_HEALTH_MDEP command
In reply to Ravi kumar Veeramally--- android/health.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
android/health.c +11 -0
@@ -54,6 +54,14 @@ static void bt_health_register_app(const void *buf, uint16_t len) HAL_STATUS_UNSUPPORTED); } +static void bt_health_mdep_cfg_data (const void *buf,uint16_t len) +{ +DBG ("Not implemented" ); + +ipc_send_rsp (hal_ipc,HAL_SERVICE_ID_HEALTH ,HAL_OP_HEALTH_MDEP , +HAL_STATUS_UNSUPPORTED ); +} +static void bt_health_unregister_app (const void *buf,uint16_t len) {DBG ("Not implemented" );
@@ -82,6 +90,9 @@ static const struct ipc_handler cmd_handlers[] = {/* HAL_OP_HEALTH_REG_APP */ { bt_health_register_app, true, sizeof(struct hal_cmd_health_reg_app) }, +/* HAL_OP_HEALTH_MDEP */ + { bt_health_mdep_cfg_data, true, + sizeof(struct hal_cmd_health_mdep) },/* HAL_OP_HEALTH_UNREG_APP */ { bt_health_unregister_app, false, sizeof(struct hal_cmd_health_unreg_app) },
Signature · 1 line
1.8.3.2
PATCH 6/11 android/client: Add initial support for health profile
In reply to Ravi kumar Veeramally--- android/Makefile.am | 1 + android/client/haltest.c | 1 + android/client/if-bt.c | 3 +-- android/client/if-hl.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++ android/client/if-main.h | 2 ++ 5 files changed, 69 insertions(+), 2 deletions(-) create mode 100644 android/client/if-hl.c
android/Makefile.am +1 -0
@@ -105,6 +105,7 @@ android_haltest_SOURCES = android/client/haltest.c \ android/client/if-hf.c \ android/client/if-hh.c \ android/client/if-pan.c \ + android/client/if-hl.c \ android/client/if-sock.c \ android/client/if-audio.c \ android/hardware/hardware.c \
android/client/haltest.c +1 -0
@@ -41,6 +41,7 @@ const struct interface *interfaces[] = { &hf_if, &hh_if, &pan_if, + &hl_if, &sock_if, NULL };
android/client/if-bt.c +1 -2
@@ -737,7 +737,6 @@ static void get_profile_interface_p(int argc, const char **argv) {const char *id;const void **pif =NULL ; -const void *dummy =NULL ;RETURN_IF_NULL (if_bluetooth);if (argc <=2 ) {
@@ -752,7 +751,7 @@ static void get_profile_interface_p(int argc, const char **argv)else if (strcmp (BT_PROFILE_ADVANCED_AUDIO_ID , id) ==0 ) pif = (const void **) &if_av;else if (strcmp (BT_PROFILE_HEALTH_ID , id) ==0 ) - pif = &dummy;/* TODO: change when if_hl is there */ + pif = (const void **) &if_hl;else if (strcmp (BT_PROFILE_SOCKETS_ID , id) ==0 ) pif = (const void **) &if_sock;else if (strcmp (BT_PROFILE_HIDHOST_ID , id) ==0 )
android/client/if-hl.c new file +64 -0
64 lines not on this page · raw message
android/client/if-main.h +2 -0
@@ -52,6 +52,7 @@ extern const btrc_interface_t *if_rc;extern const bthf_interface_t *if_hf;extern const bthh_interface_t *if_hh;extern const btpan_interface_t *if_pan; +extern const bthl_interface_t *if_hl;extern const btsock_interface_t *if_sock;extern const btgatt_interface_t *if_gatt;extern const btgatt_server_interface_t *if_gatt_server;
@@ -77,6 +78,7 @@ extern const struct interface pan_if;extern const struct interface sock_if;extern const struct interface hf_if;extern const struct interface hh_if; +extern const struct interface hl_if;/* Interfaces that will show up in tool (first part of command line) */ extern const struct interface *interfaces[];
Signature · 1 line
1.8.3.2
PATCH 7/11 android/client: Add register_application support to haltest
In reply to Ravi kumar VeeramallyInput parameters contains many optional strings, so treating '-' as empty input. It makes input handling simpler.
--- android/client/if-hl.c | 136 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 136 insertions(+)
android/client/if-hl.c +136 -0
@@ -25,6 +25,17 @@#include "pollhandler.h" #include "../hal-utils.h" +SINTMAP(bthl_mdep_role_t, -1, "(unknown)") +DELEMENT (BTHL_MDEP_ROLE_SOURCE ), +DELEMENT (BTHL_MDEP_ROLE_SINK ), +ENDMAP + +SINTMAP(bthl_channel_type_t, -1, "(unknown)") +DELEMENT (BTHL_CHANNEL_TYPE_RELIABLE ), +DELEMENT (BTHL_CHANNEL_TYPE_STREAMING ), +DELEMENT (BTHL_CHANNEL_TYPE_ANY ), +ENDMAP +const bthl_interface_t *if_hl =NULL ;static bthl_callbacks_t hl_cbacks = {
@@ -42,6 +53,126 @@ static void init_p(int argc, const char **argv)EXEC (if_hl->init, &hl_cbacks); } +/* register_application */ + +static void register_application_p (int argc,const char **argv) +{ +bthl_reg_param_t *reg; +char *app_name, *provider_name, *srv_name, *srv_descr, *descr; +uint16_t len, i, mdep_argc_init, mdep_argc_off; +int app_id =-1 ; + +RETURN_IF_NULL (if_hl); + +if (argc <=2 ) { +haltest_error ("No app name is specified\n" ); +return ; + } + +if (argc <=3 ) { +haltest_error ("No provider is specified\n" ); +return ; + } + +if (argc <=4 ) { +haltest_error ("No service name is specified\n" ); +return ; + } + +if (argc <=5 ) { +haltest_error ("No service description is specified\n" ); +return ; + } + +if (argc <=6 ) { +haltest_error ("No num of mdeps is specified\n" ); +return ; + } + + +if (argc != ((atoi (argv[6 ]) *4 ) +6 )) { +haltest_error ("mdep cfg argumetns are not proper\n" ); +return ; + } + + reg = (bthl_reg_param_t *)malloc (sizeof (bthl_reg_param_t)); + + len =strlen (argv[2 ]) +1 ; + app_name = (char *)malloc (len); +strcpy (app_name, argv[2 ]); + app_name[len] ='\0' ; + reg->application_name = app_name; + +if (strcmp ("-" , argv[3 ])) { + len =strlen (argv[3 ]) +1 ; + provider_name = (char *)malloc (len); +strcpy (provider_name, argv[3 ]); + provider_name[len] ='\0' ; + reg->provider_name = provider_name; + }else { + reg->provider_name =NULL ; + } + +if (strcmp ("-" , argv[4 ])) { + len =strlen (argv[4 ]) +1 ; + srv_name = (char *)malloc (len); +strcpy (srv_name, argv[4 ]); + srv_name[len] ='\0' ; + reg->srv_name = srv_name; + }else { + reg->srv_name =NULL ; + } + +if (strcmp ("-" , argv[5 ])) { + len =strlen (argv[5 ]) +1 ; + srv_descr = (char *)malloc (len); +strcpy (srv_descr, argv[5 ]); + srv_descr[len] ='\0' ; + reg->srv_desp = srv_descr; + }else { + reg->srv_desp =NULL ; + } + + reg->number_of_mdeps =atoi (argv[6 ]); + + reg->mdep_cfg = (bthl_mdep_cfg_t *)malloc (reg->number_of_mdeps + *sizeof (bthl_mdep_cfg_t)); + mdep_argc_init =7 ; + +for (i =0 ; i < reg->number_of_mdeps; i++) { + mdep_argc_off = mdep_argc_init + (4 * i); + reg->mdep_cfg[i].mdep_role = +str2bthl_mdep_role_t (argv[mdep_argc_off]); + reg->mdep_cfg[i].data_type =atoi (argv[mdep_argc_off +1 ]); + reg->mdep_cfg[i].channel_type = +str2bthl_channel_type_t (argv[mdep_argc_off +2 ]); + +if (strcmp ("-" , argv[mdep_argc_off +3 ])) { + reg->mdep_cfg[i].mdep_description =NULL ; +continue ; + } + + len =strlen (argv[mdep_argc_off +3 ]) +1 ; + descr = (char *)malloc (len); +strcpy (descr, argv[mdep_argc_off +3 ]); + descr[len] ='\0' ; + reg->mdep_cfg[i].mdep_description = descr; + } + +EXEC (if_hl->register_application, reg, &app_id); + +/* free memory */ +for (i =0 ; i < reg->number_of_mdeps; i++) +free ((void *) reg->mdep_cfg[i].mdep_description); + +free (reg->mdep_cfg); +free ((void *) reg->application_name); +free ((void *) reg->provider_name); +free ((void *) reg->srv_name); +free ((void *) reg->srv_desp); +free (reg); +} +/* cleanup */ static void cleanup_p (int argc,const char **argv)
@@ -54,6 +185,11 @@ static void cleanup_p(int argc, const char **argv)static struct method methods[] = {STD_METHOD (init), +STD_METHODH (register_application, +"[input optional string paramerts like -]\n" +"<app_name> <provider_name> <srv_name> <srv_descr>\n" +"<num_of_mdeps>\n" +"[<mdep_role> <data_type> <channel_type> <mdep_descr>] ..." ),STD_METHOD (cleanup),END_METHOD };
Signature · 1 line
1.8.3.2
PATCH 8/11 android/client: Add unregister_application support to haltest
In reply to Ravi kumar Veeramally--- android/client/if-hl.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
android/client/if-hl.c +19 -0
@@ -173,6 +173,24 @@ static void register_application_p(int argc, const char **argv)free (reg); } +/* unregister_application */ + +static void unregister_application_p (int argc,const char **argv) +{ +uint32_t app_id; + +RETURN_IF_NULL (if_hl); + +if (argc <=2 ) { +haltest_error ("No app id is specified" ); +return ; + } + + app_id = (uint32_t )atoi (argv[2 ]); + +EXEC (if_hl->unregister_application, app_id); +} +/* cleanup */ static void cleanup_p (int argc,const char **argv)
@@ -190,6 +208,7 @@ static struct method methods[] = {"<app_name> <provider_name> <srv_name> <srv_descr>\n" "<num_of_mdeps>\n" "[<mdep_role> <data_type> <channel_type> <mdep_descr>] ..."), +STD_METHODH (unregister_application,"<app_id>" ),STD_METHOD (cleanup), END_METHOD };
Signature · 1 line
1.8.3.2
PATCH 9/11 android/client: Add connect_channel support to haltest
In reply to Ravi kumar Veeramally--- android/client/if-hl.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+)
android/client/if-hl.c +30 -0
@@ -191,6 +191,35 @@ static void unregister_application_p(int argc, const char **argv)EXEC (if_hl->unregister_application, app_id); } +/* connect_channel */ + +static void connect_channel_p (int argc,const char **argv) +{ +uint32_t app_id, mdep_cfg_index; +int channel_id =-1 ; +bt_bdaddr_t bd_addr; + +RETURN_IF_NULL (if_hl); + +if (argc <=2 ) { +haltest_error ("No app id is specified" ); +return ; + } + +VERIFY_ADDR_ARG (3 , &bd_addr); + +if (argc <=4 ) { +haltest_error ("No mdep cfg index is specified" ); +return ; + } + + app_id = (uint32_t )atoi (argv[2 ]); + mdep_cfg_index = (uint32_t )atoi (argv[4 ]); + +EXEC (if_hl->connect_channel, app_id, &bd_addr, mdep_cfg_index, + &channel_id); +} +/* cleanup */ static void cleanup_p (int argc,const char **argv)
@@ -209,6 +238,7 @@ static struct method methods[] = {"<num_of_mdeps>\n" "[<mdep_role> <data_type> <channel_type> <mdep_descr>] ..."),STD_METHODH (unregister_application,"<app_id>" ), +STD_METHODH (connect_channel,"<app_id> <bd_addr> <mdep_cfg_index>" ),STD_METHOD (cleanup), END_METHOD };
Signature · 1 line
1.8.3.2
PATCH 10/11 android/client: Add destroy_channel support to haltest
In reply to Ravi kumar Veeramally--- android/client/if-hl.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
android/client/if-hl.c +19 -0
@@ -220,6 +220,24 @@ static void connect_channel_p(int argc, const char **argv) &channel_id); } +/* destroy_channel */ + +static void destroy_channel_p (int argc,const char **argv) +{ +uint32_t channel_id; + +RETURN_IF_NULL (if_hl); + +if (argc <=2 ) { +haltest_error ("No channel id is specified" ); +return ; + } + + channel_id = (uint32_t )atoi (argv[2 ]); + +EXEC (if_hl->destroy_channel, channel_id); +} +/* cleanup */ static void cleanup_p (int argc,const char **argv)
@@ -239,6 +257,7 @@ static struct method methods[] = { "[<mdep_role> <data_type> <channel_type> <mdep_descr>] ..."),STD_METHODH (unregister_application,"<app_id>" ),STD_METHODH (connect_channel,"<app_id> <bd_addr> <mdep_cfg_index>" ), +STD_METHODH (destroy_channel,"<channel_id>" ),STD_METHOD (cleanup), END_METHOD };
Signature · 1 line
1.8.3.2
PATCH 11/11 android/client: Add health callbacks support for haltest
In reply to Ravi kumar Veeramally--- android/client/if-hl.c | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-)
android/client/if-hl.c +35 -2
@@ -36,12 +36,45 @@ SINTMAP(bthl_channel_type_t, -1, "(unknown)")DELEMENT (BTHL_CHANNEL_TYPE_ANY ), ENDMAP +SINTMAP(bthl_app_reg_state_t, -1, "(unknown)") +DELEMENT (BTHL_APP_REG_STATE_REG_SUCCESS ), +DELEMENT (BTHL_APP_REG_STATE_REG_FAILED ), +DELEMENT (BTHL_APP_REG_STATE_DEREG_SUCCESS ), +DELEMENT (BTHL_APP_REG_STATE_DEREG_FAILED ), +ENDMAP + +SINTMAP(bthl_channel_state_t, -1, "(unknown)") +DELEMENT (BTHL_CONN_STATE_CONNECTING ), +DELEMENT (BTHL_CONN_STATE_CONNECTED ), +DELEMENT (BTHL_CONN_STATE_DISCONNECTING ), +DELEMENT (BTHL_CONN_STATE_DISCONNECTED ), +DELEMENT (BTHL_CONN_STATE_DESTROYED ), +ENDMAP + const bthl_interface_t *if_hl = NULL; +static void app_reg_state_cb (int app_id,bthl_app_reg_state_t state) +{ +haltest_info ("%s: app_id=%d app_reg_state=%s\n" , __func__, + app_id,bthl_app_reg_state_t2str (state)); +} + +static void channel_state_cb (int app_id,bt_bdaddr_t *bd_addr, +int mdep_cfg_index,int channel_id, +bthl_channel_state_t state,int fd) +{ +char addr[MAX_ADDR_STR_LEN ]; + +haltest_info ("%s: app_id=%d bd_addr=%s mdep_cfg_index=%d\n" +"channel_id=%d channel_state=%s fd=%d\n" , __func__, + app_id,bt_bdaddr_t2str (bd_addr, addr), mdep_cfg_index, + channel_id,bthl_channel_state_t2str (state), fd); +} +static bthl_callbacks_t hl_cbacks = { .size =sizeof (hl_cbacks), - .app_reg_state_cb =NULL , - .channel_state_cb =NULL , + .app_reg_state_cb = app_reg_state_cb, + .channel_state_cb = channel_state_cb, };/* init */
Signature · 1 line
1.8.3.2
Hi Ravi,
Quoted 16 lines · On Tuesday 22 of April 2014 15:05:59 Ravi kumar Veeramally wrote:
v1: Patch set contains fixes and health profile support for
haltest.Ravi kumar Veeramally (11):
android/hal-health: Use correct enums android/hal-health: Fix copying empty string android/hal-msg: Add mdep role and channel type defines android/health: Fix wrong boolean value for command handler android/health: Add initial function forHAL_OP_HEALTH_MDEPcommand android/client: Add initial support for health profile android/client: Addregister_applicationsupport to haltest android/client: Addunregister_applicationsupport to haltest android/client: Addconnect_channelsupport to haltest android/client: Adddestroy_channelsupport to haltest android/client: Add health callbacks support for haltest
Quoted 11 lines
android/Makefile.am | 1 + android/client/haltest.c | 1 + android/client/if-bt.c | 3 +- android/client/if-hl.c | 301 +++++++++++++++++++++++++++++++++++++++++++++++ android/client/if-main.h | 2 + android/hal-health.c | 14 ++- android/hal-msg.h | 7 ++ android/health.c | 13 +- 8 files changed, 334 insertions(+), 8 deletions(-) create mode 100644 android/client/if-hl.c
I've pushed all patches, thanks. But I had to fix compilation for Android and some bugs in register application (which I also simplified a bit).
Signature · 2 lines
BR Szymon Janc
Hi Szymon,
Quoted 8 lines · Szymon Janc
android/hal-health.c | 14 ++- android/hal-msg.h | 7 ++ android/health.c | 13 +- 8 files changed, 334 insertions(+), 8 deletions(-)create mode 100644
android/client/if-hl.c
I've pushed all patches, thanks. But I had to fix compilation for Android and some bugs in register application (which I also simplified a bit).
Changes looks simpler, thanks.
- Ravi.