Skip to contentSkip to conversation

android/client/health: Write dummy data on fd

RFC New Ravi kumar Veeramally 1 participant 2 messages Jun 23, 2014 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

RFC 1/2 android/client/health: Write dummy data on fd

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

---
 android/client/if-hl.c | 24 +++++++++++++++++++-----
 1 file changed, 19 insertions(+), 5 deletions(-)
android/client/if-hl.c +19 -5
index 9c00a4d..92b18c5 100644
@@ -53,8 +53,8 @@ SINTMAP(bthl_channel_state_t, -1, "(unknown)")
 ENDMAP
 
 const bthl_interface_t *if_hl = NULL;
-static int fd_list[256] = {-1};
-
+ /* app_id {role, channel_id, fd} */
+static int app_list[256][2][3] = { { {-1} } };
 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__,
@@ -72,12 +72,23 @@ 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 (state == BTHL_CONN_STATE_CONNECTED)
-		fd_list[channel_id] = fd;
+	if (state == BTHL_CONN_STATE_CONNECTED) {
+		app_list[app_id][mdep_cfg_index][1] = channel_id;
+		app_list[app_id][mdep_cfg_index][2] = fd;
+
+		/*
+		 * PTS expects dummy data on fd when it
+		 * connects in source role.
+		 */
+		if (app_list[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");
+	}
 
 	if (state == BTHL_CONN_STATE_DISCONNECTED ||
 			state == BTHL_CONN_STATE_DESTROYED)
-		close(fd_list[channel_id]);
+		close(app_list[app_id][mdep_cfg_index][2]);
 }
 
 static bthl_callbacks_t hl_cbacks = {
@@ -172,6 +183,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_list[app_id][i][0] = reg.mdep_cfg[i].mdep_role;
+
 	free(reg.mdep_cfg);
 }
 
Signature · 1 line
1.9.1
#1 lore raw

RFC 2/2 android/health: Update PTS result

Update test results for TC_SRC_HCT_BV_01_I.

---
 android/pts-hdp.txt | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
android/pts-hdp.txt +10 -1
index e27d918..99aa2d6 100644
@@ -88,7 +88,16 @@ TC_SRC_CC_BV_07_C	PASS    haltest:
 				<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
Signature · 1 line
1.9.1