[PATCHv3 16/17] android/tester: Use generic connect callback for simple cases

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is usefull when no custom behavior and just simple pdu exchange
is needed.
---
 android/tester-avrcp.c   | 13 +------------
 android/tester-hdp.c     | 32 ++------------------------------
 android/tester-hidhost.c | 12 +-----------
 android/tester-main.c    | 10 ++++++++++
 android/tester-main.h    |  1 +
 android/tester-pan.c     | 13 +------------
 6 files changed, 16 insertions(+), 65 deletions(-)

diff --git a/android/tester-avrcp.c b/android/tester-avrcp.c
index 4a49bb0..a2ceff6 100644
--- a/android/tester-avrcp.c
+++ b/android/tester-avrcp.c
@@ -138,20 +138,9 @@ static struct emu_set_l2cap_data a2dp_setup_data = {
 	.user_data = &a2dp_data,
 };
 
-static void sdp_connect_request_cb(uint16_t handle, uint16_t cid,
-							void *user_data)
-{
-	struct emu_l2cap_cid_data *cid_data = user_data;
-
-	cid_data->handle = handle;
-	cid_data->cid = cid;
-
-	tester_handle_l2cap_data_exchange(cid_data);
-}
-
 static struct emu_set_l2cap_data sdp_setup_data = {
 	.psm = 1,
-	.func = sdp_connect_request_cb,
+	.func = tester_generic_connect_cb,
 	.user_data = &sdp_data,
 };
 
diff --git a/android/tester-hdp.c b/android/tester-hdp.c
index f021943..c9c5a78 100644
--- a/android/tester-hdp.c
+++ b/android/tester-hdp.c
@@ -243,16 +243,6 @@ static void hdp_unregister_app_action(void)
 	schedule_action_verification(step);
 }
 
-static void hdp_sdp_search_cb(uint16_t handle, uint16_t cid, void *user_data)
-{
-	struct emu_l2cap_cid_data *cid_data = user_data;
-
-	cid_data->handle = handle;
-	cid_data->cid = cid;
-
-	tester_handle_l2cap_data_exchange(cid_data);
-}
-
 static void mcap_ctrl_cid_hook_cb(const void *data, uint16_t len,
 							void *user_data)
 {
@@ -315,28 +305,10 @@ static void mcap_ctrl_connect_cb(uint16_t handle, uint16_t cid, void *user_data)
 								cid_data);
 }
 
-static void mcap_data_cid_hook_cb(const void *data, uint16_t len,
-							void *user_data)
-{
-}
-
-static void mcap_data_connect_cb(uint16_t handle, uint16_t cid, void *user_data)
-{
-	struct test_data *data = tester_get_data();
-	struct bthost *bthost = hciemu_client_get_host(data->hciemu);
-	struct emu_l2cap_cid_data *cid_data = user_data;
-
-	cid_data->handle = handle;
-	cid_data->cid = cid;
-
-	bthost_add_cid_hook(bthost, handle, cid, mcap_data_cid_hook_cb,
-								cid_data);
-}
-
 /* Emulate SDP (PSM = 1) */
 static struct emu_set_l2cap_data l2cap_setup_sdp_data = {
 	.psm = 1,
-	.func = hdp_sdp_search_cb,
+	.func = tester_generic_connect_cb,
 	.user_data = &sdp_cid_data,
 };
 
@@ -350,7 +322,7 @@ static struct emu_set_l2cap_data l2cap_setup_cc_data = {
 /* Emulate Data Channel (PSM = 0x1003) */
 static struct emu_set_l2cap_data l2cap_setup_dc_data = {
 	.psm = 0x1003,
-	.func = mcap_data_connect_cb,
+	.func = tester_generic_connect_cb,
 	.user_data = &data_cid_data,
 };
 
diff --git a/android/tester-hidhost.c b/android/tester-hidhost.c
index 9ee026a..4c8b4c6 100644
--- a/android/tester-hidhost.c
+++ b/android/tester-hidhost.c
@@ -135,16 +135,6 @@ static struct emu_l2cap_cid_data sdp_cid_data = {
 static struct emu_l2cap_cid_data ctrl_cid_data;
 static struct emu_l2cap_cid_data intr_cid_data;
 
-static void hid_sdp_search_cb(uint16_t handle, uint16_t cid, void *user_data)
-{
-	struct emu_l2cap_cid_data *cid_data = user_data;
-
-	cid_data->handle = handle;
-	cid_data->cid = cid;
-
-	tester_handle_l2cap_data_exchange(cid_data);
-}
-
 static void hid_prepare_reply_protocol_mode(struct emu_l2cap_cid_data *cid_data)
 {
 	struct test_data *t_data = tester_get_data();
@@ -247,7 +237,7 @@ static void hid_intr_connect_cb(uint16_t handle, uint16_t cid, void *user_data)
 /* Emulate SDP (PSM = 1) */
 static struct emu_set_l2cap_data l2cap_setup_sdp_data = {
 	.psm = 1,
-	.func = hid_sdp_search_cb,
+	.func = tester_generic_connect_cb,
 	.user_data = &sdp_cid_data,
 };
 
diff --git a/android/tester-main.c b/android/tester-main.c
index 0152374..c728f05 100644
--- a/android/tester-main.c
+++ b/android/tester-main.c
@@ -2175,6 +2175,16 @@ void tester_handle_l2cap_data_exchange(struct emu_l2cap_cid_data *cid_data)
 					emu_generic_cid_hook_cb, cid_data);
 }
 
+void tester_generic_connect_cb(uint16_t handle, uint16_t cid, void *user_data)
+{
+	struct emu_l2cap_cid_data *cid_data = user_data;
+
+	cid_data->handle = handle;
+	cid_data->cid = cid;
+
+	tester_handle_l2cap_data_exchange(cid_data);
+}
+
 static void rfcomm_connect_cb(uint16_t handle, uint16_t cid, void *user_data,
 								bool status)
 {
diff --git a/android/tester-main.h b/android/tester-main.h
index 8c619da..560277a 100644
--- a/android/tester-main.h
+++ b/android/tester-main.h
@@ -516,6 +516,7 @@ struct test_case {
 };
 
 void tester_handle_l2cap_data_exchange(struct emu_l2cap_cid_data *cid_data);
+void tester_generic_connect_cb(uint16_t handle, uint16_t cid, void *user_data);
 
 /* Get, remove test cases API */
 struct queue *get_bluetooth_tests(void);
diff --git a/android/tester-pan.c b/android/tester-pan.c
index 503b9ed..4c9354a 100644
--- a/android/tester-pan.c
+++ b/android/tester-pan.c
@@ -35,20 +35,9 @@ static struct emu_l2cap_cid_data cid_data = {
 	.pdu = pdus,
 };
 
-static void pan_connect_request_cb(uint16_t handle, uint16_t cid,
-							void *user_data)
-{
-	struct emu_l2cap_cid_data *cid_data = user_data;
-
-	cid_data->handle = handle;
-	cid_data->cid = cid;
-
-	tester_handle_l2cap_data_exchange(cid_data);
-}
-
 static struct emu_set_l2cap_data l2cap_setup_data = {
 	.psm = 15,
-	.func = pan_connect_request_cb,
+	.func = tester_generic_connect_cb,
 	.user_data = &cid_data,
 };
 
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux