* [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
* [BlueZ v4 2/6] audio/A2DP: Add implemention of audio Close 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 | 30 ++++++++++++++++++++++++++++--
1 file changed, 28 insertions(+), 2 deletions(-)
diff --git a/android/a2dp.c b/android/a2dp.c
index b6b46e4..354895a 100644
--- a/android/a2dp.c
+++ b/android/a2dp.c
@@ -517,11 +517,37 @@ failed:
audio_ipc_send_rsp(AUDIO_OP_OPEN, AUDIO_STATUS_FAILED);
}
+static struct a2dp_endpoint *find_endpoint(uint8_t id)
+{
+ GSList *l;
+
+ for (l = endpoints; l; l = g_slist_next(l)) {
+ struct a2dp_endpoint *endpoint = l->data;
+
+ if (endpoint->id == id)
+ return endpoint;
+ }
+
+ return NULL;
+}
+
static void bt_audio_close(const void *buf, uint16_t len)
{
- DBG("Not Implemented");
+ const struct audio_cmd_close *cmd = buf;
+ struct a2dp_endpoint *endpoint;
+
+ DBG("");
+
+ endpoint = find_endpoint(cmd->id);
+ if (!endpoint) {
+ error("Unable to find endpoint %u", cmd->id);
+ audio_ipc_send_rsp(AUDIO_OP_CLOSE, AUDIO_STATUS_FAILED);
+ return;
+ }
+
+ unregister_endpoint(endpoint);
- audio_ipc_send_rsp(AUDIO_OP_CLOSE, HAL_STATUS_FAILED);
+ audio_ipc_send_rsp(AUDIO_OP_CLOSE, AUDIO_STATUS_SUCCESS);
}
static void bt_stream_open(const void *buf, uint16_t len)
--
1.8.4.2
^ permalink raw reply related
* [BlueZ v4 1/6] audio/A2DP: Add implemention of audio Open command
From: Luiz Augusto von Dentz @ 2014-01-13 12:09 UTC (permalink / raw)
To: linux-bluetooth
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
^ permalink raw reply related
* Re: Problems with Logitech V270 mouse
From: Luiz Augusto von Dentz @ 2014-01-13 11:19 UTC (permalink / raw)
To: Szymon Janc; +Cc: Jakub Jechanowski, linux-bluetooth@vger.kernel.org
In-Reply-To: <3017327.dufLGECPfA@uw000953>
Hi,
On Mon, Jan 13, 2014 at 12:37 PM, Szymon Janc <szymon.janc@tieto.com> wrote:
> On Thursday 02 of January 2014 23:55:25 Jakub Jechanowski wrote:
>> After pairing and connecting (bluetoothctl or bluetooth-wizard) mouse
>> works ok. But when I restart bluetoothd (or whole OS) mouse no longer
>> works. After touching the mouse, in bluetoothd log I get:
>>
>> bluetoothd[6418]: src/adapter.c:connected_callback() hci0 device
>> 00:07:61:68:55:27 connected eir_len 5
>> bluetoothd[6418]: src/device.c:device_create() dst 00:07:61:68:55:27
>> bluetoothd[6418]: src/device.c:device_new() address 00:07:61:68:55:27
>> bluetoothd[6418]: src/device.c:device_new() Creating device
>> /org/bluez/hci0/dev_00_07_61_68_55_27
>> bluetoothd[6418]: src/device.c:btd_device_set_temporary() temporary 1
>> bluetoothd[6418]: src/adapter.c:adapter_connect_list_remove() device
>> /org/bluez/hci0/dev_00_07_61_68_55_27 is not on the list, ignoring
>> bluetoothd[6418]: src/device.c:device_set_class()
>> /org/bluez/hci0/dev_00_07_61_68_55_27 0x002580
>> bluetoothd[6418]: profiles/input/server.c:connect_event_cb() Incoming
>> connection from 00:07:61:68:55:27 on PSM 17
>> bluetoothd[6418]: profiles/input/device.c:input_device_set_channel()
>> idev (nil) psm 17
>> bluetoothd[6418]: Refusing input device connect: No such file or directory (2)
>> bluetoothd[6418]: profiles/input/server.c:confirm_event_cb()
>> bluetoothd[6418]: Refusing connection from 00:07:61:68:55:27: unknown device
>> <<<few seconds of pause>>>
>> bluetoothd[6418]: src/adapter.c:dev_disconnected() Device
>> 00:07:61:68:55:27 disconnected, reason 2
>> bluetoothd[6418]: src/adapter.c:adapter_remove_connection()
>> bluetoothd[6418]: src/adapter.c:adapter_remove_connection() Removing
>> temporary device /org/bluez/hci0/dev_00_07_61_68_55_27
>> bluetoothd[6418]: src/device.c:device_remove() Removing device
>> /org/bluez/hci0/dev_00_07_61_68_55_27
>> bluetoothd[6418]: src/device.c:btd_device_unref() Freeing device
>> /org/bluez/hci0/dev_00_07_61_68_55_27
>> bluetoothd[6418]: src/device.c:device_free() 0x24a65e0
>> bluetoothd[6418]: src/adapter.c:bonding_attempt_complete() hci0 bdaddr
>> 00:07:61:68:55:27 type 0 status 0xe
>> bluetoothd[6418]: src/adapter.c:resume_discovery()
>>
>> ------------------------------------
>>
>> Log from btmon after touching mouse:
>>
>> > HCI Event: Connect Request (0x04) plen 10 [hci0] 9.133728
>> Address: 00:07:61:68:55:27 (Logitech Europe SA)
>> Class: 0x002580
>> Major class: Peripheral (mouse, joystick, keyboards)
>> Minor class: 0x20
>> Limited Discoverable Mode
>> Link type: ACL (0x01)
>> < HCI Command: Accept Connection Request (0x01|0x0009) plen 7 [hci0] 9.133770
>> Address: 00:07:61:68:55:27 (Logitech Europe SA)
>> Role: Master (0x00)
>> > HCI Event: Command Status (0x0f) plen 4 [hci0] 9.136727
>> Accept Connection Request (0x01|0x0009) ncmd 1
>> Status: Success (0x00)
>> > HCI Event: Role Change (0x12) plen 8 [hci0] 9.294753
>> Status: Success (0x00)
>> Address: 00:07:61:68:55:27 (Logitech Europe SA)
>> Role: Master (0x00)
>> > HCI Event: Connect Complete (0x03) plen 11 [hci0] 9.444736
>> Status: Success (0x00)
>> Handle: 11
>> Address: 00:07:61:68:55:27 (Logitech Europe SA)
>> Link type: ACL (0x01)
>> Encryption: Disabled (0x00)
>> < HCI Command: Read Remote Supported Fe.. (0x01|0x001b) plen 2 [hci0] 9.444839
>> Handle: 11
>> > HCI Event: Command Status (0x0f) plen 4 [hci0] 9.446731
>> Read Remote Supported Features (0x01|0x001b) ncmd 1
>> Status: Success (0x00)
>> > HCI Event: Read Remote Supported Features (0x0b) plen 11 [hci0] 9.448739
>> Status: Success (0x00)
>> Handle: 11
>> Features: 0xfc 0xff 0x0f 0x00 0x08 0x08 0x00 0x00
>> Encryption
>> Slot offset
>> Timing accuracy
>> Role switch
>> Hold mode
>> Sniff mode
>> Park state
>> Power control requests
>> Channel quality driven data rate (CQDDR)
>> SCO link
>> HV2 packets
>> HV3 packets
>> u-law log synchronous data
>> A-law log synchronous data
>> CVSD synchronous data
>> Paging parameter negotiation
>> Power control
>> Transparent synchronous data
>> AFH capable slave
>> AFH capable master
>> < HCI Command: Remote Name Request (0x01|0x0019) plen 10 [hci0] 9.448793
>> Address: 00:07:61:68:55:27 (Logitech Europe SA)
>> Page scan repetition mode: R2 (0x02)
>> Page scan mode: Mandatory (0x00)
>> Clock offset: 0x0000
>> > HCI Event: Command Status (0x0f) plen 4 [hci0] 9.449737
>> Remote Name Request (0x01|0x0019) ncmd 1
>> Status: Success (0x00)
>> > ACL Data RX: Handle 11 flags 0x02 dlen 12 [hci0] 9.477736
>> L2CAP: Connection Request (0x02) ident 1 len 4
>> PSM: 17 (0x0011)
>> Source CID: 64
>> < ACL Data TX: Handle 11 flags 0x02 dlen 16 [hci0] 9.477798
>> L2CAP: Connection Response (0x03) ident 1 len 8
>> Destination CID: 64
>> Source CID: 64
>> Result: Connection pending (0x0001)
>> Status: No further information available (0x0000)
>> < ACL Data TX: Handle 11 flags 0x02 dlen 10 [hci0] 9.477805
>> L2CAP: Information Request (0x0a) ident 1 len 2
>> Type: Extended features supported (0x0002)
>> @ Device Connected: 00:07:61:68:55:27 (0) flags 0x0000
>> 04 0d 80 25 00 ...%.
>> > HCI Event: Number of Completed Packets (0x13) plen 5 [hci0] 9.485716
>> Num handles: 1
>> Handle: 11
>> Count: 2
>> > ACL Data RX: Handle 11 flags 0x02 dlen 16 [hci0] 9.501737
>> L2CAP: Information Response (0x0b) ident 1 len 8
>> Type: Extended features supported (0x0002)
>> Result: Success (0x0000)
>> Features: 0x00000000
>> < ACL Data TX: Handle 11 flags 0x02 dlen 16 [hci0] 9.502107
>> L2CAP: Connection Response (0x03) ident 1 len 8
>> Destination CID: 64
>> Source CID: 64
>> Result: Connection successful (0x0000)
>> Status: No further information available (0x0000)
>> < ACL Data TX: Handle 11 flags 0x02 dlen 12 [hci0] 9.502113
>> L2CAP: Configure Request (0x04) ident 2 len 4
>> Destination CID: 64
>> Flags: 0x0000
>> > HCI Event: Number of Completed Packets (0x13) plen 5 [hci0] 9.507719
>> Num handles: 1
>> Handle: 11
>> Count: 2
>> > HCI Event: Remote Name Req Complete (0x07) plen 255 [hci0] 9.548727
>> Status: Success (0x00)
>> Address: 00:07:61:68:55:27 (Logitech Europe SA)
>> Name: Bluetooth Travel Mouse
>> > ACL Data RX: Handle 11 flags 0x02 dlen 17 [hci0] 9.555740
>> > ACL Data RX: Handle 11 flags 0x01 dlen 17 [hci0] 9.556723
>> > HCI Event: QoS Setup Complete (0x0d) plen 21 [hci0] 9.557718
>> Status: Success (0x00)
>> Handle: 11
>> Flags: 0x00
>> Service type: Best Effort (0x01)
>> Token rate: 1511
>> Peak bandwidth: 0
>> Latency: 11250
>> Delay variation: -1
>> > ACL Data RX: Handle 11 flags 0x01 dlen 6 [hci0] 9.557726
>> L2CAP: Configure Request (0x04) ident 2 len 32
>> Destination CID: 64
>> Flags: 0x0000
>> Option: Maximum Transmission Unit (0x01)
>> MTU: 48
>> Option: Quality of Service (0x03)
>> Flags: 0x00
>> Service type: Best Effort (0x01)
>> Token rate: 0x00000000
>> Token bucket size: 0x00000000
>> Peak bandwidth: 0x00000000
>> Latency: 0x00002bf2
>> Delay variation: 0xffffffff
>> < ACL Data TX: Handle 11 flags 0x02 dlen 18 [hci0] 9.557754
>> L2CAP: Configure Response (0x05) ident 2 len 10
>> Source CID: 64
>> Flags: 0x0000
>> Result: Success (0x0000)
>> Option: Maximum Transmission Unit (0x01)
>> MTU: 48
>> > ACL Data RX: Handle 11 flags 0x02 dlen 14 [hci0] 9.570733
>> L2CAP: Configure Response (0x05) ident 2 len 6
>> Source CID: 64
>> Flags: 0x0000
>> Result: Success (0x0000)
>> < ACL Data TX: Handle 11 flags 0x02 dlen 5 [hci0] 9.571076
>> Channel: 64 len 1 [PSM 17 mode 0] {chan 0}
>> 15 .
>> < ACL Data TX: Handle 11 flags 0x02 dlen 12 [hci0] 9.571284
>> L2CAP: Disconnection Request (0x06) ident 3 len 4
>> Destination CID: 64
>> Source CID: 64
>> > HCI Event: Number of Completed Packets (0x13) plen 5 [hci0] 9.573737
>> Num handles: 1
>> Handle: 11
>> Count: 2
>> > ACL Data RX: Handle 11 flags 0x02 dlen 12 [hci0] 9.610754
>> L2CAP: Connection Request (0x02) ident 3 len 4
>> PSM: 19 (0x0013)
>> Source CID: 65
>> < ACL Data TX: Handle 11 flags 0x02 dlen 16 [hci0] 9.610846
>> L2CAP: Connection Response (0x03) ident 3 len 8
>> Destination CID: 65
>> Source CID: 65
>> Result: Connection pending (0x0001)
>> Status: Authorization pending (0x0002)
>> < ACL Data TX: Handle 11 flags 0x02 dlen 16 [hci0] 9.612931
>> L2CAP: Connection Response (0x03) ident 3 len 8
>> Destination CID: 65
>> Source CID: 65
>> Result: Connection refused - security block (0x0003)
>> Status: No further information available (0x0000)
>> > HCI Event: Number of Completed Packets (0x13) plen 5 [hci0] 9.613738
>> Num handles: 1
>> Handle: 11
>> Count: 2
>> > ACL Data RX: Handle 11 flags 0x02 dlen 12 [hci0] 9.640735
>> L2CAP: Disconnection Response (0x07) ident 3 len 4
>> Destination CID: 64
>> Source CID: 64
>> > HCI Event: Number of Completed Packets (0x13) plen 5 [hci0] 9.854750
>> Num handles: 1
>> Handle: 11
>> Count: 1
>> < HCI Command: Disconnect (0x01|0x0006) plen 3 [hci0] 13.650261
>> Handle: 11
>> Reason: Remote User Terminated Connection (0x13)
>> > HCI Event: Command Status (0x0f) plen 4 [hci0] 13.652743
>> Disconnect (0x01|0x0006) ncmd 1
>> Status: Success (0x00)
>> > HCI Event: Disconnect Complete (0x05) plen 4 [hci0] 13.705753
>> Status: Success (0x00)
>> Handle: 11
>> Reason: Connection Terminated By Local Host (0x16)
>> @ Device Disconnected: 00:07:61:68:55:27 (0) reason 2
>>
>>
>> ------------------------------------
>>
>> I also noticed, that after bluetoothd restart, lists of devices and
>> paired-devices are empty:
>
> This looks like issues with storage. Could you check if bluetoothd is able to
> access storage directory (/var/lib/bluetooth) ?
Either this or the mount point gets overwritten/wiped on every boot...
--
Luiz Augusto von Dentz
^ permalink raw reply
* Re: [PATCH 1/2] tools: Fix build error in seq2bseq
From: Anderson Lizardo @ 2014-01-13 11:15 UTC (permalink / raw)
To: Szymon Janc, BlueZ development
In-Reply-To: <CAJdJm_NMf_VpC0JpcGi8KbcMg7BxF3zQ_iP9vk3q+voh6uCpJw@mail.gmail.com>
Hi,
On Mon, Jan 13, 2014 at 7:13 AM, Anderson Lizardo
<anderson.lizardo@openbossa.org> wrote:
> Hi Szymon/Johan,
>
> On Mon, Jan 13, 2014 at 4:48 AM, Johan Hedberg <johan.hedberg@gmail.com> wrote:
>> Hi Szymon,
>>
>> On Mon, Jan 13, 2014, Szymon Janc wrote:
>>> Don't ignore return value of write. This fix following build error on
>>> Ubuntu:
>>>
>>> tools/seq2bseq.c: In function ‘convert_line’:
>>> tools/seq2bseq.c:52:8: error: ignoring return value of ‘write’,
>>> declared with attribute warn_unused_result [-Werror=unused-result]
>>> write(fd, &val, 1);
>>> ---
>>> tools/seq2bseq.c | 10 +++++++---
>>> 1 file changed, 7 insertions(+), 3 deletions(-)
>>
>> Both patches have been applied. Thanks.
>
>
> I sent a similar patch a few hours ago (which was not applied). There
> you can see the caller of convert_line() also needs to be changed to
> break the parsing loop. I was also printing the error with perror
> (similar to other places on the file).
Oops, I've just seen the second patch. Sorry about the noise :)
Best Regards,
--
Anderson Lizardo
Instituto Nokia de Tecnologia - INdT
Manaus - Brazil
^ permalink raw reply
* Re: [PATCH 1/2] tools: Fix build error in seq2bseq
From: Anderson Lizardo @ 2014-01-13 11:13 UTC (permalink / raw)
To: Szymon Janc, BlueZ development
In-Reply-To: <20140113084845.GE27885@x220.p-661hnu-f1>
Hi Szymon/Johan,
On Mon, Jan 13, 2014 at 4:48 AM, Johan Hedberg <johan.hedberg@gmail.com> wrote:
> Hi Szymon,
>
> On Mon, Jan 13, 2014, Szymon Janc wrote:
>> Don't ignore return value of write. This fix following build error on
>> Ubuntu:
>>
>> tools/seq2bseq.c: In function ‘convert_line’:
>> tools/seq2bseq.c:52:8: error: ignoring return value of ‘write’,
>> declared with attribute warn_unused_result [-Werror=unused-result]
>> write(fd, &val, 1);
>> ---
>> tools/seq2bseq.c | 10 +++++++---
>> 1 file changed, 7 insertions(+), 3 deletions(-)
>
> Both patches have been applied. Thanks.
I sent a similar patch a few hours ago (which was not applied). There
you can see the caller of convert_line() also needs to be changed to
break the parsing loop. I was also printing the error with perror
(similar to other places on the file).
Best Regards,
--
Anderson Lizardo
Instituto Nokia de Tecnologia - INdT
Manaus - Brazil
^ permalink raw reply
* Re: [PATCH] avrcp: Remove dead code
From: Andrei Emeltchenko @ 2014-01-13 10:55 UTC (permalink / raw)
To: Luiz Augusto von Dentz; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <CABBYNZJfet_rQChugsSyv4ygBknj8Ao64kA532=sJHCz9nxPBA@mail.gmail.com>
Hi Luiz,
On Mon, Jan 13, 2014 at 11:08:49AM +0200, Luiz Augusto von Dentz wrote:
> Hi Andrei,
>
> On Fri, Jan 10, 2014 at 4:56 PM, Andrei Emeltchenko
> <Andrei.Emeltchenko.news@gmail.com> wrote:
> > From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
> >
> > session->target cannot be NULL since it is already checked 11 lines
> > above:
> > ...
> > if (session == NULL || session->target == NULL)
> > return -ENOTCONN;
> > ...
> > ---
> > profiles/audio/avrcp.c | 24 ++++--------------------
> > 1 file changed, 4 insertions(+), 20 deletions(-)
> >
> > diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c
> > index 8d4309a..197959f 100644
> > --- a/profiles/audio/avrcp.c
> > +++ b/profiles/audio/avrcp.c
> > @@ -3722,30 +3722,14 @@ int avrcp_set_volume(struct btd_device *dev, uint8_t volume)
> >
> > DBG("volume=%u", volume);
> >
> > - if (session->target) {
> > - pdu->pdu_id = AVRCP_SET_ABSOLUTE_VOLUME;
> > - pdu->params[0] = volume;
> > - pdu->params_len = htons(1);
> > + pdu->pdu_id = AVRCP_SET_ABSOLUTE_VOLUME;
> > + pdu->params[0] = volume;
> > + pdu->params_len = htons(1);
> >
> > - return avctp_send_vendordep_req(session->conn,
> > + return avctp_send_vendordep_req(session->conn,
> > AVC_CTYPE_CONTROL, AVC_SUBUNIT_PANEL,
> > buf, sizeof(buf),
> > avrcp_handle_set_volume, session);
> > - } else if (session->registered_events &
> > - (1 << AVRCP_EVENT_VOLUME_CHANGED)) {
> > - uint8_t id = AVRCP_EVENT_VOLUME_CHANGED;
> > - pdu->pdu_id = AVRCP_REGISTER_NOTIFICATION;
> > - pdu->params[0] = AVRCP_EVENT_VOLUME_CHANGED;
> > - pdu->params[1] = volume;
> > - pdu->params_len = htons(2);
> > -
> > - return avctp_send_vendordep(session->conn,
> > - session->transaction_events[id],
> > - AVC_CTYPE_CHANGED, AVC_SUBUNIT_PANEL,
> > - buf, sizeof(buf));
> > - }
>
> The above code is necessary to notify volume changes when acting as
> controller (session->control is set), so your fix is not good either
> and we should depend on session->target on the first place because
> both session->control and session->target can be set.
So did you make a proper fix, since otherwise this is dead code?
Best regards
Andrei Emeltchenko
^ permalink raw reply
* Re: Problems with Logitech V270 mouse
From: Szymon Janc @ 2014-01-13 10:37 UTC (permalink / raw)
To: Jakub Jechanowski; +Cc: linux-bluetooth
In-Reply-To: <CAA8=LDXCLCVytAMDNAX8Vafi827F5mMrEp7WELbseM_oZ5+S0w@mail.gmail.com>
On Thursday 02 of January 2014 23:55:25 Jakub Jechanowski wrote:
> After pairing and connecting (bluetoothctl or bluetooth-wizard) mouse
> works ok. But when I restart bluetoothd (or whole OS) mouse no longer
> works. After touching the mouse, in bluetoothd log I get:
>
> bluetoothd[6418]: src/adapter.c:connected_callback() hci0 device
> 00:07:61:68:55:27 connected eir_len 5
> bluetoothd[6418]: src/device.c:device_create() dst 00:07:61:68:55:27
> bluetoothd[6418]: src/device.c:device_new() address 00:07:61:68:55:27
> bluetoothd[6418]: src/device.c:device_new() Creating device
> /org/bluez/hci0/dev_00_07_61_68_55_27
> bluetoothd[6418]: src/device.c:btd_device_set_temporary() temporary 1
> bluetoothd[6418]: src/adapter.c:adapter_connect_list_remove() device
> /org/bluez/hci0/dev_00_07_61_68_55_27 is not on the list, ignoring
> bluetoothd[6418]: src/device.c:device_set_class()
> /org/bluez/hci0/dev_00_07_61_68_55_27 0x002580
> bluetoothd[6418]: profiles/input/server.c:connect_event_cb() Incoming
> connection from 00:07:61:68:55:27 on PSM 17
> bluetoothd[6418]: profiles/input/device.c:input_device_set_channel()
> idev (nil) psm 17
> bluetoothd[6418]: Refusing input device connect: No such file or directory (2)
> bluetoothd[6418]: profiles/input/server.c:confirm_event_cb()
> bluetoothd[6418]: Refusing connection from 00:07:61:68:55:27: unknown device
> <<<few seconds of pause>>>
> bluetoothd[6418]: src/adapter.c:dev_disconnected() Device
> 00:07:61:68:55:27 disconnected, reason 2
> bluetoothd[6418]: src/adapter.c:adapter_remove_connection()
> bluetoothd[6418]: src/adapter.c:adapter_remove_connection() Removing
> temporary device /org/bluez/hci0/dev_00_07_61_68_55_27
> bluetoothd[6418]: src/device.c:device_remove() Removing device
> /org/bluez/hci0/dev_00_07_61_68_55_27
> bluetoothd[6418]: src/device.c:btd_device_unref() Freeing device
> /org/bluez/hci0/dev_00_07_61_68_55_27
> bluetoothd[6418]: src/device.c:device_free() 0x24a65e0
> bluetoothd[6418]: src/adapter.c:bonding_attempt_complete() hci0 bdaddr
> 00:07:61:68:55:27 type 0 status 0xe
> bluetoothd[6418]: src/adapter.c:resume_discovery()
>
> ------------------------------------
>
> Log from btmon after touching mouse:
>
> > HCI Event: Connect Request (0x04) plen 10 [hci0] 9.133728
> Address: 00:07:61:68:55:27 (Logitech Europe SA)
> Class: 0x002580
> Major class: Peripheral (mouse, joystick, keyboards)
> Minor class: 0x20
> Limited Discoverable Mode
> Link type: ACL (0x01)
> < HCI Command: Accept Connection Request (0x01|0x0009) plen 7 [hci0] 9.133770
> Address: 00:07:61:68:55:27 (Logitech Europe SA)
> Role: Master (0x00)
> > HCI Event: Command Status (0x0f) plen 4 [hci0] 9.136727
> Accept Connection Request (0x01|0x0009) ncmd 1
> Status: Success (0x00)
> > HCI Event: Role Change (0x12) plen 8 [hci0] 9.294753
> Status: Success (0x00)
> Address: 00:07:61:68:55:27 (Logitech Europe SA)
> Role: Master (0x00)
> > HCI Event: Connect Complete (0x03) plen 11 [hci0] 9.444736
> Status: Success (0x00)
> Handle: 11
> Address: 00:07:61:68:55:27 (Logitech Europe SA)
> Link type: ACL (0x01)
> Encryption: Disabled (0x00)
> < HCI Command: Read Remote Supported Fe.. (0x01|0x001b) plen 2 [hci0] 9.444839
> Handle: 11
> > HCI Event: Command Status (0x0f) plen 4 [hci0] 9.446731
> Read Remote Supported Features (0x01|0x001b) ncmd 1
> Status: Success (0x00)
> > HCI Event: Read Remote Supported Features (0x0b) plen 11 [hci0] 9.448739
> Status: Success (0x00)
> Handle: 11
> Features: 0xfc 0xff 0x0f 0x00 0x08 0x08 0x00 0x00
> Encryption
> Slot offset
> Timing accuracy
> Role switch
> Hold mode
> Sniff mode
> Park state
> Power control requests
> Channel quality driven data rate (CQDDR)
> SCO link
> HV2 packets
> HV3 packets
> u-law log synchronous data
> A-law log synchronous data
> CVSD synchronous data
> Paging parameter negotiation
> Power control
> Transparent synchronous data
> AFH capable slave
> AFH capable master
> < HCI Command: Remote Name Request (0x01|0x0019) plen 10 [hci0] 9.448793
> Address: 00:07:61:68:55:27 (Logitech Europe SA)
> Page scan repetition mode: R2 (0x02)
> Page scan mode: Mandatory (0x00)
> Clock offset: 0x0000
> > HCI Event: Command Status (0x0f) plen 4 [hci0] 9.449737
> Remote Name Request (0x01|0x0019) ncmd 1
> Status: Success (0x00)
> > ACL Data RX: Handle 11 flags 0x02 dlen 12 [hci0] 9.477736
> L2CAP: Connection Request (0x02) ident 1 len 4
> PSM: 17 (0x0011)
> Source CID: 64
> < ACL Data TX: Handle 11 flags 0x02 dlen 16 [hci0] 9.477798
> L2CAP: Connection Response (0x03) ident 1 len 8
> Destination CID: 64
> Source CID: 64
> Result: Connection pending (0x0001)
> Status: No further information available (0x0000)
> < ACL Data TX: Handle 11 flags 0x02 dlen 10 [hci0] 9.477805
> L2CAP: Information Request (0x0a) ident 1 len 2
> Type: Extended features supported (0x0002)
> @ Device Connected: 00:07:61:68:55:27 (0) flags 0x0000
> 04 0d 80 25 00 ...%.
> > HCI Event: Number of Completed Packets (0x13) plen 5 [hci0] 9.485716
> Num handles: 1
> Handle: 11
> Count: 2
> > ACL Data RX: Handle 11 flags 0x02 dlen 16 [hci0] 9.501737
> L2CAP: Information Response (0x0b) ident 1 len 8
> Type: Extended features supported (0x0002)
> Result: Success (0x0000)
> Features: 0x00000000
> < ACL Data TX: Handle 11 flags 0x02 dlen 16 [hci0] 9.502107
> L2CAP: Connection Response (0x03) ident 1 len 8
> Destination CID: 64
> Source CID: 64
> Result: Connection successful (0x0000)
> Status: No further information available (0x0000)
> < ACL Data TX: Handle 11 flags 0x02 dlen 12 [hci0] 9.502113
> L2CAP: Configure Request (0x04) ident 2 len 4
> Destination CID: 64
> Flags: 0x0000
> > HCI Event: Number of Completed Packets (0x13) plen 5 [hci0] 9.507719
> Num handles: 1
> Handle: 11
> Count: 2
> > HCI Event: Remote Name Req Complete (0x07) plen 255 [hci0] 9.548727
> Status: Success (0x00)
> Address: 00:07:61:68:55:27 (Logitech Europe SA)
> Name: Bluetooth Travel Mouse
> > ACL Data RX: Handle 11 flags 0x02 dlen 17 [hci0] 9.555740
> > ACL Data RX: Handle 11 flags 0x01 dlen 17 [hci0] 9.556723
> > HCI Event: QoS Setup Complete (0x0d) plen 21 [hci0] 9.557718
> Status: Success (0x00)
> Handle: 11
> Flags: 0x00
> Service type: Best Effort (0x01)
> Token rate: 1511
> Peak bandwidth: 0
> Latency: 11250
> Delay variation: -1
> > ACL Data RX: Handle 11 flags 0x01 dlen 6 [hci0] 9.557726
> L2CAP: Configure Request (0x04) ident 2 len 32
> Destination CID: 64
> Flags: 0x0000
> Option: Maximum Transmission Unit (0x01)
> MTU: 48
> Option: Quality of Service (0x03)
> Flags: 0x00
> Service type: Best Effort (0x01)
> Token rate: 0x00000000
> Token bucket size: 0x00000000
> Peak bandwidth: 0x00000000
> Latency: 0x00002bf2
> Delay variation: 0xffffffff
> < ACL Data TX: Handle 11 flags 0x02 dlen 18 [hci0] 9.557754
> L2CAP: Configure Response (0x05) ident 2 len 10
> Source CID: 64
> Flags: 0x0000
> Result: Success (0x0000)
> Option: Maximum Transmission Unit (0x01)
> MTU: 48
> > ACL Data RX: Handle 11 flags 0x02 dlen 14 [hci0] 9.570733
> L2CAP: Configure Response (0x05) ident 2 len 6
> Source CID: 64
> Flags: 0x0000
> Result: Success (0x0000)
> < ACL Data TX: Handle 11 flags 0x02 dlen 5 [hci0] 9.571076
> Channel: 64 len 1 [PSM 17 mode 0] {chan 0}
> 15 .
> < ACL Data TX: Handle 11 flags 0x02 dlen 12 [hci0] 9.571284
> L2CAP: Disconnection Request (0x06) ident 3 len 4
> Destination CID: 64
> Source CID: 64
> > HCI Event: Number of Completed Packets (0x13) plen 5 [hci0] 9.573737
> Num handles: 1
> Handle: 11
> Count: 2
> > ACL Data RX: Handle 11 flags 0x02 dlen 12 [hci0] 9.610754
> L2CAP: Connection Request (0x02) ident 3 len 4
> PSM: 19 (0x0013)
> Source CID: 65
> < ACL Data TX: Handle 11 flags 0x02 dlen 16 [hci0] 9.610846
> L2CAP: Connection Response (0x03) ident 3 len 8
> Destination CID: 65
> Source CID: 65
> Result: Connection pending (0x0001)
> Status: Authorization pending (0x0002)
> < ACL Data TX: Handle 11 flags 0x02 dlen 16 [hci0] 9.612931
> L2CAP: Connection Response (0x03) ident 3 len 8
> Destination CID: 65
> Source CID: 65
> Result: Connection refused - security block (0x0003)
> Status: No further information available (0x0000)
> > HCI Event: Number of Completed Packets (0x13) plen 5 [hci0] 9.613738
> Num handles: 1
> Handle: 11
> Count: 2
> > ACL Data RX: Handle 11 flags 0x02 dlen 12 [hci0] 9.640735
> L2CAP: Disconnection Response (0x07) ident 3 len 4
> Destination CID: 64
> Source CID: 64
> > HCI Event: Number of Completed Packets (0x13) plen 5 [hci0] 9.854750
> Num handles: 1
> Handle: 11
> Count: 1
> < HCI Command: Disconnect (0x01|0x0006) plen 3 [hci0] 13.650261
> Handle: 11
> Reason: Remote User Terminated Connection (0x13)
> > HCI Event: Command Status (0x0f) plen 4 [hci0] 13.652743
> Disconnect (0x01|0x0006) ncmd 1
> Status: Success (0x00)
> > HCI Event: Disconnect Complete (0x05) plen 4 [hci0] 13.705753
> Status: Success (0x00)
> Handle: 11
> Reason: Connection Terminated By Local Host (0x16)
> @ Device Disconnected: 00:07:61:68:55:27 (0) reason 2
>
>
> ------------------------------------
>
> I also noticed, that after bluetoothd restart, lists of devices and
> paired-devices are empty:
This looks like issues with storage. Could you check if bluetoothd is able to
access storage directory (/var/lib/bluetooth) ?
> [root@pavilion 00:24:7E:F4:D7:EC]# bluetoothctl
> [NEW] Controller 00:24:7E:F4:D7:EC pavilion [default]
> [NEW] Device 00:07:61:68:55:27 Bluetooth Travel Mouse
> [bluetooth]# devices
> Device 00:07:61:68:55:27 Bluetooth Travel Mouse
> [bluetooth]# paired-devices
> Device 00:07:61:68:55:27 Bluetooth Travel Mouse
> <<< restart of bluetoothd >>>
> [bluetooth]# devices
> [bluetooth]# paired-devices
> [bluetooth]# exit
> [DEL] Controller 00:24:7E:F4:D7:EC pavilion [default]
>
>
> Bluez 5.13, Arch Linux
>
> Mouse worked without problems on Bluez 4.x
>
> It seems to be similar to "Missing AuthorizeService callback?" topic
> from 2013-12-10.
>
> Cheers, Kuba
> --
> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
--
Best regards,
Szymon Janc
^ permalink raw reply
* [PATCH 7/7] android/ipc-tester: Add basic negative test cases for IPC's daemon site
From: Jakub Tyszkowski @ 2014-01-13 10:37 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1389609422-21200-1-git-send-email-jakub.tyszkowski@tieto.com>
This patch add first few test cases checking for proper daemon
termination in case of receiving invalid IPC data.
---
android/ipc-negative-tester.c | 120 ++++++++++++++++++++++++++++++++++++++++--
1 file changed, 117 insertions(+), 3 deletions(-)
diff --git a/android/ipc-negative-tester.c b/android/ipc-negative-tester.c
index 7b2bbf8..15701e8 100644
--- a/android/ipc-negative-tester.c
+++ b/android/ipc-negative-tester.c
@@ -540,22 +540,136 @@ static void ipc_send_tc(const void *data)
3, user, g_free); \
} while (0)
-static const struct generic_data dummy_data = {
+struct regmod_msg register_bt_msg = {
+ .header = {
+ .service_id = HAL_SERVICE_ID_CORE,
+ .opcode = HAL_OP_REGISTER_MODULE,
+ .len = sizeof(struct hal_cmd_register_module),
+ },
+ .cmd = {
+ .service_id = HAL_SERVICE_ID_CORE,
+ },
+ };
+
+static const struct generic_data to_small_data = {
.ipc_data = {
- .buffer = "",
+ /* valid header and payload */
+ .buffer = ®ister_bt_msg,
+ /* but write only incomplete header */
.len = 1,
},
.init_services = {HAL_SERVICE_ID_BLUETOOTH},
.num_services = 1,
};
+struct regmod_msg register_bt_malformed_size_msg = {
+ .header = {
+ .service_id = HAL_SERVICE_ID_CORE,
+ .opcode = HAL_OP_REGISTER_MODULE,
+ /* wrong payload size declared */
+ .len = sizeof(struct hal_cmd_register_module) - 1,
+ },
+ .cmd = {
+ .service_id = HAL_SERVICE_ID_CORE,
+ },
+ };
+
+static const struct generic_data malformed_data = {
+ .ipc_data = {
+ /* use malformed msg - wrong size declared */
+ .buffer = ®ister_bt_malformed_size_msg,
+ /* but write proper size */
+ .len = sizeof(struct hal_cmd_register_module),
+ },
+ .init_services = {HAL_SERVICE_ID_BLUETOOTH},
+ .num_services = 1,
+};
+
+struct hal_hdr enable_unknown_service_hdr = {
+ .service_id = HAL_SERVICE_ID_MAX + 1,
+ .opcode = HAL_OP_ENABLE,
+ .len = 0,
+};
+
+static const struct generic_data enable_unknown_service_data = {
+ .ipc_data = {
+ /* enable invalid service */
+ .buffer = &enable_unknown_service_hdr,
+ .len = sizeof(enable_unknown_service_hdr),
+ },
+ .init_services = {HAL_SERVICE_ID_BLUETOOTH},
+ .num_services = 1,
+};
+
+struct hal_hdr enable_bt_service_hdr = {
+ .service_id = HAL_SERVICE_ID_BLUETOOTH,
+ .opcode = HAL_OP_ENABLE,
+ .len = 0,
+};
+
+static const struct generic_data enable_unregistered_service_data = {
+ .ipc_data = {
+ /* valid msg */
+ .buffer = &enable_bt_service_hdr,
+ /* send the whole thing */
+ .len = sizeof(enable_bt_service_hdr),
+ },
+ /* but don't register it before enabling */
+ .init_services = {},
+ .num_services = 0,
+};
+
+struct hal_hdr invalid_opcode_hdr = {
+ .service_id = HAL_SERVICE_ID_BLUETOOTH,
+ .opcode = 0x16,
+ .len = 0,
+};
+
+static const struct generic_data invalid_opcode_data = {
+ .ipc_data = {
+ /* valid msg */
+ .buffer = &invalid_opcode_hdr,
+ /* send the whole thing */
+ .len = sizeof(invalid_opcode_hdr),
+ },
+ .init_services = {HAL_SERVICE_ID_BLUETOOTH},
+ .num_services = 1,
+};
+
+struct hal_hdr invalid_msg_size_hdr = {
+ .service_id = HAL_SERVICE_ID_BLUETOOTH,
+ .opcode = HAL_OP_CREATE_BOND,
+ .len = 0,
+};
+
+static const struct generic_data invalid_msg_size_data = {
+ .ipc_data = {
+ .buffer = &invalid_msg_size_hdr,
+ .len = sizeof(invalid_msg_size_hdr),
+ },
+ .init_services = {HAL_SERVICE_ID_BLUETOOTH},
+ .num_services = 1,
+};
+
int main(int argc, char *argv[])
{
snprintf(exec_dir, sizeof(exec_dir), "%s", dirname(argv[0]));
tester_init(&argc, &argv);
- test_bredrle("Test Dummy", &dummy_data, setup, ipc_send_tc, teardown);
+ test_bredrle("To small data", &to_small_data,
+ setup, ipc_send_tc, teardown);
+ test_bredrle("Malformed data", &malformed_data,
+ setup, ipc_send_tc, teardown);
+ test_bredrle("Invalid service", &enable_unknown_service_data,
+ setup, ipc_send_tc, teardown);
+ test_bredrle("Enable unregistered service",
+ &enable_unregistered_service_data,
+ setup, ipc_send_tc, teardown);
+ test_bredrle("Invalid opcode", &invalid_opcode_data,
+ setup, ipc_send_tc, teardown);
+ test_bredrle("Invalid msg size for opcode", &invalid_msg_size_data,
+ setup, ipc_send_tc, teardown);
return tester_run();
}
--
1.8.5
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox