Skip to contentSkip to conversation

android/health: Fix wrong mdep config index

PATCH In review Ravi kumar Veeramally 2 participants 6 messages Jun 23, 2014 – Jun 24, 2014 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/5 android/health: Fix wrong mdep config index

MDEP Id starts from 1, (0 value for Echo). HAL api sends mdep cfg index which starts from 0.

---
 android/health.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
android/health.c +1 -1
index effa5e2..183608b 100644
@@ -137,7 +137,7 @@ static void send_channel_state_notify(struct health_channel *channel,
 
 	bdaddr2android(&channel->dev->dst, ev.bdaddr);
 	ev.app_id = channel->dev->app_id;
-	ev.mdep_index = channel->mdep_id;
+	ev.mdep_index = channel->mdep_id - 1;
 	ev.channel_id = channel->id;
 	ev.channel_state = state;
 
Signature · 1 line
1.9.1
#1 lore raw

PATCH 2/5 android/health: Fix error messages

---
 android/health.c | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)
android/health.c +13 -13
index 183608b..f45ae51 100644
@@ -661,7 +661,7 @@ static int update_sdp_record(struct health_app *app)
 		goto fail;
 
 	if (bt_adapter_add_record(rec, SVC_HINT_HEALTH) < 0) {
-		error("Failed to register HEALTH record");
+		error("health: Failed to register HEALTH record");
 		goto fail;
 	}
 
@@ -841,7 +841,7 @@ static void bt_health_mdep_cfg_data(const void *buf, uint16_t len)
 	 *    multile MDEP configurations ?
 	 */
 	if (update_sdp_record(app) < 0) {
-		error("Error creating HDP SDP record");
+		error("health: HDP SDP record preparation failed");
 		status = HAL_STATUS_FAILED;
 		goto fail;
 	}
@@ -1105,7 +1105,7 @@ static void create_mdl_cb(struct mcap_mdl *mdl, uint8_t type, GError *gerr,
 	 */
 	if (channel->type != type) {
 		/* TODO: abort mdl */
-		error("abort, channel-type requested %d, preferred %d not same",
+		error("health: channel type requested %d preferred %d not same",
 							channel->type, type);
 		goto fail;
 	}
@@ -1261,7 +1261,7 @@ static void create_mcl_cb(struct mcap_mcl *mcl, GError *err, gpointer data)
 	DBG("");
 
 	if (err) {
-		error("error creating MCL : %s", err->message);
+		error("health: error creating MCL : %s", err->message);
 		goto fail;
 	}
 
@@ -1269,7 +1269,7 @@ static void create_mcl_cb(struct mcap_mcl *mcl, GError *err, gpointer data)
 		channel->dev->mcl = mcap_mcl_ref(mcl);
 
 	channel->dev->mcl_conn = true;
-	DBG("MCL connected");
+	info("MCL connected");
 
 	ret = mcap_mcl_set_cb(channel->dev->mcl, channel, &gerr,
 			MCAP_MDL_CB_CONNECTED, mcap_mdl_connected_cb,
@@ -1280,7 +1280,7 @@ static void create_mcl_cb(struct mcap_mcl *mcl, GError *err, gpointer data)
 			MCAP_MDL_CB_REMOTE_RECONN_REQ, mcap_mdl_reconn_req_cb,
 			MCAP_MDL_CB_INVALID);
 	if (!ret) {
-		error("error setting mdl callbacks on mcl");
+		error("health: error setting mdl callbacks on mcl");
 
 		if (gerr)
 			g_error_free(gerr);
@@ -1307,23 +1307,23 @@ static void search_cb(sdp_list_t *recs, int err, gpointer data)
 	DBG("");
 
 	if (err < 0 || !recs) {
-		error("Error getting remote SDP records");
+		error("health: Error getting remote SDP records");
 		goto fail;
 	}
 
 	if (get_ccpsm(recs, &channel->dev->ccpsm) < 0) {
-		error("Can't get remote PSM for control channel");
+		error("health: Can't get remote PSM for control channel");
 		goto fail;
 	}
 
 	if (get_dcpsm(recs, &channel->dev->dcpsm) < 0) {
-		error("Can't get remote PSM for data channel");
+		error("health: Can't get remote PSM for data channel");
 		goto fail;
 	}
 
 	if (!mcap_create_mcl(mcap, &channel->dev->dst, channel->dev->ccpsm,
 					create_mcl_cb, channel, NULL, &gerr)) {
-		error("error creating mcl %s", gerr->message);
+		error("health: error creating mcl %s", gerr->message);
 
 		if (gerr)
 			g_error_free(gerr);
@@ -1478,14 +1478,14 @@ static void bt_health_connect_channel(const void *buf, uint16_t len)
 
 	if (!queue_length(dev->channels)) {
 		if (channel->type != CHANNEL_TYPE_RELIABLE) {
-			error("error, first data shannel should be reliable");
+			error("health: first data shannel should be reliable");
 			goto fail;
 		}
 	}
 
 	if (!dev->mcl) {
 		if (connect_mcl(channel) < 0) {
-			error("health:error retrieving HDP SDP record");
+			error("health: error retrieving HDP SDP record");
 			goto fail;
 		}
 	} else {
@@ -1571,7 +1571,7 @@ bool bt_health_register(struct ipc *ipc, const bdaddr_t *addr, uint8_t mode)
 					NULL, &err);
 
 	if (!mcap) {
-		error("Error creating MCAP instance : %s", err->message);
+		error("health: MCAP instance creation failed %s", err->message);
 		g_error_free(err);
 		return false;
 	}
Signature · 1 line
1.9.1
#2 lore raw

PATCH 3/5 android/client: Fix coding style

In reply to Ravi kumar Veeramally
---
 android/client/if-hl.c | 10 +++++-----
 android/client/if-rc.c |  8 ++++----
 2 files changed, 9 insertions(+), 9 deletions(-)
android/client/if-hl.c +5 -5
index c6374f1..d27afcc 100644
@@ -15,12 +15,12 @@
  *
  */
 
-#include<stdio.h>
-#include<ctype.h>
-#include<unistd.h>
+#include <stdio.h>
+#include <ctype.h>
+#include <unistd.h>
 
-#include<hardware/bluetooth.h>
-#include<hardware/bt_hl.h>
+#include <hardware/bluetooth.h>
+#include <hardware/bt_hl.h>
 
 #include "if-main.h"
 #include "pollhandler.h"
android/client/if-rc.c +4 -4
index cdf6311..afd90a3 100644
@@ -15,11 +15,11 @@
  *
  */
 
-#include<stdio.h>
-#include<ctype.h>
+#include <stdio.h>
+#include <ctype.h>
 
-#include<hardware/bluetooth.h>
-#include<hardware/bt_hh.h>
+#include <hardware/bluetooth.h>
+#include <hardware/bt_hh.h>
 
 #include "if-main.h"
 #include "pollhandler.h"
Signature · 1 line
1.9.1
#3 lore raw

PATCH 4/5 android/client/health: Write dummy data on fd

In reply to Ravi kumar Veeramally

PTS expects dummy data on fd when it connects in source role.

---
 android/client/if-hl.c | 39 +++++++++++++++++++++++++++++----------
 1 file changed, 29 insertions(+), 10 deletions(-)
android/client/if-hl.c +29 -10
index d27afcc..34e8b27 100644
@@ -52,10 +52,13 @@ SINTMAP(bthl_channel_state_t, -1, "(unknown)")
 	DELEMENT(BTHL_CONN_STATE_DESTROYED),
 ENDMAP
 
-#define FD_LIST_SIZE 256
+#define APP_ID_SIZE 256
+#define MDEP_CFG_SIZE 10
+#define ELEMENTS_SIZE 3
 
 const bthl_interface_t *if_hl = NULL;
-static int fd_list[FD_LIST_SIZE];
+/* app_id {mdep_cfg_index{role, channel_id, fd}} */
+static int app_info[APP_ID_SIZE][MDEP_CFG_SIZE][ELEMENTS_SIZE];
 
 static void app_reg_state_cb(int app_id, bthl_app_reg_state_t state)
 {
@@ -74,19 +77,30 @@ static void channel_state_cb(int app_id, bt_bdaddr_t *bd_addr,
 			app_id, bt_bdaddr_t2str(bd_addr, addr), mdep_cfg_index,
 			channel_id, bthl_channel_state_t2str(state), fd);
 
-	if (channel_id >= FD_LIST_SIZE)
+	if (app_id >= APP_ID_SIZE || mdep_cfg_index >= MDEP_CFG_SIZE)
 		return;
 
 	if (state == BTHL_CONN_STATE_CONNECTED) {
-		fd_list[channel_id] = fd;
+		app_info[app_id][mdep_cfg_index][1] = channel_id;
+		app_info[app_id][mdep_cfg_index][2] = fd;
+
+		/*
+		 * PTS expects dummy data on fd when it
+		 * connects in source role.
+		 */
+		if (app_info[app_id][mdep_cfg_index][0] ==
+				BTHL_MDEP_ROLE_SOURCE)
+			if (write(fd, "0", sizeof("0")) < 0)
+				haltest_error("writing data on fd failed\n");
+
 		return;
 	}
 
 	if (state == BTHL_CONN_STATE_DISCONNECTED ||
 			state == BTHL_CONN_STATE_DESTROYED) {
-		if (fd_list[channel_id] >= 0) {
-			close(fd_list[channel_id]);
-			fd_list[channel_id] = -1;
+		if (app_info[app_id][mdep_cfg_index][2] >= 0) {
+			close(app_info[app_id][mdep_cfg_index][2]);
+			app_info[app_id][mdep_cfg_index][2] = -1;
 		}
 	}
 }
@@ -101,10 +115,12 @@ static bthl_callbacks_t hl_cbacks = {
 
 static void init_p(int argc, const char **argv)
 {
-	int i;
+	int i, j, k;
 
-	for (i = 0; i < FD_LIST_SIZE; i++)
-		fd_list[i] = -1;
+	for (i = 0; i < APP_ID_SIZE; i++)
+		for (j = 0; j < MDEP_CFG_SIZE; j++)
+			for (k = 0; k < ELEMENTS_SIZE; k++)
+				app_info[i][j][k] = -1;
 
 	RETURN_IF_NULL(if_hl);
 
@@ -188,6 +204,9 @@ static void register_application_p(int argc, const char **argv)
 
 	EXEC(if_hl->register_application, &reg, &app_id);
 
+	for (i = 0; i < reg.number_of_mdeps; i++)
+		app_info[app_id][i][0] = reg.mdep_cfg[i].mdep_role;
+
 	free(reg.mdep_cfg);
 }
 
Signature · 1 line
1.9.1
#4 lore raw

PATCH 5/5 android/health: Update PTS results

In reply to Ravi kumar Veeramally

Update test results for TC_SRC_CC_BV_03_C, TC_SRC_CC_BV_07_C, TC_SNK_CC_BV_04_C, TC_SNK_HCT_BV_01_I, TC_SNK_CC_BV_08_C and TC_SRC_HCT_BV_01_I.

---
 android/pts-hdp.txt | 81 +++++++++++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 75 insertions(+), 6 deletions(-)
android/pts-hdp.txt +75 -6
index bdf8eca..99aa2d6 100644
@@ -58,12 +58,46 @@ TC_SRC_CC_BV_01_C	PASS	haltest:
 
 				when prompted: bluetooth ssp_reply <args>
 TC_SRC_CC_BV_02_C	PASS	when prompted: bluetooth ssp_reply <args>
-TC_SRC_CC_BV_03_C	INC
+TC_SRC_CC_BV_03_C	PASS    haltest:
+				hl register_application bluez-android Bluez
+				bluez-hdp health-device-profile 1
+				BTHL_MDEP_ROLE_SOURCE 4100
+				BTHL_CHANNEL_TYPE_RELIABLE pulse-oximeter
+
+				hl connect_channel <app_id> <bd_addr>
+				<mdep_cfg_index>
+
+				when prompted: bluetooth ssp_reply <args>
+
 TC_SRC_CC_BV_05_C	INC
-TC_SRC_CC_BV_07_C	INC
+TC_SRC_CC_BV_07_C	PASS    haltest:
+				hl register_application bluez-android Bluez
+				bluez-hdp health-device-profile 2
+				BTHL_MDEP_ROLE_SOURCE 4100
+				BTHL_CHANNEL_TYPE_RELIABLE pulse-oximeter
+				BTHL_MDEP_ROLE_SOURCE 4100
+				BTHL_CHANNEL_TYPE_STREAMING pulse-oximeter
+
+				hl connect_channel <app_id> <bd_addr>
+				<mdep_cfg_index>
+
+				when prompted: bluetooth ssp_reply <args>
+
+				when prompted:
+				hl connect_channel <app_id> <bd_addr>
+				<mdep_cfg_index>
 TC_SRC_CC_BV_09_C	INC
 TC_SRC_CC_BI_12_C	INC
-TC_SRC_HCT_BV_01_I	INC
+TC_SRC_HCT_BV_01_I	PASS    haltest:
+				hl register_application bluez-android Bluez
+				bluez-hdp health-device-profile 1
+				BTHL_MDEP_ROLE_SOURCE 4100
+				BTHL_CHANNEL_TYPE_RELIABLE pulse-oximeter
+
+				hl connect_channel <app_id> <bd_addr>
+				<mdep_cfg_index>
+
+				when prompted: bluetooth ssp_reply <args>
 TC_SRC_HCT_BV_02_I	INC
 TC_SRC_HCT_BV_03_I	N/A
 TC_SRC_HCT_BV_04_I	INC
@@ -113,12 +147,47 @@ TC_SNK_CC_BV_01_C	PASS	haltest:
 
 				when prompted: bluetooth ssp_reply <args>
 TC_SNK_CC_BV_02_C	PASS	when prompted: bluetooth ssp_reply <args>
-TC_SNK_CC_BV_04_C	INC
+TC_SNK_CC_BV_04_C	PASS    haltest:
+				hl register_application bluez-android Bluez
+				bluez-hdp health-device-profile 1
+				BTHL_MDEP_ROLE_SINK 4100
+				BTHL_CHANNEL_TYPE_RELIABLE pulse-oximeter
+
+				hl connect_channel <app_id> <bd_addr>
+				<mdep_cfg_index>
+
+				when prompted: bluetooth ssp_reply <args>
+
 TC_SNK_CC_BV_06_C	INC
-TC_SNK_CC_BV_08_C	INC
+TC_SNK_CC_BV_08_C	PASS    haltest:
+				hl register_application bluez-android Bluez
+				bluez-hdp health-device-profile 2
+				BTHL_MDEP_ROLE_SINK 4100
+				BTHL_CHANNEL_TYPE_RELIABLE pulse-oximeter
+				BTHL_MDEP_ROLE_SINK 4100
+				BTHL_CHANNEL_TYPE_STREAMING pulse-oximeter
+
+				hl connect_channel <app_id> <bd_addr>
+				<mdep_cfg_index>
+
+				when prompted: bluetooth ssp_reply <args>
+
+				when prompted:
+				hl connect_channel <app_id> <bd_addr>
+				<mdep_cfg_index>
+
 TC_SNK_CC_BV_10_C	INC
 TC_SNK_CC_BI_11_C	INC
-TC_SNK_HCT_BV_01_I	INC
+TC_SNK_HCT_BV_01_I	PASS    haltest:
+				hl register_application bluez-android Bluez
+				bluez-hdp health-device-profile 1
+				BTHL_MDEP_ROLE_SINK 4100
+				BTHL_CHANNEL_TYPE_RELIABLE pulse-oximeter
+
+				hl connect_channel <app_id> <bd_addr>
+				<mdep_cfg_index>
+
+				when prompted: bluetooth ssp_reply <args>
 TC_SNK_HCT_BV_02_I	INC
 TC_SNK_HCT_BV_03_I	N/A
 TC_SNK_HCT_BV_04_I	INC
Signature · 1 line
1.9.1
#5 lore raw
In reply to Ravi kumar Veeramally

Hi Ravi,

Quoted 12 lines · On Monday 23 of June 2014 18:06:00 Ravi kumar Veeramally wrote:

MDEP Id starts from 1, (0 value for Echo). HAL api sends mdep cfg index which starts from 0.

---
 android/health.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
android/health.c +0 -0
index effa5e2..183608b 100644

android/health.c static void send_channel_state_notify(struct health_channel *channel, · line 143

Quoted 8 lines
android/health.c +1 -1
@@ -137,7 +137,7 @@ static void send_channel_state_notify(struct health_channel *channel,
 
 	bdaddr2android(&channel->dev->dst, ev.bdaddr);
 	ev.app_id = channel->dev->app_id;
-	ev.mdep_index = channel->mdep_id;
+	ev.mdep_index = channel->mdep_id - 1;
 	ev.channel_id = channel->id;
 	ev.channel_state = state;
 

All patches applied, thanks.

Signature · 2 lines
Best regards, 
Szymon Janc