Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH 15/15] android/tester: Add get remote FRIENDLY_NAME property fail test case
From: Grzegorz Kolodziejczyk @ 2014-01-13 17:12 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1389633161-11357-1-git-send-email-grzegorz.kolodziejczyk@tieto.com>

This adds remote FRIENDLY NAME property fail test case.
---
 android/android-tester.c | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/android/android-tester.c b/android/android-tester.c
index c2e5d40..559a8ec 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -1582,6 +1582,26 @@ static const struct generic_data
 	.expected_adapter_status = BT_STATUS_FAIL,
 };
 
+static struct priority_property remote_getprop_fname_props[] = {
+	{
+	.prop.type = BT_PROPERTY_REMOTE_VERSION_INFO,
+	.prop.val = NULL,
+	.prop.len = 0,
+	},
+};
+
+static const struct generic_data
+				bluetooth_remote_getprop_fname_fail_test = {
+	.expected_hal_cb.discovery_state_changed_cb =
+					remote_discovery_state_changed_cb,
+	.expected_hal_cb.device_found_cb = remote_get_property_device_found_cb,
+	.expected_hal_cb.remote_device_properties_cb =
+					remote_test_device_properties_cb,
+	.expected_cb_count = 3,
+	.expected_properties = remote_getprop_fname_props,
+	.expected_adapter_status = BT_STATUS_FAIL,
+};
+
 static bt_callbacks_t bt_callbacks = {
 	.size = sizeof(bt_callbacks),
 	.adapter_state_changed_cb = adapter_state_changed_cb,
@@ -2212,6 +2232,15 @@ static void test_remote_getprop_verinfo_fail(const void *test_data)
 	data->if_bluetooth->start_discovery();
 }
 
+static void test_remote_getprop_fname_fail(const void *test_data)
+{
+	struct test_data *data = tester_get_data();
+
+	init_test_conditions(data);
+
+	data->if_bluetooth->start_discovery();
+}
+
 /* Test Socket HAL */
 
 static void adapter_socket_state_changed_cb(bt_state_t state)
@@ -2878,6 +2907,11 @@ int main(int argc, char *argv[])
 				setup_enabled_adapter,
 				test_remote_getprop_verinfo_fail, teardown);
 
+	test_bredrle("Bluetooth RemDev Get FRIENDLY_NAME - Fail",
+				&bluetooth_remote_getprop_fname_fail_test,
+				setup_enabled_adapter,
+				test_remote_getprop_fname_fail, teardown);
+
 	test_bredrle("Socket Init", NULL, setup_socket_interface,
 						test_dummy, teardown);
 
-- 
1.8.5.2


^ permalink raw reply related

* [PATCH 14/15] android/tester: Add get remote VERINFO property fail test case
From: Grzegorz Kolodziejczyk @ 2014-01-13 17:12 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1389633161-11357-1-git-send-email-grzegorz.kolodziejczyk@tieto.com>

This adds remote VERSION INFO property fail test case.
---
 android/android-tester.c | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/android/android-tester.c b/android/android-tester.c
index 04329c2..c2e5d40 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -1562,6 +1562,26 @@ static const struct generic_data
 	.expected_adapter_status = BT_STATUS_FAIL,
 };
 
+static struct priority_property remote_getprop_verinfo_props[] = {
+	{
+	.prop.type = BT_PROPERTY_REMOTE_VERSION_INFO,
+	.prop.val = NULL,
+	.prop.len = 0,
+	},
+};
+
+static const struct generic_data
+				bluetooth_remote_getprop_verinfo_fail_test = {
+	.expected_hal_cb.discovery_state_changed_cb =
+					remote_discovery_state_changed_cb,
+	.expected_hal_cb.device_found_cb = remote_get_property_device_found_cb,
+	.expected_hal_cb.remote_device_properties_cb =
+					remote_test_device_properties_cb,
+	.expected_cb_count = 3,
+	.expected_properties = remote_getprop_verinfo_props,
+	.expected_adapter_status = BT_STATUS_FAIL,
+};
+
 static bt_callbacks_t bt_callbacks = {
 	.size = sizeof(bt_callbacks),
 	.adapter_state_changed_cb = adapter_state_changed_cb,
@@ -2183,6 +2203,15 @@ static void test_remote_getprop_disctimeout_fail(const void *test_data)
 	data->if_bluetooth->start_discovery();
 }
 
+static void test_remote_getprop_verinfo_fail(const void *test_data)
+{
+	struct test_data *data = tester_get_data();
+
+	init_test_conditions(data);
+
+	data->if_bluetooth->start_discovery();
+}
+
 /* Test Socket HAL */
 
 static void adapter_socket_state_changed_cb(bt_state_t state)
@@ -2844,6 +2873,11 @@ int main(int argc, char *argv[])
 				setup_enabled_adapter,
 				test_remote_getprop_disctimeout_fail, teardown);
 
+	test_bredrle("Bluetooth RemDev Get VERSION_INFO - Fail",
+				&bluetooth_remote_getprop_verinfo_fail_test,
+				setup_enabled_adapter,
+				test_remote_getprop_verinfo_fail, teardown);
+
 	test_bredrle("Socket Init", NULL, setup_socket_interface,
 						test_dummy, teardown);
 
-- 
1.8.5.2


^ permalink raw reply related

* [PATCH 13/15] android/tester: Add get remote DISCTIMEOUT property fail test case
From: Grzegorz Kolodziejczyk @ 2014-01-13 17:12 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1389633161-11357-1-git-send-email-grzegorz.kolodziejczyk@tieto.com>

This adds remote DISCOVERY TIMEOUT property fail test case.
---
 android/android-tester.c | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/android/android-tester.c b/android/android-tester.c
index f4acbd1..04329c2 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -1540,6 +1540,28 @@ static const struct generic_data
 	.expected_adapter_status = BT_STATUS_FAIL,
 };
 
+static uint32_t remote_getprop_disctimeout_val = 120;
+
+static struct priority_property remote_getprop_disctimeout_props[] = {
+	{
+	.prop.type = BT_PROPERTY_ADAPTER_DISCOVERY_TIMEOUT,
+	.prop.val = &remote_getprop_disctimeout_val,
+	.prop.len = sizeof(remote_getprop_disctimeout_val),
+	},
+};
+
+static const struct generic_data
+			bluetooth_remote_getprop_disctimeout_fail_test = {
+	.expected_hal_cb.discovery_state_changed_cb =
+					remote_discovery_state_changed_cb,
+	.expected_hal_cb.device_found_cb = remote_get_property_device_found_cb,
+	.expected_hal_cb.remote_device_properties_cb =
+					remote_test_device_properties_cb,
+	.expected_cb_count = 3,
+	.expected_properties = remote_getprop_disctimeout_props,
+	.expected_adapter_status = BT_STATUS_FAIL,
+};
+
 static bt_callbacks_t bt_callbacks = {
 	.size = sizeof(bt_callbacks),
 	.adapter_state_changed_cb = adapter_state_changed_cb,
@@ -2152,6 +2174,15 @@ static void test_remote_getprop_bonded_devices_success(const void *test_data)
 	data->if_bluetooth->start_discovery();
 }
 
+static void test_remote_getprop_disctimeout_fail(const void *test_data)
+{
+	struct test_data *data = tester_get_data();
+
+	init_test_conditions(data);
+
+	data->if_bluetooth->start_discovery();
+}
+
 /* Test Socket HAL */
 
 static void adapter_socket_state_changed_cb(bt_state_t state)
@@ -2808,6 +2839,11 @@ int main(int argc, char *argv[])
 			setup_enabled_adapter,
 			test_remote_getprop_bonded_devices_success, teardown);
 
+	test_bredrle("Bluetooth RemDev Get DISCOVERY_TIMEOUT - Fail",
+				&bluetooth_remote_getprop_disctimeout_fail_test,
+				setup_enabled_adapter,
+				test_remote_getprop_disctimeout_fail, teardown);
+
 	test_bredrle("Socket Init", NULL, setup_socket_interface,
 						test_dummy, teardown);
 
-- 
1.8.5.2


^ permalink raw reply related

* [PATCH 12/15] android/tester: Add get remote BONDED_DEV property fail test case
From: Grzegorz Kolodziejczyk @ 2014-01-13 17:12 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1389633161-11357-1-git-send-email-grzegorz.kolodziejczyk@tieto.com>

This adds remote BONDED DEVICES property fail test case.
---
 android/android-tester.c | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/android/android-tester.c b/android/android-tester.c
index 2295e20..f4acbd1 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -1520,6 +1520,26 @@ static const struct generic_data
 	.expected_adapter_status = BT_STATUS_FAIL,
 };
 
+static struct priority_property remote_getprop_bondeddev_props[] = {
+	{
+	.prop.type = BT_PROPERTY_ADAPTER_BONDED_DEVICES,
+	.prop.val = NULL,
+	.prop.len = 0,
+	},
+};
+
+static const struct generic_data
+			bluetooth_remote_getprop_bonded_devices_fail_test = {
+	.expected_hal_cb.discovery_state_changed_cb =
+					remote_discovery_state_changed_cb,
+	.expected_hal_cb.device_found_cb = remote_get_property_device_found_cb,
+	.expected_hal_cb.remote_device_properties_cb =
+					remote_test_device_properties_cb,
+	.expected_cb_count = 3,
+	.expected_properties = remote_getprop_bondeddev_props,
+	.expected_adapter_status = BT_STATUS_FAIL,
+};
+
 static bt_callbacks_t bt_callbacks = {
 	.size = sizeof(bt_callbacks),
 	.adapter_state_changed_cb = adapter_state_changed_cb,
@@ -2123,6 +2143,15 @@ static void test_remote_getprop_scanmode_fail(const void *test_data)
 	data->if_bluetooth->start_discovery();
 }
 
+static void test_remote_getprop_bonded_devices_success(const void *test_data)
+{
+	struct test_data *data = tester_get_data();
+
+	init_test_conditions(data);
+
+	data->if_bluetooth->start_discovery();
+}
+
 /* Test Socket HAL */
 
 static void adapter_socket_state_changed_cb(bt_state_t state)
@@ -2774,6 +2803,11 @@ int main(int argc, char *argv[])
 				setup_enabled_adapter,
 				test_remote_getprop_scanmode_fail, teardown);
 
+	test_bredrle("Bluetooth RemDev Get BONDED_DEVICES - Fail",
+			&bluetooth_remote_getprop_bonded_devices_fail_test,
+			setup_enabled_adapter,
+			test_remote_getprop_bonded_devices_success, teardown);
+
 	test_bredrle("Socket Init", NULL, setup_socket_interface,
 						test_dummy, teardown);
 
-- 
1.8.5.2


^ permalink raw reply related

* [PATCH 11/15] android/tester: Add get remote SCAN_MODE property fail test case
From: Grzegorz Kolodziejczyk @ 2014-01-13 17:12 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1389633161-11357-1-git-send-email-grzegorz.kolodziejczyk@tieto.com>

This adds remote SCAN MODE property fail test case.
---
 android/android-tester.c | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/android/android-tester.c b/android/android-tester.c
index cc7f58e..2295e20 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -1498,6 +1498,28 @@ static const struct generic_data
 	.expected_adapter_status = BT_STATUS_FAIL,
 };
 
+static bt_scan_mode_t remote_getprop_scanmode_val = BT_SCAN_MODE_CONNECTABLE;
+
+static struct priority_property remote_getprop_scanmode_props[] = {
+	{
+	.prop.type = BT_PROPERTY_ADAPTER_SCAN_MODE,
+	.prop.val = &remote_getprop_scanmode_val,
+	.prop.len = sizeof(remote_getprop_scanmode_val),
+	},
+};
+
+static const struct generic_data
+				bluetooth_remote_getprop_scanmode_fail_test = {
+	.expected_hal_cb.discovery_state_changed_cb =
+					remote_discovery_state_changed_cb,
+	.expected_hal_cb.device_found_cb = remote_get_property_device_found_cb,
+	.expected_hal_cb.remote_device_properties_cb =
+					remote_test_device_properties_cb,
+	.expected_cb_count = 3,
+	.expected_properties = remote_getprop_scanmode_props,
+	.expected_adapter_status = BT_STATUS_FAIL,
+};
+
 static bt_callbacks_t bt_callbacks = {
 	.size = sizeof(bt_callbacks),
 	.adapter_state_changed_cb = adapter_state_changed_cb,
@@ -2092,6 +2114,15 @@ static void test_remote_getprop_servrec_fail(const void *test_data)
 	data->if_bluetooth->start_discovery();
 }
 
+static void test_remote_getprop_scanmode_fail(const void *test_data)
+{
+	struct test_data *data = tester_get_data();
+
+	init_test_conditions(data);
+
+	data->if_bluetooth->start_discovery();
+}
+
 /* Test Socket HAL */
 
 static void adapter_socket_state_changed_cb(bt_state_t state)
@@ -2738,6 +2769,11 @@ int main(int argc, char *argv[])
 				setup_enabled_adapter,
 				test_remote_getprop_servrec_fail, teardown);
 
+	test_bredrle("Bluetooth RemDev Get SCAN_MODE - Fail",
+				&bluetooth_remote_getprop_scanmode_fail_test,
+				setup_enabled_adapter,
+				test_remote_getprop_scanmode_fail, teardown);
+
 	test_bredrle("Socket Init", NULL, setup_socket_interface,
 						test_dummy, teardown);
 
-- 
1.8.5.2


^ permalink raw reply related

* [PATCH 10/15] android/tester: Add get remote SERVREC property fail test case
From: Grzegorz Kolodziejczyk @ 2014-01-13 17:12 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1389633161-11357-1-git-send-email-grzegorz.kolodziejczyk@tieto.com>

This adds remote SERVICE RECORD property fail test case.
---
 android/android-tester.c | 40 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)

diff --git a/android/android-tester.c b/android/android-tester.c
index 51b9875..cc7f58e 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -1472,6 +1472,32 @@ static const struct generic_data
 	.expected_adapter_status = BT_STATUS_FAIL,
 };
 
+static bt_service_record_t remote_getprop_servrec_val = {
+	.uuid = { {0x00} },
+	.channel = 12,
+	.name = "bt_name",
+};
+
+static struct priority_property remote_getprop_servrec_props[] = {
+	{
+	.prop.type = BT_PROPERTY_SERVICE_RECORD,
+	.prop.val = &remote_getprop_servrec_val,
+	.prop.len = sizeof(remote_getprop_servrec_val),
+	},
+};
+
+static const struct generic_data
+				bluetooth_remote_getprop_servrec_fail_test = {
+	.expected_hal_cb.discovery_state_changed_cb =
+					remote_discovery_state_changed_cb,
+	.expected_hal_cb.device_found_cb = remote_get_property_device_found_cb,
+	.expected_hal_cb.remote_device_properties_cb =
+					remote_test_device_properties_cb,
+	.expected_cb_count = 3,
+	.expected_properties = remote_getprop_servrec_props,
+	.expected_adapter_status = BT_STATUS_FAIL,
+};
+
 static bt_callbacks_t bt_callbacks = {
 	.size = sizeof(bt_callbacks),
 	.adapter_state_changed_cb = adapter_state_changed_cb,
@@ -2057,6 +2083,15 @@ static void test_remote_getprop_bdaddr_fail(const void *test_data)
 	data->if_bluetooth->start_discovery();
 }
 
+static void test_remote_getprop_servrec_fail(const void *test_data)
+{
+	struct test_data *data = tester_get_data();
+
+	init_test_conditions(data);
+
+	data->if_bluetooth->start_discovery();
+}
+
 /* Test Socket HAL */
 
 static void adapter_socket_state_changed_cb(bt_state_t state)
@@ -2698,6 +2733,11 @@ int main(int argc, char *argv[])
 				setup_enabled_adapter,
 				test_remote_getprop_bdaddr_fail, teardown);
 
+	test_bredrle("Bluetooth RemDev Get SERVICE_RECORD - Fail",
+				&bluetooth_remote_getprop_servrec_fail_test,
+				setup_enabled_adapter,
+				test_remote_getprop_servrec_fail, teardown);
+
 	test_bredrle("Socket Init", NULL, setup_socket_interface,
 						test_dummy, teardown);
 
-- 
1.8.5.2


^ permalink raw reply related

* [PATCH 09/15] android/tester: Add get remote BDADDR property fail test case
From: Grzegorz Kolodziejczyk @ 2014-01-13 17:12 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1389633161-11357-1-git-send-email-grzegorz.kolodziejczyk@tieto.com>

This adds remote BDADDR property fail test case.
---
 android/android-tester.c | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)

diff --git a/android/android-tester.c b/android/android-tester.c
index b8c967f..51b9875 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -1448,6 +1448,30 @@ static const struct generic_data
 	.expected_adapter_status = BT_STATUS_SUCCESS,
 };
 
+static bt_bdaddr_t remote_getprop_bdaddr_val = {
+	.address = { 0x00, 0xaa, 0x01, 0x00, 0x00, 0x00 }
+};
+
+static struct priority_property remote_getprop_bdaddr_props[] = {
+	{
+	.prop.type = BT_PROPERTY_BDADDR,
+	.prop.val = &remote_getprop_bdaddr_val,
+	.prop.len = sizeof(remote_getprop_bdaddr_val),
+	},
+};
+
+static const struct generic_data
+				bluetooth_remote_getprop_bdaddr_fail_test = {
+	.expected_hal_cb.discovery_state_changed_cb =
+					remote_discovery_state_changed_cb,
+	.expected_hal_cb.device_found_cb = remote_get_property_device_found_cb,
+	.expected_hal_cb.remote_device_properties_cb =
+					remote_test_device_properties_cb,
+	.expected_cb_count = 3,
+	.expected_properties = remote_getprop_bdaddr_props,
+	.expected_adapter_status = BT_STATUS_FAIL,
+};
+
 static bt_callbacks_t bt_callbacks = {
 	.size = sizeof(bt_callbacks),
 	.adapter_state_changed_cb = adapter_state_changed_cb,
@@ -2024,6 +2048,15 @@ static void test_remote_getprop_timestamp_success(const void *test_data)
 	data->if_bluetooth->start_discovery();
 }
 
+static void test_remote_getprop_bdaddr_fail(const void *test_data)
+{
+	struct test_data *data = tester_get_data();
+
+	init_test_conditions(data);
+
+	data->if_bluetooth->start_discovery();
+}
+
 /* Test Socket HAL */
 
 static void adapter_socket_state_changed_cb(bt_state_t state)
@@ -2660,6 +2693,11 @@ int main(int argc, char *argv[])
 				setup_enabled_adapter,
 				test_remote_getprop_timestamp_success, teardown);
 
+	test_bredrle("Bluetooth RemDev Get BDADDR - Fail",
+				&bluetooth_remote_getprop_bdaddr_fail_test,
+				setup_enabled_adapter,
+				test_remote_getprop_bdaddr_fail, teardown);
+
 	test_bredrle("Socket Init", NULL, setup_socket_interface,
 						test_dummy, teardown);
 
-- 
1.8.5.2


^ permalink raw reply related

* [PATCH 08/15] android/tester: Add get remote TIMESTAMP property success test case
From: Grzegorz Kolodziejczyk @ 2014-01-13 17:12 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1389633161-11357-1-git-send-email-grzegorz.kolodziejczyk@tieto.com>

This adds remote TIMESTAMP property success test case.
---
 android/android-tester.c | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/android/android-tester.c b/android/android-tester.c
index d10f0a5..b8c967f 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -1427,6 +1427,27 @@ static const struct generic_data
 	.expected_adapter_status = BT_STATUS_SUCCESS,
 };
 
+static struct priority_property remote_getprop_timestamp_props[] = {
+	{
+	.prop.type = BT_PROPERTY_REMOTE_DEVICE_TIMESTAMP,
+	.prop.val = NULL,
+	.prop.len = 4,
+	},
+};
+
+static const struct generic_data
+			bluetooth_remote_getprop_timestamp_success_test = {
+	.expected_hal_cb.discovery_state_changed_cb =
+					remote_discovery_state_changed_cb,
+	.expected_hal_cb.device_found_cb = remote_get_property_device_found_cb,
+	.expected_hal_cb.remote_device_properties_cb =
+					remote_test_device_properties_cb,
+	.expected_cb_count = 3,
+	.expected_properties_num = 1,
+	.expected_properties = remote_getprop_timestamp_props,
+	.expected_adapter_status = BT_STATUS_SUCCESS,
+};
+
 static bt_callbacks_t bt_callbacks = {
 	.size = sizeof(bt_callbacks),
 	.adapter_state_changed_cb = adapter_state_changed_cb,
@@ -1994,6 +2015,15 @@ static void test_remote_getprop_rssi_success(const void *test_data)
 	data->if_bluetooth->start_discovery();
 }
 
+static void test_remote_getprop_timestamp_success(const void *test_data)
+{
+	struct test_data *data = tester_get_data();
+
+	init_test_conditions(data);
+
+	data->if_bluetooth->start_discovery();
+}
+
 /* Test Socket HAL */
 
 static void adapter_socket_state_changed_cb(bt_state_t state)
@@ -2625,6 +2655,11 @@ int main(int argc, char *argv[])
 				setup_enabled_adapter,
 				test_remote_getprop_rssi_success, teardown);
 
+	test_bredrle("Bluetooth RemDev Get TIMESTAMP - Success",
+				&bluetooth_remote_getprop_timestamp_success_test,
+				setup_enabled_adapter,
+				test_remote_getprop_timestamp_success, teardown);
+
 	test_bredrle("Socket Init", NULL, setup_socket_interface,
 						test_dummy, teardown);
 
-- 
1.8.5.2


^ permalink raw reply related

* [PATCH 07/15] android/tester: Add get remote RSSI property success test case
From: Grzegorz Kolodziejczyk @ 2014-01-13 17:12 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1389633161-11357-1-git-send-email-grzegorz.kolodziejczyk@tieto.com>

This adds remote RSSI property success test case.
---
 android/android-tester.c | 37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/android/android-tester.c b/android/android-tester.c
index 927d04c..d10f0a5 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -1404,6 +1404,29 @@ static const struct generic_data
 	.expected_adapter_status = BT_STATUS_SUCCESS,
 };
 
+static int32_t remote_getprop_rssi_val = -60;
+
+static struct priority_property remote_getprop_rssi_props[] = {
+	{
+	.prop.type = BT_PROPERTY_REMOTE_RSSI,
+	.prop.val = &remote_getprop_rssi_val,
+	.prop.len = sizeof(remote_getprop_rssi_val),
+	},
+};
+
+static const struct generic_data
+				bluetooth_remote_getprop_rssi_success_test = {
+	.expected_hal_cb.discovery_state_changed_cb =
+					remote_discovery_state_changed_cb,
+	.expected_hal_cb.device_found_cb = remote_get_property_device_found_cb,
+	.expected_hal_cb.remote_device_properties_cb =
+					remote_test_device_properties_cb,
+	.expected_cb_count = 3,
+	.expected_properties_num = 1,
+	.expected_properties = remote_getprop_rssi_props,
+	.expected_adapter_status = BT_STATUS_SUCCESS,
+};
+
 static bt_callbacks_t bt_callbacks = {
 	.size = sizeof(bt_callbacks),
 	.adapter_state_changed_cb = adapter_state_changed_cb,
@@ -1962,6 +1985,15 @@ static void test_remote_getprop_tod_success(const void *test_data)
 	data->if_bluetooth->start_discovery();
 }
 
+static void test_remote_getprop_rssi_success(const void *test_data)
+{
+	struct test_data *data = tester_get_data();
+
+	init_test_conditions(data);
+
+	data->if_bluetooth->start_discovery();
+}
+
 /* Test Socket HAL */
 
 static void adapter_socket_state_changed_cb(bt_state_t state)
@@ -2588,6 +2620,11 @@ int main(int argc, char *argv[])
 				setup_enabled_adapter,
 				test_remote_getprop_tod_success, teardown);
 
+	test_bredrle("Bluetooth RemDev Get REMOTE_RSSI - Success",
+				&bluetooth_remote_getprop_rssi_success_test,
+				setup_enabled_adapter,
+				test_remote_getprop_rssi_success, teardown);
+
 	test_bredrle("Socket Init", NULL, setup_socket_interface,
 						test_dummy, teardown);
 
-- 
1.8.5.2


^ permalink raw reply related

* [PATCH 06/15] android/tester: Add get remote TOD property success test case
From: Grzegorz Kolodziejczyk @ 2014-01-13 17:12 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1389633161-11357-1-git-send-email-grzegorz.kolodziejczyk@tieto.com>

This adds remote TOD property success test case.
---
 android/android-tester.c | 37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/android/android-tester.c b/android/android-tester.c
index 13470bd..927d04c 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -1381,6 +1381,29 @@ static const struct generic_data
 	.expected_adapter_status = BT_STATUS_SUCCESS,
 };
 
+static bt_device_type_t remote_getprop_tod_val = BT_DEVICE_DEVTYPE_BREDR;
+
+static struct priority_property remote_getprop_tod_props[] = {
+	{
+	.prop.type = BT_PROPERTY_TYPE_OF_DEVICE,
+	.prop.val = &remote_getprop_tod_val,
+	.prop.len = sizeof(remote_getprop_tod_val),
+	},
+};
+
+static const struct generic_data
+				bluetooth_remote_getprop_tod_success_test = {
+	.expected_hal_cb.discovery_state_changed_cb =
+					remote_discovery_state_changed_cb,
+	.expected_hal_cb.device_found_cb = remote_get_property_device_found_cb,
+	.expected_hal_cb.remote_device_properties_cb =
+					remote_test_device_properties_cb,
+	.expected_cb_count = 3,
+	.expected_properties_num = 1,
+	.expected_properties = remote_getprop_tod_props,
+	.expected_adapter_status = BT_STATUS_SUCCESS,
+};
+
 static bt_callbacks_t bt_callbacks = {
 	.size = sizeof(bt_callbacks),
 	.adapter_state_changed_cb = adapter_state_changed_cb,
@@ -1930,6 +1953,15 @@ static void test_remote_getprop_cod_success(const void *test_data)
 	data->if_bluetooth->start_discovery();
 }
 
+static void test_remote_getprop_tod_success(const void *test_data)
+{
+	struct test_data *data = tester_get_data();
+
+	init_test_conditions(data);
+
+	data->if_bluetooth->start_discovery();
+}
+
 /* Test Socket HAL */
 
 static void adapter_socket_state_changed_cb(bt_state_t state)
@@ -2551,6 +2583,11 @@ int main(int argc, char *argv[])
 				setup_enabled_adapter,
 				test_remote_getprop_cod_success, teardown);
 
+	test_bredrle("Bluetooth RemDev Get TYPE_OF_DEVICE - Success",
+				&bluetooth_remote_getprop_tod_success_test,
+				setup_enabled_adapter,
+				test_remote_getprop_tod_success, teardown);
+
 	test_bredrle("Socket Init", NULL, setup_socket_interface,
 						test_dummy, teardown);
 
-- 
1.8.5.2


^ permalink raw reply related

* [PATCH 05/15] android/tester: Add get remote COD property success test case
From: Grzegorz Kolodziejczyk @ 2014-01-13 17:12 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1389633161-11357-1-git-send-email-grzegorz.kolodziejczyk@tieto.com>

This adds remote COD property success test case.
---
 android/android-tester.c | 37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/android/android-tester.c b/android/android-tester.c
index a4dac42..13470bd 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -1358,6 +1358,29 @@ static const struct generic_data
 	.expected_adapter_status = BT_STATUS_SUCCESS,
 };
 
+static uint32_t remote_getprop_cod_val = 0;
+
+static struct priority_property remote_getprop_cod_props[] = {
+	{
+	.prop.type = BT_PROPERTY_CLASS_OF_DEVICE,
+	.prop.val = &remote_getprop_cod_val,
+	.prop.len = sizeof(remote_getprop_cod_val),
+	},
+};
+
+static const struct generic_data
+				bluetooth_remote_getprop_cod_success_test = {
+	.expected_hal_cb.discovery_state_changed_cb =
+					remote_discovery_state_changed_cb,
+	.expected_hal_cb.device_found_cb = remote_get_property_device_found_cb,
+	.expected_hal_cb.remote_device_properties_cb =
+					remote_test_device_properties_cb,
+	.expected_cb_count = 3,
+	.expected_properties_num = 1,
+	.expected_properties = remote_getprop_cod_props,
+	.expected_adapter_status = BT_STATUS_SUCCESS,
+};
+
 static bt_callbacks_t bt_callbacks = {
 	.size = sizeof(bt_callbacks),
 	.adapter_state_changed_cb = adapter_state_changed_cb,
@@ -1898,6 +1921,15 @@ static void test_remote_getprop_uuids_success(const void *test_data)
 	data->if_bluetooth->start_discovery();
 }
 
+static void test_remote_getprop_cod_success(const void *test_data)
+{
+	struct test_data *data = tester_get_data();
+
+	init_test_conditions(data);
+
+	data->if_bluetooth->start_discovery();
+}
+
 /* Test Socket HAL */
 
 static void adapter_socket_state_changed_cb(bt_state_t state)
@@ -2514,6 +2546,11 @@ int main(int argc, char *argv[])
 				setup_enabled_adapter,
 				test_remote_getprop_uuids_success, teardown);
 
+	test_bredrle("Bluetooth RemDev Get CLASS_OF_DEVICE - Success",
+				&bluetooth_remote_getprop_cod_success_test,
+				setup_enabled_adapter,
+				test_remote_getprop_cod_success, teardown);
+
 	test_bredrle("Socket Init", NULL, setup_socket_interface,
 						test_dummy, teardown);
 
-- 
1.8.5.2


^ permalink raw reply related

* [PATCH 04/15] android/tester: Add get remote UUIDS property success test case
From: Grzegorz Kolodziejczyk @ 2014-01-13 17:12 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1389633161-11357-1-git-send-email-grzegorz.kolodziejczyk@tieto.com>

This adds remote UUIDS property success test case.
---
 android/android-tester.c | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/android/android-tester.c b/android/android-tester.c
index 674d3f6..a4dac42 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -1337,6 +1337,27 @@ static const struct generic_data
 	.expected_adapter_status = BT_STATUS_SUCCESS,
 };
 
+static struct priority_property remote_getprop_uuids_props[] = {
+	{
+	.prop.type = BT_PROPERTY_UUIDS,
+	.prop.val = NULL,
+	.prop.len = 0,
+	},
+};
+
+static const struct generic_data
+				bluetooth_remote_getprop_uuids_success_test = {
+	.expected_hal_cb.discovery_state_changed_cb =
+					remote_discovery_state_changed_cb,
+	.expected_hal_cb.device_found_cb = remote_get_property_device_found_cb,
+	.expected_hal_cb.remote_device_properties_cb =
+			remote_test_device_properties_cb,
+	.expected_cb_count = 3,
+	.expected_properties_num = 1,
+	.expected_properties = remote_getprop_uuids_props,
+	.expected_adapter_status = BT_STATUS_SUCCESS,
+};
+
 static bt_callbacks_t bt_callbacks = {
 	.size = sizeof(bt_callbacks),
 	.adapter_state_changed_cb = adapter_state_changed_cb,
@@ -1868,6 +1889,15 @@ static void test_remote_getprop_bdname__success(const void *test_data)
 	data->if_bluetooth->start_discovery();
 }
 
+static void test_remote_getprop_uuids_success(const void *test_data)
+{
+	struct test_data *data = tester_get_data();
+
+	init_test_conditions(data);
+
+	data->if_bluetooth->start_discovery();
+}
+
 /* Test Socket HAL */
 
 static void adapter_socket_state_changed_cb(bt_state_t state)
@@ -2479,6 +2509,11 @@ int main(int argc, char *argv[])
 				setup_enabled_adapter,
 				test_remote_getprop_bdname__success, teardown);
 
+	test_bredrle("Bluetooth RemDev Get UUIDS - Success",
+				&bluetooth_remote_getprop_uuids_success_test,
+				setup_enabled_adapter,
+				test_remote_getprop_uuids_success, teardown);
+
 	test_bredrle("Socket Init", NULL, setup_socket_interface,
 						test_dummy, teardown);
 
-- 
1.8.5.2


^ permalink raw reply related

* [PATCH 03/15] android/tester: Add get remote BDNAME property success test case
From: Grzegorz Kolodziejczyk @ 2014-01-13 17:12 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1389633161-11357-1-git-send-email-grzegorz.kolodziejczyk@tieto.com>

This adds remote BDNAME property success test case.
---
 android/android-tester.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 56 insertions(+)

diff --git a/android/android-tester.c b/android/android-tester.c
index c051200..674d3f6 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -730,6 +730,25 @@ static void remote_get_properties_device_found_cb(int num_properties,
 	data->if_bluetooth->get_remote_device_properties(&remote_addr);
 }
 
+static void remote_get_property_device_found_cb(int num_properties, bt_property_t *properties)
+{
+	struct test_data *data = tester_get_data();
+	const struct generic_data *test = data->test_data;
+	bt_status_t status;
+	uint8_t *bdaddr = (uint8_t *)hciemu_get_client_bdaddr(data->hciemu);
+	bt_bdaddr_t remote_addr;
+
+	const bt_property_t prop = test->expected_properties[0].prop;
+
+	bdaddr2android((const bdaddr_t *)bdaddr, &remote_addr.address);
+
+	if (data->cb_count == 2)
+		data->cb_count--;
+
+	status = data->if_bluetooth->get_remote_device_property(&remote_addr, prop.type);
+	check_expected_status(status);
+}
+
 static void device_found_cb(int num_properties, bt_property_t *properties)
 {
 	struct test_data *data = tester_get_data();
@@ -1295,6 +1314,29 @@ static const struct generic_data
 	.expected_adapter_status = BT_STATUS_NOT_EXPECTED,
 };
 
+static char remote_getprop_bdname_val[] = "00:AA:01:01:00:00";
+
+static struct priority_property remote_getprop_bdname_props[] = {
+	{
+	.prop.type = BT_PROPERTY_BDNAME,
+	.prop.val = &remote_getprop_bdname_val,
+	.prop.len = sizeof(remote_getprop_bdname_val) - 1,
+	},
+};
+
+static const struct generic_data
+				bluetooth_remote_getprop_bdname_success_test = {
+	.expected_hal_cb.discovery_state_changed_cb =
+					remote_discovery_state_changed_cb,
+	.expected_hal_cb.device_found_cb = remote_get_property_device_found_cb,
+	.expected_hal_cb.remote_device_properties_cb =
+					remote_test_device_properties_cb,
+	.expected_cb_count = 3,
+	.expected_properties_num = 1,
+	.expected_properties = remote_getprop_bdname_props,
+	.expected_adapter_status = BT_STATUS_SUCCESS,
+};
+
 static bt_callbacks_t bt_callbacks = {
 	.size = sizeof(bt_callbacks),
 	.adapter_state_changed_cb = adapter_state_changed_cb,
@@ -1817,6 +1859,15 @@ static void test_remote_get_properties_success(const void *test_data)
 	data->if_bluetooth->start_discovery();
 }
 
+static void test_remote_getprop_bdname__success(const void *test_data)
+{
+	struct test_data *data = tester_get_data();
+
+	init_test_conditions(data);
+
+	data->if_bluetooth->start_discovery();
+}
+
 /* Test Socket HAL */
 
 static void adapter_socket_state_changed_cb(bt_state_t state)
@@ -2423,6 +2474,11 @@ int main(int argc, char *argv[])
 				setup_enabled_adapter,
 				test_remote_get_properties_success, teardown);
 
+	test_bredrle("Bluetooth RemDev Get BDNAME- Success",
+				&bluetooth_remote_getprop_bdname_success_test,
+				setup_enabled_adapter,
+				test_remote_getprop_bdname__success, teardown);
+
 	test_bredrle("Socket Init", NULL, setup_socket_interface,
 						test_dummy, teardown);
 
-- 
1.8.5.2


^ permalink raw reply related

* [PATCH 02/15] android/tester: Add get remote properties success test case
From: Grzegorz Kolodziejczyk @ 2014-01-13 17:12 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1389633161-11357-1-git-send-email-grzegorz.kolodziejczyk@tieto.com>

This adds remote properties success test case.
---
 android/android-tester.c | 128 ++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 127 insertions(+), 1 deletion(-)

diff --git a/android/android-tester.c b/android/android-tester.c
index 0e34117..c051200 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -631,6 +631,21 @@ static void discovery_device_found_state_changed_cb(bt_discovery_state_t state)
 	}
 }
 
+static void remote_discovery_state_changed_cb(
+						bt_discovery_state_t state)
+{
+	struct test_data *data = tester_get_data();
+
+	if (state == BT_DISCOVERY_STARTED && data->cb_count == 3) {
+		data->cb_count--;
+		return;
+	}
+	if (state == BT_DISCOVERY_STOPPED && data->cb_count == 1) {
+		data->cb_count--;
+		check_cb_count();
+	}
+}
+
 static void discovery_state_changed_cb(bt_discovery_state_t state)
 {
 	struct test_data *data = tester_get_data();
@@ -700,6 +715,21 @@ static void discovery_device_found_cb(int num_properties,
 	}
 }
 
+static void remote_get_properties_device_found_cb(int num_properties,
+						bt_property_t *properties)
+{
+	struct test_data *data = tester_get_data();
+	uint8_t *bdaddr = (uint8_t *)hciemu_get_client_bdaddr(data->hciemu);
+	bt_bdaddr_t remote_addr;
+
+	bdaddr2android((const bdaddr_t *)bdaddr, &remote_addr.address);
+
+	if (data->cb_count == 2)
+		data->cb_count--;
+
+	data->if_bluetooth->get_remote_device_properties(&remote_addr);
+}
+
 static void device_found_cb(int num_properties, bt_property_t *properties)
 {
 	struct test_data *data = tester_get_data();
@@ -735,6 +765,30 @@ static void adapter_properties_cb(bt_status_t status, int num_properties,
 	}
 }
 
+static void remote_test_device_properties_cb(
+				bt_status_t status, bt_bdaddr_t *bd_addr,
+				int num_properties, bt_property_t *properties)
+{
+	int i;
+
+	for (i = 0; i < num_properties; i++)
+		check_expected_property(properties[i]);
+}
+
+static void remote_device_properties_cb(bt_status_t status,
+				bt_bdaddr_t *bd_addr, int num_properties,
+				bt_property_t *properties)
+{
+	struct test_data *data = tester_get_data();
+	const struct generic_data *test = data->test_data;
+
+	if (data->test_init_done &&
+			test->expected_hal_cb.remote_device_properties_cb) {
+		test->expected_hal_cb.remote_device_properties_cb(status,
+					bd_addr, num_properties, properties);
+	}
+}
+
 static bt_bdaddr_t enable_done_bdaddr_val = { {0x00} };
 static const char enable_done_bdname_val[] = "BlueZ for Android";
 static bt_uuid_t enable_done_uuids_val = {
@@ -1183,11 +1237,69 @@ static const struct generic_data bluetooth_discovery_device_found_test = {
 	.expected_adapter_status = BT_STATUS_NOT_EXPECTED,
 };
 
+static const char remote_get_properties_bdname_val[] = "00:AA:01:01:00:00";
+static uint32_t remote_get_properties_cod_val = 0;
+static bt_device_type_t remote_get_properties_tod_val = BT_DEVICE_DEVTYPE_BREDR;
+static int32_t remote_get_properties_rssi_val = -60;
+
+static struct priority_property remote_get_properties_props[] = {
+	{
+	.prop.type = BT_PROPERTY_BDNAME,
+	.prop.val = &remote_get_properties_bdname_val,
+	.prop.len = sizeof(remote_get_properties_bdname_val) - 1,
+	.prio = 1,
+	},
+	{
+	.prop.type = BT_PROPERTY_UUIDS,
+	.prop.val = NULL,
+	.prop.len = 0,
+	.prio = 2,
+	},
+	{
+	.prop.type = BT_PROPERTY_CLASS_OF_DEVICE,
+	.prop.val = &remote_get_properties_cod_val,
+	.prop.len = sizeof(remote_get_properties_cod_val),
+	.prio = 3,
+	},
+	{
+	.prop.type = BT_PROPERTY_TYPE_OF_DEVICE,
+	.prop.val = &remote_get_properties_tod_val,
+	.prop.len = sizeof(remote_get_properties_tod_val),
+	.prio = 4,
+	},
+	{
+	.prop.type = BT_PROPERTY_REMOTE_RSSI,
+	.prop.val = &remote_get_properties_rssi_val,
+	.prop.len = sizeof(remote_get_properties_rssi_val),
+	.prio = 5,
+	},
+	{
+	.prop.type = BT_PROPERTY_REMOTE_DEVICE_TIMESTAMP,
+	.prop.val = NULL,
+	.prop.len = 4,
+	.prio = 6,
+	},
+};
+
+static const struct generic_data
+				bluetooth_remote_get_properties_success_test = {
+	.expected_hal_cb.discovery_state_changed_cb =
+					remote_discovery_state_changed_cb,
+	.expected_hal_cb.device_found_cb =
+					remote_get_properties_device_found_cb,
+	.expected_hal_cb.remote_device_properties_cb =
+					remote_test_device_properties_cb,
+	.expected_cb_count = 3,
+	.expected_properties_num = 6,
+	.expected_properties = remote_get_properties_props,
+	.expected_adapter_status = BT_STATUS_NOT_EXPECTED,
+};
+
 static bt_callbacks_t bt_callbacks = {
 	.size = sizeof(bt_callbacks),
 	.adapter_state_changed_cb = adapter_state_changed_cb,
 	.adapter_properties_cb = adapter_properties_cb,
-	.remote_device_properties_cb = NULL,
+	.remote_device_properties_cb = remote_device_properties_cb,
 	.device_found_cb = device_found_cb,
 	.discovery_state_changed_cb = discovery_state_changed_cb,
 	.pin_request_cb = NULL,
@@ -1696,6 +1808,15 @@ static void test_discovery_device_found(const void *test_data)
 	data->if_bluetooth->start_discovery();
 }
 
+static void test_remote_get_properties_success(const void *test_data)
+{
+	struct test_data *data = tester_get_data();
+
+	init_test_conditions(data);
+
+	data->if_bluetooth->start_discovery();
+}
+
 /* Test Socket HAL */
 
 static void adapter_socket_state_changed_cb(bt_state_t state)
@@ -2297,6 +2418,11 @@ int main(int argc, char *argv[])
 				setup_enabled_adapter,
 				test_discovery_device_found, teardown);
 
+	test_bredrle("Bluetooth RemDev Get Properties - Success",
+				&bluetooth_remote_get_properties_success_test,
+				setup_enabled_adapter,
+				test_remote_get_properties_success, teardown);
+
 	test_bredrle("Socket Init", NULL, setup_socket_interface,
 						test_dummy, teardown);
 
-- 
1.8.5.2


^ permalink raw reply related

* [PATCH 01/15] android/tester: Fix for asynchronous test case condition check
From: Grzegorz Kolodziejczyk @ 2014-01-13 17:12 UTC (permalink / raw)
  To: linux-bluetooth

This patch fixes checking the state of test case. Due to asynchronous of
callbacks during state check of every single condition, state can be
checked double time by callback condition check with pass status already
set in mean time. Now state is kept as one decremented int.
To pass it must be equal zero and cannot be checked set again.
---
 android/android-tester.c | 47 ++++++++++++++++++++++-------------------------
 1 file changed, 22 insertions(+), 25 deletions(-)

diff --git a/android/android-tester.c b/android/android-tester.c
index 6f18e5c..0e34117 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -88,14 +88,13 @@ struct test_data {
 	const btsock_interface_t *if_sock;
 	const bthh_interface_t *if_hid;
 
-	bool mgmt_settings_set;
-	bool cb_count_checked;
-	bool status_checked;
-	bool property_checked;
+	uint8_t conditions_left;
 
 	/* Set to true if test conditions are initialized */
 	bool test_init_done;
 
+	bool test_result_set;
+
 	int cb_count;
 	GSList *expected_properties_list;
 };
@@ -106,20 +105,15 @@ static void test_update_state(void)
 {
 	struct test_data *data = tester_get_data();
 
-	if (!(data->cb_count_checked))
-		return;
-	if (!(data->mgmt_settings_set))
-		return;
-	if (!(data->status_checked))
-		return;
-	if (!(data->property_checked))
-		return;
-	tester_test_passed();
+	if (data->conditions_left == 0 && !data->test_result_set) {
+		data->test_result_set = true;
+		tester_test_passed();
+	}
 }
 
 static void test_mgmt_settings_set(struct test_data *data)
 {
-	data->mgmt_settings_set = true;
+	data->conditions_left--;
 
 	test_update_state();
 }
@@ -155,7 +149,7 @@ static void check_cb_count(void)
 		return;
 
 	if (data->cb_count == 0) {
-		data->cb_count_checked = true;
+		data->conditions_left--;
 		test_update_state();
 	}
 }
@@ -185,8 +179,9 @@ static void expected_status_init(struct test_data *data)
 {
 	const struct generic_data *test_data = data->test_data;
 
-	if (test_data->expected_adapter_status == BT_STATUS_NOT_EXPECTED)
-		data->status_checked = true;
+	if (test_data->expected_adapter_status == BT_STATUS_NOT_EXPECTED) {
+		data->conditions_left--;
+	}
 }
 
 static void test_property_init(struct test_data *data)
@@ -195,8 +190,8 @@ static void test_property_init(struct test_data *data)
 	GSList *l = data->expected_properties_list;
 	int i;
 
-	if (!test_data->expected_hal_cb.adapter_properties_cb) {
-		data->property_checked = true;
+	if (!test_data->expected_properties_num) {
+		data->conditions_left--;
 		return;
 	}
 
@@ -210,6 +205,8 @@ static void init_test_conditions(struct test_data *data)
 {
 	data->test_init_done = true;
 
+	data->conditions_left = 4;
+
 	expected_cb_count_init(data);
 	mgmt_cb_init(data);
 	expected_status_init(data);
@@ -222,7 +219,7 @@ static void check_expected_status(uint8_t status)
 	const struct generic_data *test_data = data->test_data;
 
 	if (test_data->expected_adapter_status == status) {
-		data->status_checked = true;
+		data->conditions_left--;
 		test_update_state();
 	} else
 		tester_test_failed();
@@ -278,6 +275,9 @@ static void check_expected_property(bt_property_t received_prop)
 	GSList *l = data->expected_properties_list;
 	GSList *found_exp_prop;
 
+	if (!g_slist_length(l))
+		return;
+
 	found_exp_prop = g_slist_find_custom(l, &received_prop,
 							&locate_property);
 
@@ -293,15 +293,13 @@ static void check_expected_property(bt_property_t received_prop)
 	if (g_slist_length(l))
 		return;
 
-	data->property_checked = true;
+	data->conditions_left--;
 	test_update_state();
 }
 
 static bool check_test_property(bt_property_t received_prop,
 						bt_property_t expected_prop)
 {
-	struct test_data *data = tester_get_data();
-
 	if (expected_prop.type && (expected_prop.type != received_prop.type))
 		return false;
 	if (expected_prop.len && (expected_prop.len != received_prop.len))
@@ -310,7 +308,7 @@ static bool check_test_property(bt_property_t received_prop,
 							expected_prop.len))
 		return false;
 
-	return data->property_checked = true;
+	return true;
 }
 
 static void read_info_callback(uint8_t status, uint16_t length,
@@ -1444,7 +1442,6 @@ static void test_getprop_bdname_success(const void *test_data)
 	init_test_conditions(data);
 
 	adapter_status = data->if_bluetooth->set_adapter_property(prop);
-	check_expected_status(adapter_status);
 
 	adapter_status = data->if_bluetooth->get_adapter_property((*prop).type);
 	check_expected_status(adapter_status);
-- 
1.8.5.2


^ permalink raw reply related

* [PATCH] l2test: Use correct buffer size
From: Andrei Emeltchenko @ 2014-01-13 16:39 UTC (permalink / raw)
  To: linux-bluetooth

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

---
 tools/l2test.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/l2test.c b/tools/l2test.c
index aaa1608..0993f74 100644
--- a/tools/l2test.c
+++ b/tools/l2test.c
@@ -782,7 +782,7 @@ static void dump_mode(int sk)
 		data_size = imtu;
 
 	if (defer_setup) {
-		len = read(sk, buf, sizeof(buf));
+		len = read(sk, buf, data_size);
 		if (len < 0)
 			syslog(LOG_ERR, "Initial read error: %s (%d)",
 						strerror(errno), errno);
@@ -842,7 +842,7 @@ static void recv_mode(int sk)
 		data_size = imtu;
 
 	if (defer_setup) {
-		len = read(sk, buf, sizeof(buf));
+		len = read(sk, buf, data_size);
 		if (len < 0)
 			syslog(LOG_ERR, "Initial read error: %s (%d)",
 						strerror(errno), errno);
-- 
1.8.3.2


^ permalink raw reply related

* [PATCH] scotest: Use correct buffer size
From: Andrei Emeltchenko @ 2014-01-13 16:34 UTC (permalink / raw)
  To: linux-bluetooth

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

---
 tools/scotest.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/scotest.c b/tools/scotest.c
index 69150b1..227287d 100644
--- a/tools/scotest.c
+++ b/tools/scotest.c
@@ -255,7 +255,7 @@ static void dump_mode(int sk)
 							strerror(errno), errno);
 
 	if (defer_setup) {
-		len = read(sk, buf, sizeof(buf));
+		len = read(sk, buf, data_size);
 		if (len < 0)
 			syslog(LOG_ERR, "Initial read error: %s (%d)",
 						strerror(errno), errno);
@@ -283,7 +283,7 @@ static void recv_mode(int sk)
 							strerror(errno), errno);
 
 	if (defer_setup) {
-		len = read(sk, buf, sizeof(buf));
+		len = read(sk, buf, data_size);
 		if (len < 0)
 			syslog(LOG_ERR, "Initial read error: %s (%d)",
 						strerror(errno), errno);
-- 
1.8.3.2


^ permalink raw reply related

* [PATCH] Bluetooth: Fix mgmt error code for negative PIN response
From: johan.hedberg @ 2014-01-13 15:15 UTC (permalink / raw)
  To: linux-bluetooth

From: Johan Hedberg <johan.hedberg@intel.com>

The NOT_PAIRED status is only really suitable for operations where being
paired is a pre-requisite. Using it e.g. for the mgmt_pair_device
command seems unintuitive. In the case that either the local or the
remote user responds with a negative PIN Code response the "PIN or Key
Missing" HCI status will be generated. This patch changes the mapping of
this status from the NOT_PAIRED mgmt status to the more intuitive
AUTH_FAILED mgmt status.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
I had trouble deciding whether we should use REJECTED or AUTH_FAILED
here, but eventually went with AUTH_FAILED. If someone thinks REJECTED
is better and has convincing reasons for it I can change it.

 net/bluetooth/mgmt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 4b6034fcc902..4ee07b432379 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -128,7 +128,7 @@ static u8 mgmt_status_table[] = {
 	MGMT_STATUS_FAILED,		/* Hardware Failure */
 	MGMT_STATUS_CONNECT_FAILED,	/* Page Timeout */
 	MGMT_STATUS_AUTH_FAILED,	/* Authentication Failed */
-	MGMT_STATUS_NOT_PAIRED,		/* PIN or Key Missing */
+	MGMT_STATUS_AUTH_FAILED,	/* PIN or Key Missing */
 	MGMT_STATUS_NO_RESOURCES,	/* Memory Full */
 	MGMT_STATUS_TIMEOUT,		/* Connection Timeout */
 	MGMT_STATUS_NO_RESOURCES,	/* Max Number of Connections */
-- 
1.8.4.2


^ permalink raw reply related

* Re: [PATCH] android/a2dp: Fix buffer size calculation for codec caps
From: Luiz Augusto von Dentz @ 2014-01-13 13:11 UTC (permalink / raw)
  To: Andrzej Kaczmarek; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <1389617627-4617-1-git-send-email-andrzej.kaczmarek@tieto.com>

Hi Andrzej,

On Mon, Jan 13, 2014 at 2:53 PM, Andrzej Kaczmarek
<andrzej.kaczmarek@tieto.com> wrote:
> ---
>  android/a2dp.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/android/a2dp.c b/android/a2dp.c
> index 05edd71..1f7678a 100644
> --- a/android/a2dp.c
> +++ b/android/a2dp.c
> @@ -415,7 +415,7 @@ static gboolean sep_getcap_ind(struct avdtp *session,
>         service = avdtp_service_cap_new(AVDTP_MEDIA_TRANSPORT, NULL, 0);
>         *caps = g_slist_append(*caps, service);
>
> -       codec = g_malloc0(sizeof(*codec) + sizeof(cap->len));
> +       codec = g_malloc0(sizeof(*codec) + cap->len);
>         codec->media_type = AVDTP_MEDIA_TYPE_AUDIO;
>         codec->media_codec_type = endpoint->codec;
>         memcpy(codec->data, cap->data, cap->len);
> --
> 1.8.5.2

Applied, thanks.


-- 
Luiz Augusto von Dentz

^ permalink raw reply

* [PATCH] android/a2dp: Fix buffer size calculation for codec caps
From: Andrzej Kaczmarek @ 2014-01-13 12:53 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Andrzej Kaczmarek

---
 android/a2dp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/android/a2dp.c b/android/a2dp.c
index 05edd71..1f7678a 100644
--- a/android/a2dp.c
+++ b/android/a2dp.c
@@ -415,7 +415,7 @@ static gboolean sep_getcap_ind(struct avdtp *session,
 	service = avdtp_service_cap_new(AVDTP_MEDIA_TRANSPORT, NULL, 0);
 	*caps = g_slist_append(*caps, service);
 
-	codec = g_malloc0(sizeof(*codec) + sizeof(cap->len));
+	codec = g_malloc0(sizeof(*codec) + cap->len);
 	codec->media_type = AVDTP_MEDIA_TYPE_AUDIO;
 	codec->media_codec_type = endpoint->codec;
 	memcpy(codec->data, cap->data, cap->len);
-- 
1.8.5.2


^ permalink raw reply related

* Re: [BlueZ v4 1/6] audio/A2DP: Add implemention of audio Open command
From: Luiz Augusto von Dentz @ 2014-01-13 12:35 UTC (permalink / raw)
  To: linux-bluetooth@vger.kernel.org
In-Reply-To: <1389615004-32612-1-git-send-email-luiz.dentz@gmail.com>

Hi,

On Mon, Jan 13, 2014 at 2:09 PM, Luiz Augusto von Dentz
<luiz.dentz@gmail.com> wrote:
> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
>
> ---
>  android/a2dp.c | 161 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
>  1 file changed, 160 insertions(+), 1 deletion(-)
>
> diff --git a/android/a2dp.c b/android/a2dp.c
> index b59c53d..b6b46e4 100644
> --- a/android/a2dp.c
> +++ b/android/a2dp.c
> @@ -52,9 +52,23 @@
>
>  static GIOChannel *server = NULL;
>  static GSList *devices = NULL;
> +static GSList *endpoints = NULL;
>  static bdaddr_t adapter_addr;
>  static uint32_t record_id = 0;
>
> +struct a2dp_preset {
> +       void *data;
> +       int8_t len;
> +};
> +
> +struct a2dp_endpoint {
> +       uint8_t id;
> +       uint8_t codec;
> +       struct avdtp_local_sep *sep;
> +       struct a2dp_preset *caps;
> +       GSList *presets;
> +};
> +
>  struct a2dp_device {
>         bdaddr_t        dst;
>         uint8_t         state;
> @@ -70,6 +84,29 @@ static int device_cmp(gconstpointer s, gconstpointer user_data)
>         return bacmp(&dev->dst, dst);
>  }
>
> +static void preset_free(void *data)
> +{
> +       struct a2dp_preset *preset = data;
> +
> +       g_free(preset->data);
> +       g_free(preset);
> +}
> +
> +static void unregister_endpoint(void *data)
> +{
> +       struct a2dp_endpoint *endpoint = data;
> +
> +       if (endpoint->sep)
> +               avdtp_unregister_sep(endpoint->sep);
> +
> +       if (endpoint->caps)
> +               preset_free(endpoint->caps);
> +
> +       g_slist_free_full(endpoint->presets, preset_free);
> +
> +       g_free(endpoint);
> +}
> +
>  static void a2dp_device_free(struct a2dp_device *dev)
>  {
>         if (dev->session)
> @@ -354,10 +391,129 @@ static sdp_record_t *a2dp_record(void)
>         return record;
>  }
>
> +static gboolean sep_getcap_ind(struct avdtp *session,
> +                                       struct avdtp_local_sep *sep,
> +                                       GSList **caps, uint8_t *err,
> +                                       void *user_data)
> +{
> +       struct a2dp_endpoint *endpoint = user_data;
> +       struct a2dp_preset *cap = endpoint->caps;
> +       struct avdtp_service_capability *service;
> +       struct avdtp_media_codec_capability *codec;
> +
> +       *caps = NULL;
> +
> +       service = avdtp_service_cap_new(AVDTP_MEDIA_TRANSPORT, NULL, 0);
> +       *caps = g_slist_append(*caps, service);
> +
> +       codec = g_malloc0(sizeof(*codec) + sizeof(cap->len));
> +       codec->media_type = AVDTP_MEDIA_TYPE_AUDIO;
> +       codec->media_codec_type = endpoint->codec;
> +       memcpy(codec->data, cap->data, cap->len);
> +
> +       service = avdtp_service_cap_new(AVDTP_MEDIA_CODEC, codec,
> +                                               sizeof(*codec) + cap->len);
> +       *caps = g_slist_append(*caps, service);
> +       g_free(codec);
> +
> +       return TRUE;
> +}
> +
> +static struct avdtp_sep_ind sep_ind = {
> +       .get_capability         = sep_getcap_ind,
> +};
> +
> +static uint8_t register_endpoint(const uint8_t *uuid, uint8_t codec,
> +                                                       GSList *presets)
> +{
> +       struct a2dp_endpoint *endpoint;
> +
> +       /* FIXME: Add proper check for uuid */
> +
> +       endpoint = g_new0(struct a2dp_endpoint, 1);
> +       endpoint->id = g_slist_length(endpoints) + 1;
> +       endpoint->codec = codec;
> +       endpoint->sep = avdtp_register_sep(AVDTP_SEP_TYPE_SOURCE,
> +                                               AVDTP_MEDIA_TYPE_AUDIO,
> +                                               codec, FALSE, &sep_ind, NULL,
> +                                               endpoint);
> +       endpoint->caps = presets->data;
> +       endpoint->presets = g_slist_copy(g_slist_nth(presets, 1));
> +
> +       endpoints = g_slist_append(endpoints, endpoint);
> +
> +       return endpoint->id;
> +}
> +
> +static GSList *parse_presets(const struct audio_preset *p, uint8_t count,
> +                                                               uint16_t len)
> +{
> +       GSList *l = NULL;
> +       uint8_t i;
> +
> +       for (i = 0; count > i; i++) {
> +               const uint8_t *ptr = (const uint8_t *) p;
> +               struct a2dp_preset *preset;
> +
> +               if (len < sizeof(struct audio_preset)) {
> +                       DBG("Invalid preset index %u", i);
> +                       g_slist_free_full(l, preset_free);
> +                       return NULL;
> +               }
> +
> +               len -= sizeof(struct audio_preset);
> +               if (len == 0 || len < p->len) {
> +                       DBG("Invalid preset size of %u for index %u", len, i);
> +                       g_slist_free_full(l, preset_free);
> +                       return NULL;
> +               }
> +
> +               preset = g_new0(struct a2dp_preset, 1);
> +               preset->len = p->len;
> +               preset->data = g_memdup(p->data, preset->len);
> +               l = g_slist_append(l, preset);
> +
> +               len -= preset->len;
> +               ptr += sizeof(*p) + preset->len;
> +               p = (const struct audio_preset *) ptr;
> +       }
> +
> +       return l;
> +}
> +
>  static void bt_audio_open(const void *buf, uint16_t len)
>  {
> -       DBG("Not Implemented");
> +       const struct audio_cmd_open *cmd = buf;
> +       struct audio_rsp_open rsp;
> +       GSList *presets;
>
> +       DBG("");
> +
> +       if (cmd->presets == 0) {
> +               error("No audio presets found");
> +               goto failed;
> +       }
> +
> +       presets = parse_presets(cmd->preset, cmd->presets, len - sizeof(*cmd));
> +       if (!presets) {
> +               error("No audio presets found");
> +               goto failed;
> +       }
> +
> +       rsp.id = register_endpoint(cmd->uuid, cmd->codec, presets);
> +       if (rsp.id == 0) {
> +               g_slist_free_full(presets, preset_free);
> +               error("Unable to register endpoint");
> +               goto failed;
> +       }
> +
> +       g_slist_free(presets);
> +
> +       audio_ipc_send_rsp_full(AUDIO_OP_OPEN, sizeof(rsp), &rsp, -1);
> +
> +       return;
> +
> +failed:
>         audio_ipc_send_rsp(AUDIO_OP_OPEN, AUDIO_STATUS_FAILED);
>  }
>
> @@ -471,6 +627,9 @@ void bt_a2dp_unregister(void)
>  {
>         DBG("");
>
> +       g_slist_free_full(endpoints, unregister_endpoint);
> +       endpoints = NULL;
> +
>         g_slist_foreach(devices, a2dp_device_disconnected, NULL);
>         devices = NULL;
>
> --
> 1.8.4.2

This set is now pushed upstream.



-- 
Luiz Augusto von Dentz

^ permalink raw reply

* [BlueZ v4 6/6] audio/A2DP: Add implemention of audio Suspend Stream command
From: Luiz Augusto von Dentz @ 2014-01-13 12:10 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1389615004-32612-1-git-send-email-luiz.dentz@gmail.com>

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

---
 android/a2dp.c | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/android/a2dp.c b/android/a2dp.c
index fee8b81..05edd71 100644
--- a/android/a2dp.c
+++ b/android/a2dp.c
@@ -808,8 +808,29 @@ failed:
 
 static void bt_stream_suspend(const void *buf, uint16_t len)
 {
-	DBG("Not Implemented");
+	const struct audio_cmd_suspend_stream *cmd = buf;
+	struct a2dp_setup *setup;
+	int err;
+
+	DBG("");
+
+	setup = find_setup(cmd->id);
+	if (!setup) {
+		error("Unable to find stream for endpoint %u", cmd->id);
+		goto failed;
+	}
+
+	err = avdtp_suspend(setup->dev->session, setup->stream);
+	if (err < 0) {
+		error("avdtp_suspend: %s", strerror(-err));
+		goto failed;
+	}
 
+	audio_ipc_send_rsp(AUDIO_OP_SUSPEND_STREAM, AUDIO_STATUS_SUCCESS);
+
+	return;
+
+failed:
 	audio_ipc_send_rsp(AUDIO_OP_SUSPEND_STREAM, AUDIO_STATUS_FAILED);
 }
 
-- 
1.8.4.2


^ permalink raw reply related

* [BlueZ v4 5/6] audio/A2DP: Add implemention of audio Resume Stream command
From: Luiz Augusto von Dentz @ 2014-01-13 12:10 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1389615004-32612-1-git-send-email-luiz.dentz@gmail.com>

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

---
 android/a2dp.c | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/android/a2dp.c b/android/a2dp.c
index ece5e47..fee8b81 100644
--- a/android/a2dp.c
+++ b/android/a2dp.c
@@ -780,8 +780,29 @@ failed:
 
 static void bt_stream_resume(const void *buf, uint16_t len)
 {
-	DBG("Not Implemented");
+	const struct audio_cmd_resume_stream *cmd = buf;
+	struct a2dp_setup *setup;
+	int err;
+
+	DBG("");
 
+	setup = find_setup(cmd->id);
+	if (!setup) {
+		error("Unable to find stream for endpoint %u", cmd->id);
+		goto failed;
+	}
+
+	err = avdtp_start(setup->dev->session, setup->stream);
+	if (err < 0) {
+		error("avdtp_start: %s", strerror(-err));
+		goto failed;
+	}
+
+	audio_ipc_send_rsp(AUDIO_OP_RESUME_STREAM, AUDIO_STATUS_SUCCESS);
+
+	return;
+
+failed:
 	audio_ipc_send_rsp(AUDIO_OP_RESUME_STREAM, AUDIO_STATUS_FAILED);
 }
 
-- 
1.8.4.2


^ permalink raw reply related

* [BlueZ v4 4/6] audio/A2DP: Add implemention of audio Close Stream command
From: Luiz Augusto von Dentz @ 2014-01-13 12:10 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1389615004-32612-1-git-send-email-luiz.dentz@gmail.com>

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

---
 android/a2dp.c | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/android/a2dp.c b/android/a2dp.c
index b26d727..ece5e47 100644
--- a/android/a2dp.c
+++ b/android/a2dp.c
@@ -752,8 +752,29 @@ static void bt_stream_open(const void *buf, uint16_t len)
 
 static void bt_stream_close(const void *buf, uint16_t len)
 {
-	DBG("Not Implemented");
+	const struct audio_cmd_close_stream *cmd = buf;
+	struct a2dp_setup *setup;
+	int err;
 
+	DBG("");
+
+	setup = find_setup(cmd->id);
+	if (!setup) {
+		error("Unable to find stream for endpoint %u", cmd->id);
+		goto failed;
+	}
+
+	err = avdtp_close(setup->dev->session, setup->stream, FALSE);
+	if (err < 0) {
+		error("avdtp_close: %s", strerror(-err));
+		goto failed;
+	}
+
+	audio_ipc_send_rsp(AUDIO_OP_CLOSE_STREAM, AUDIO_STATUS_SUCCESS);
+
+	return;
+
+failed:
 	audio_ipc_send_rsp(AUDIO_OP_CLOSE_STREAM, AUDIO_STATUS_FAILED);
 }
 
-- 
1.8.4.2


^ permalink raw reply related

* [BlueZ v4 3/6] audio/A2DP: Add implemention of audio Open Stream command
From: Luiz Augusto von Dentz @ 2014-01-13 12:10 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1389615004-32612-1-git-send-email-luiz.dentz@gmail.com>

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

---
 android/a2dp.c | 200 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 198 insertions(+), 2 deletions(-)

diff --git a/android/a2dp.c b/android/a2dp.c
index 354895a..b26d727 100644
--- a/android/a2dp.c
+++ b/android/a2dp.c
@@ -37,6 +37,7 @@
 #include "lib/bluetooth.h"
 #include "lib/sdp.h"
 #include "lib/sdp_lib.h"
+#include "profiles/audio/a2dp-codecs.h"
 #include "log.h"
 #include "a2dp.h"
 #include "hal-msg.h"
@@ -53,6 +54,7 @@
 static GIOChannel *server = NULL;
 static GSList *devices = NULL;
 static GSList *endpoints = NULL;
+static GSList *setups = NULL;
 static bdaddr_t adapter_addr;
 static uint32_t record_id = 0;
 
@@ -76,6 +78,13 @@ struct a2dp_device {
 	struct avdtp	*session;
 };
 
+struct a2dp_setup {
+	struct a2dp_device *dev;
+	struct a2dp_endpoint *endpoint;
+	struct a2dp_preset *preset;
+	struct avdtp_stream *stream;
+};
+
 static int device_cmp(gconstpointer s, gconstpointer user_data)
 {
 	const struct a2dp_device *dev = s;
@@ -419,8 +428,162 @@ static gboolean sep_getcap_ind(struct avdtp *session,
 	return TRUE;
 }
 
+static int sbc_check_config(struct a2dp_endpoint *endpoint,
+						struct a2dp_preset *conf)
+{
+	a2dp_sbc_t *caps, *config;
+
+	if (conf->len != sizeof(a2dp_sbc_t)) {
+		error("SBC: Invalid configuration size (%u)", conf->len);
+		return -EINVAL;
+	}
+
+	caps = endpoint->caps->data;
+	config = conf->data;
+
+	if (!(caps->frequency & config->frequency)) {
+		error("SBC: Unsupported frequency (%u) by endpoint",
+							config->frequency);
+		return -EINVAL;
+	}
+
+	if (!(caps->channel_mode & config->channel_mode)) {
+		error("SBC: Unsupported channel mode (%u) by endpoint",
+							config->channel_mode);
+		return -EINVAL;
+	}
+
+	if (!(caps->block_length & config->block_length)) {
+		error("SBC: Unsupported block length (%u) by endpoint",
+							config->block_length);
+		return -EINVAL;
+	}
+
+	if (!(caps->allocation_method & config->allocation_method)) {
+		error("SBC: Unsupported allocation method (%u) by endpoint",
+							config->block_length);
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
+static int check_config(struct a2dp_endpoint *endpoint,
+						struct a2dp_preset *config)
+{
+	GSList *l;
+
+	for (l = endpoint->presets; l; l = g_slist_next(l)) {
+		struct a2dp_preset *preset = l->data;
+
+		if (preset->len != config->len)
+			continue;
+
+		if (memcmp(preset->data, config->data, preset->len) == 0)
+			return 0;
+	}
+
+	/* Codec specific */
+	switch (endpoint->codec) {
+	case A2DP_CODEC_SBC:
+		return sbc_check_config(endpoint, config);
+	default:
+		return -EINVAL;
+	}
+}
+
+static struct a2dp_device *find_device_by_session(struct avdtp *session)
+{
+	GSList *l;
+
+	for (l = devices; l; l = g_slist_next(l)) {
+		struct a2dp_device *dev = l->data;
+
+		if (dev->session == session)
+			return dev;
+	}
+
+	return NULL;
+}
+
+static void setup_free(void *data)
+{
+	struct a2dp_setup *setup = data;
+
+	preset_free(setup->preset);
+	g_free(setup);
+}
+
+static void setup_add(struct a2dp_device *dev, struct a2dp_endpoint *endpoint,
+			struct a2dp_preset *preset, struct avdtp_stream *stream)
+{
+	struct a2dp_setup *setup;
+
+	setup = g_new0(struct a2dp_setup, 1);
+	setup->dev = dev;
+	setup->endpoint = endpoint;
+	setup->preset = preset;
+	setup->stream = stream;
+	setups = g_slist_append(setups, setup);
+}
+
+static gboolean sep_setconf_ind(struct avdtp *session,
+						struct avdtp_local_sep *sep,
+						struct avdtp_stream *stream,
+						GSList *caps,
+						avdtp_set_configuration_cb cb,
+						void *user_data)
+{
+	struct a2dp_endpoint *endpoint = user_data;
+	struct a2dp_device *dev;
+	struct a2dp_preset *preset = NULL;
+
+	DBG("");
+
+	dev = find_device_by_session(session);
+	if (!dev) {
+		error("Unable to find device for session %p", session);
+		return FALSE;
+	}
+
+	for (; caps != NULL; caps = g_slist_next(caps)) {
+		struct avdtp_service_capability *cap = caps->data;
+		struct avdtp_media_codec_capability *codec;
+
+		if (cap->category == AVDTP_DELAY_REPORTING)
+			return FALSE;
+
+		if (cap->category != AVDTP_MEDIA_CODEC)
+			continue;
+
+		codec = (struct avdtp_media_codec_capability *) cap->data;
+
+		if (codec->media_codec_type != endpoint->codec)
+			return FALSE;
+
+		preset = g_new0(struct a2dp_preset, 1);
+		preset->len = cap->length - sizeof(*codec);
+		preset->data = g_memdup(codec->data, preset->len);
+
+		if (check_config(endpoint, preset) < 0) {
+			preset_free(preset);
+			return FALSE;
+		}
+	}
+
+	if (!preset)
+		return FALSE;
+
+	setup_add(dev, endpoint, preset, stream);
+
+	cb(session, stream, NULL);
+
+	return TRUE;
+}
+
 static struct avdtp_sep_ind sep_ind = {
 	.get_capability		= sep_getcap_ind,
+	.set_configuration	= sep_setconf_ind,
 };
 
 static uint8_t register_endpoint(const uint8_t *uuid, uint8_t codec,
@@ -550,11 +713,41 @@ static void bt_audio_close(const void *buf, uint16_t len)
 	audio_ipc_send_rsp(AUDIO_OP_CLOSE, AUDIO_STATUS_SUCCESS);
 }
 
+static struct a2dp_setup *find_setup(uint8_t id)
+{
+	GSList *l;
+
+	for (l = setups; l; l = g_slist_next(l)) {
+		struct a2dp_setup *setup = l->data;
+
+		if (setup->endpoint->id == id)
+			return setup;
+	}
+
+	return NULL;
+}
+
 static void bt_stream_open(const void *buf, uint16_t len)
 {
-	DBG("Not Implemented");
+	const struct audio_cmd_open_stream *cmd = buf;
+	struct audio_rsp_open_stream *rsp;
+	struct a2dp_setup *setup;
+
+	DBG("");
 
-	audio_ipc_send_rsp(AUDIO_OP_OPEN_STREAM, AUDIO_STATUS_FAILED);
+	setup = find_setup(cmd->id);
+	if (!setup) {
+		error("Unable to find stream for endpoint %u", cmd->id);
+		audio_ipc_send_rsp(AUDIO_OP_OPEN_STREAM, AUDIO_STATUS_FAILED);
+		return;
+	}
+
+	len = sizeof(*rsp) + setup->preset->len;
+	rsp = g_malloc0(sizeof(*rsp) + setup->preset->len);
+	rsp->preset->len = setup->preset->len;
+	memcpy(rsp->preset->data, setup->preset->data, setup->preset->len);
+
+	audio_ipc_send_rsp_full(AUDIO_OP_OPEN_STREAM, len, rsp, -1);
 }
 
 static void bt_stream_close(const void *buf, uint16_t len)
@@ -653,6 +846,9 @@ void bt_a2dp_unregister(void)
 {
 	DBG("");
 
+	g_slist_free_full(setups, setup_free);
+	setups = NULL;
+
 	g_slist_free_full(endpoints, unregister_endpoint);
 	endpoints = NULL;
 
-- 
1.8.4.2


^ permalink raw reply related


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox