* [PATCH v2 04/10] emulator: Add handling inquiry number of responses
From: Lukasz Rymanowski @ 2014-03-09 23:05 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Lukasz Rymanowski
In-Reply-To: <1394406363-6751-1-git-send-email-lukasz.rymanowski@tieto.com>
---
emulator/btdev.c | 26 ++++++++++++++++++--------
1 file changed, 18 insertions(+), 8 deletions(-)
diff --git a/emulator/btdev.c b/emulator/btdev.c
index 3c0b0ad..c932a18 100644
--- a/emulator/btdev.c
+++ b/emulator/btdev.c
@@ -129,6 +129,8 @@ struct btdev {
struct inquiry_data {
struct btdev *btdev;
+ int num_resp;
+
int sent_count;
int iter;
};
@@ -705,6 +707,7 @@ static bool inquiry_callback(void *user_data)
{
struct inquiry_data *data = user_data;
struct btdev *btdev = data->btdev;
+ struct bt_hci_evt_inquiry_complete ic;
int sent = data->sent_count;
int i;
@@ -769,17 +772,22 @@ static bool inquiry_callback(void *user_data)
}
}
- if (i == MAX_BTDEV_ENTRIES) {
- struct bt_hci_evt_inquiry_complete ic;
-
- ic.status = BT_HCI_ERR_SUCCESS;
- send_event(btdev, BT_HCI_EVT_INQUIRY_COMPLETE, &ic, sizeof(ic));
+ /* Check if we sent already required amount of responses*/
+ if (data->num_resp && data->sent_count == data->num_resp)
+ goto finish;
- btdev->inquiry_id = 0;
- return false;
- }
+ if (i == MAX_BTDEV_ENTRIES)
+ goto finish;
return true;
+
+finish:
+ /* Note that destroy will be called */
+ ic.status = BT_HCI_ERR_SUCCESS;
+ send_event(btdev, BT_HCI_EVT_INQUIRY_COMPLETE, &ic, sizeof(ic));
+
+ btdev->inquiry_id = 0;
+ return false;
}
static void inquiry_destroy(void *user_data)
@@ -804,6 +812,7 @@ finish:
static void inquiry_cmd(struct btdev *btdev, const void *cmd)
{
+ const struct bt_hci_cmd_inquiry *inq_cmd = cmd;
struct inquiry_data *data;
struct bt_hci_evt_inquiry_complete ic;
int status = BT_HCI_ERR_HARDWARE_FAILURE;
@@ -819,6 +828,7 @@ static void inquiry_cmd(struct btdev *btdev, const void *cmd)
memset(data, 0, sizeof(*data));
data->btdev = btdev;
+ data->num_resp = inq_cmd->num_resp;
btdev->inquiry_id = timeout_add(DEFAULT_INQUIRY_INTERVAL,
inquiry_callback, data, inquiry_destroy);
--
1.8.4
^ permalink raw reply related
* [PATCH v2 05/10] emulator: Add handling inquiry_lenght from inquiry command
From: Lukasz Rymanowski @ 2014-03-09 23:05 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Lukasz Rymanowski
In-Reply-To: <1394406363-6751-1-git-send-email-lukasz.rymanowski@tieto.com>
With this patch, btdev is taking into accoung inquiry_lenght from hci
inquiry command.
Inquiry session will last that long unless number of devices parameter
has been provided different then 0
---
emulator/btdev.c | 46 ++++++++++++++++++++++++++++++++++++++++++----
1 file changed, 42 insertions(+), 4 deletions(-)
diff --git a/emulator/btdev.c b/emulator/btdev.c
index c932a18..27bbb08 100644
--- a/emulator/btdev.c
+++ b/emulator/btdev.c
@@ -70,6 +70,7 @@ struct btdev {
void *send_data;
int inquiry_id;
+ int inquiry_timeout_id;
bool inquiry_cancel;
struct hook *hook_list[MAX_HOOK_ENTRIES];
@@ -133,6 +134,8 @@ struct inquiry_data {
int sent_count;
int iter;
+
+ bool timeout;
};
#define DEFAULT_INQUIRY_INTERVAL 100 /* 100 miliseconds */
@@ -711,6 +714,14 @@ static bool inquiry_callback(void *user_data)
int sent = data->sent_count;
int i;
+ /* Check if inquiry timeout fired. */
+ if (data->timeout)
+ goto finish;
+
+ /*Report devices only once and wait for inquiry timeout*/
+ if (data->iter == MAX_BTDEV_ENTRIES)
+ return true;
+
for (i = data->iter; i < MAX_BTDEV_ENTRIES; i++, data->iter++) {
/*Lets sent 10 inquiry results at once */
if (sent + 10 == data->sent_count)
@@ -771,14 +782,10 @@ static bool inquiry_callback(void *user_data)
data->sent_count++;
}
}
-
/* Check if we sent already required amount of responses*/
if (data->num_resp && data->sent_count == data->num_resp)
goto finish;
- if (i == MAX_BTDEV_ENTRIES)
- goto finish;
-
return true;
finish:
@@ -806,16 +813,33 @@ static void inquiry_destroy(void *user_data)
btdev->inquiry_cancel = false;
btdev->inquiry_id = 0;
+ if (btdev->inquiry_timeout_id)
+ timeout_remove(btdev->inquiry_timeout_id);
+
+ btdev->inquiry_timeout_id = 0;
+
finish:
free(data);
}
+static bool inquiry_timeout(void *user_data)
+{
+ struct inquiry_data *data = user_data;
+ struct btdev *btdev = data->btdev;
+
+ data->timeout = true;
+ btdev->inquiry_timeout_id = 0;
+
+ return false;
+}
+
static void inquiry_cmd(struct btdev *btdev, const void *cmd)
{
const struct bt_hci_cmd_inquiry *inq_cmd = cmd;
struct inquiry_data *data;
struct bt_hci_evt_inquiry_complete ic;
int status = BT_HCI_ERR_HARDWARE_FAILURE;
+ unsigned int inquiry_len_ms;
if (btdev->inquiry_id) {
status = BT_HCI_ERR_COMMAND_DISALLOWED;
@@ -830,6 +854,13 @@ static void inquiry_cmd(struct btdev *btdev, const void *cmd)
data->btdev = btdev;
data->num_resp = inq_cmd->num_resp;
+ /* Add timeout to cancel inquiry */
+ inquiry_len_ms = 1280 * inq_cmd->length;
+ if (inquiry_len_ms)
+ btdev->inquiry_timeout_id = timeout_add(inquiry_len_ms,
+ inquiry_timeout,
+ data, NULL);
+
btdev->inquiry_id = timeout_add(DEFAULT_INQUIRY_INTERVAL,
inquiry_callback, data, inquiry_destroy);
/* Return if success */
@@ -852,9 +883,16 @@ static void inquiry_cancel(struct btdev *btdev)
}
btdev->inquiry_cancel = true;
+
+ if (btdev->inquiry_timeout_id)
+ timeout_remove(btdev->inquiry_timeout_id);
+
+ btdev->inquiry_timeout_id = 0;
+
timeout_remove(btdev->inquiry_id);
btdev->inquiry_id = 0;
}
+
static void conn_complete(struct btdev *btdev,
const uint8_t *bdaddr, uint8_t status)
{
--
1.8.4
^ permalink raw reply related
* [PATCH v2 06/10] android/tester: Fix handling inquiry by android tester
From: Lukasz Rymanowski @ 2014-03-09 23:05 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Lukasz Rymanowski
In-Reply-To: <1394406363-6751-1-git-send-email-lukasz.rymanowski@tieto.com>
Previously btdev sent inquiry_complete in one mainloop iteration. Due to
new way of handling it we need to make sure cancel_discovery is called
if start_discovery has been used.
There is also no need to hook before inquiry_complete_event in case of
test for cancel_discovery.
Conflicts:
android/android-tester.c
---
android/android-tester.c | 24 +++++++-----------------
1 file changed, 7 insertions(+), 17 deletions(-)
diff --git a/android/android-tester.c b/android/android-tester.c
index b762a2d..7cab79c 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -940,10 +940,13 @@ static void discovery_device_found_cb(int num_properties,
}
if (!check_test_property(received_prop, expected_prop)) {
+ data->if_bluetooth->cancel_discovery();
tester_test_failed();
return;
}
}
+
+ data->if_bluetooth->cancel_discovery();
}
static void remote_getprops_device_found_cb(int num_properties,
@@ -958,6 +961,7 @@ static void remote_getprops_device_found_cb(int num_properties,
if (data->cb_count == 2)
data->cb_count--;
+ data->if_bluetooth->cancel_discovery();
data->if_bluetooth->get_remote_device_properties(&remote_addr);
}
@@ -977,6 +981,7 @@ static void remote_get_property_device_found_cb(int num_properties,
if (data->cb_count == 2)
data->cb_count--;
+ data->if_bluetooth->cancel_discovery();
status = data->if_bluetooth->get_remote_device_property(&remote_addr,
prop.type);
check_expected_status(status);
@@ -998,6 +1003,7 @@ static void remote_setprop_device_found_cb(int num_properties,
if (data->cb_count == 3)
data->cb_count--;
+ data->if_bluetooth->cancel_discovery();
status = data->if_bluetooth->set_remote_device_property(&remote_addr,
&prop);
check_expected_status(status);
@@ -1019,6 +1025,7 @@ static void remote_setprop_fail_device_found_cb(int num_properties,
if (data->cb_count == 2)
data->cb_count--;
+ data->if_bluetooth->cancel_discovery();
status = data->if_bluetooth->set_remote_device_property(&remote_addr,
&prop);
check_expected_status(status);
@@ -2965,26 +2972,12 @@ static void test_discovery_stop_done(const void *test_data)
check_expected_status(status);
}
-static bool pre_inq_compl_hook(const void *dummy, uint16_t len, void *user_data)
-{
- struct test_data *data = tester_get_data();
-
- /* Make sure Inquiry Command Complete is not called */
-
- hciemu_del_hook(data->hciemu, HCIEMU_HOOK_PRE_EVT, BT_HCI_CMD_INQUIRY);
-
- return false;
-}
-
static void test_discovery_stop_success(const void *test_data)
{
struct test_data *data = tester_get_data();
init_test_conditions(data);
- hciemu_add_hook(data->hciemu, HCIEMU_HOOK_PRE_EVT, BT_HCI_CMD_INQUIRY,
- pre_inq_compl_hook, data);
-
data->if_bluetooth->start_discovery();
}
@@ -2994,9 +2987,6 @@ static void test_discovery_start_done(const void *test_data)
init_test_conditions(data);
- hciemu_add_hook(data->hciemu, HCIEMU_HOOK_PRE_EVT, BT_HCI_CMD_INQUIRY,
- pre_inq_compl_hook, data);
-
data->if_bluetooth->start_discovery();
}
--
1.8.4
^ permalink raw reply related
* [PATCH v2 07/10] tools/mgmt-tester: Fix for Stop discovery test
From: Lukasz Rymanowski @ 2014-03-09 23:06 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Lukasz Rymanowski
In-Reply-To: <1394406363-6751-1-git-send-email-lukasz.rymanowski@tieto.com>
Test "Stop Discovery - BR/EDR (Inquiry) Success 1" uses hciemu_type
BREDR but uses power settings to enable LE and tries to set LE:
mgmt: [0x0002] command 0x000d
mgmt: < 0d 00 02 00 01 00 01 .......
mgmt: > 02 00 02 00 03 00 0d 00 0c .........
mgmt: [0x0002] command 0x0d status: 0x0c
This patch fixes this minor issue
---
tools/mgmt-tester.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/mgmt-tester.c b/tools/mgmt-tester.c
index a3c1c72..9f71743 100644
--- a/tools/mgmt-tester.c
+++ b/tools/mgmt-tester.c
@@ -1733,7 +1733,7 @@ static const struct generic_data stop_discovery_success_test_1 = {
};
static const struct generic_data stop_discovery_bredr_success_test_1 = {
- .setup_settings = settings_powered_le,
+ .setup_settings = settings_powered,
.setup_expect_hci_command = BT_HCI_CMD_INQUIRY,
.setup_expect_hci_param = stop_discovery_inq_param,
.setup_expect_hci_len = sizeof(stop_discovery_inq_param),
--
1.8.4
^ permalink raw reply related
* [PATCH v2 08/10] tools/mgmt-tester: Update Stop Discovery-BR/EDR (Inquiry) Success 1
From: Lukasz Rymanowski @ 2014-03-09 23:06 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Lukasz Rymanowski
In-Reply-To: <1394406363-6751-1-git-send-email-lukasz.rymanowski@tieto.com>
With new way of handling inquiry in btdev there is no need to register
inquiry event hook
---
tools/mgmt-tester.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/tools/mgmt-tester.c b/tools/mgmt-tester.c
index 9f71743..17d2bd2 100644
--- a/tools/mgmt-tester.c
+++ b/tools/mgmt-tester.c
@@ -1734,9 +1734,6 @@ static const struct generic_data stop_discovery_success_test_1 = {
static const struct generic_data stop_discovery_bredr_success_test_1 = {
.setup_settings = settings_powered,
- .setup_expect_hci_command = BT_HCI_CMD_INQUIRY,
- .setup_expect_hci_param = stop_discovery_inq_param,
- .setup_expect_hci_len = sizeof(stop_discovery_inq_param),
.send_opcode = MGMT_OP_STOP_DISCOVERY,
.send_param = stop_discovery_bredr_param,
.send_len = sizeof(stop_discovery_bredr_param),
--
1.8.4
^ permalink raw reply related
* [PATCH v2 09/10] tools/mgmt-tester: Remove not used condition
From: Lukasz Rymanowski @ 2014-03-09 23:06 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Lukasz Rymanowski
In-Reply-To: <1394406363-6751-1-git-send-email-lukasz.rymanowski@tieto.com>
---
tools/mgmt-tester.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/tools/mgmt-tester.c b/tools/mgmt-tester.c
index 17d2bd2..a711d0d 100644
--- a/tools/mgmt-tester.c
+++ b/tools/mgmt-tester.c
@@ -2868,9 +2868,6 @@ static void setup_start_discovery(const void *test_data)
setup_command_hci_callback,
NULL);
- if (test->send_func)
- send_param = test->send_func(&send_len);
-
mgmt_send(data->mgmt, MGMT_OP_START_DISCOVERY, data->mgmt_index,
send_len, send_param, NULL, NULL, NULL);
} else {
--
1.8.4
^ permalink raw reply related
* [PATCH v2 10/10] tools/mgmt-tester: Refactor setup_start_discovery function
From: Lukasz Rymanowski @ 2014-03-09 23:06 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Lukasz Rymanowski
In-Reply-To: <1394406363-6751-1-git-send-email-lukasz.rymanowski@tieto.com>
This patch removes handling hook register from this
function and its callback as this is no longer necessary for any stop
discovery tests.
This patch also adds setup_send_param and setup_send_len parameters to
test data so it is easy to control start discovery command parameters.
It is useful for tests:
Stop Discovery - Invalid parameters 1
Stop Discovery - BR/EDR (Inquiry) Success 1
---
tools/mgmt-tester.c | 62 ++++++++++++++---------------------------------------
1 file changed, 16 insertions(+), 46 deletions(-)
diff --git a/tools/mgmt-tester.c b/tools/mgmt-tester.c
index a711d0d..64188f1 100644
--- a/tools/mgmt-tester.c
+++ b/tools/mgmt-tester.c
@@ -362,6 +362,9 @@ struct generic_data {
uint16_t setup_expect_hci_command;
const void *setup_expect_hci_param;
uint8_t setup_expect_hci_len;
+ uint16_t setup_send_opcode;
+ const void *setup_send_param;
+ uint16_t setup_send_len;
bool send_index_none;
uint16_t send_opcode;
const void *send_param;
@@ -1734,6 +1737,8 @@ static const struct generic_data stop_discovery_success_test_1 = {
static const struct generic_data stop_discovery_bredr_success_test_1 = {
.setup_settings = settings_powered,
+ .setup_send_param = start_discovery_bredr_param,
+ .setup_send_len = sizeof(start_discovery_bredr_param),
.send_opcode = MGMT_OP_STOP_DISCOVERY,
.send_param = stop_discovery_bredr_param,
.send_len = sizeof(stop_discovery_bredr_param),
@@ -1758,6 +1763,8 @@ static const struct generic_data stop_discovery_rejected_test_1 = {
static const struct generic_data stop_discovery_invalid_param_test_1 = {
.setup_settings = settings_powered_le,
+ .setup_send_param = start_discovery_bredrle_param,
+ .setup_send_len = sizeof(start_discovery_bredrle_param),
.send_opcode = MGMT_OP_STOP_DISCOVERY,
.send_param = stop_discovery_bredrle_invalid_param,
.send_len = sizeof(stop_discovery_bredrle_invalid_param),
@@ -2824,59 +2831,22 @@ static void setup_discovery_callback(uint8_t status, uint16_t length,
tester_setup_complete();
}
-static bool setup_command_hci_callback(const void *data, uint16_t len,
- void *user_data)
-{
- struct test_data *tdata = tester_get_data();
- const struct generic_data *test = tdata->test_data;
-
- tester_print("HCI Command 0x%04x length %u (setup)",
- test->setup_expect_hci_command, len);
-
- if (len != test->setup_expect_hci_len) {
- tester_warn("Invalid parameter size for HCI command (setup)");
- tester_setup_failed();
- goto done;
- }
-
- if (memcmp(data, test->setup_expect_hci_param, len) != 0) {
- tester_warn("Unexpected HCI command parameter value (setup)");
- tester_setup_failed();
- goto done;
- }
-
- tester_setup_complete();
-
-done:
- hciemu_del_hook(tdata->hciemu, HCIEMU_HOOK_PRE_EVT,
- test->setup_expect_hci_command);
-
- return false;
-}
-
static void setup_start_discovery(const void *test_data)
{
struct test_data *data = tester_get_data();
const struct generic_data *test = data->test_data;
- const void *send_param = test->send_param;
- uint16_t send_len = test->send_len;
-
- if (test->setup_expect_hci_command) {
- tester_print("Registering HCI command callback (setup)");
- hciemu_add_hook(data->hciemu, HCIEMU_HOOK_PRE_EVT,
- test->setup_expect_hci_command,
- setup_command_hci_callback,
- NULL);
+ const void *send_param = test->setup_send_param;
+ uint16_t send_len = test->setup_send_len;
+ unsigned char disc_param[] = { 0x07 };
- mgmt_send(data->mgmt, MGMT_OP_START_DISCOVERY, data->mgmt_index,
- send_len, send_param, NULL, NULL, NULL);
- } else {
- unsigned char disc_param[] = { 0x07 };
+ if (!send_param) {
+ send_param = disc_param;
+ send_len = 1;
+ }
- mgmt_send(data->mgmt, MGMT_OP_START_DISCOVERY, data->mgmt_index,
- sizeof(disc_param), disc_param,
+ mgmt_send(data->mgmt, MGMT_OP_START_DISCOVERY, data->mgmt_index,
+ send_len, send_param,
setup_discovery_callback, NULL, NULL);
- }
}
static void setup_multi_uuid32(const void *test_data)
--
1.8.4
^ permalink raw reply related
* [PATCH v2 0/3] android: Improve of handling stop discovery
From: Lukasz Rymanowski @ 2014-03-09 23:06 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Lukasz Rymanowski
Following patches improves handling of stop discovery in scenario of
big inflow of device found events.
v2:
* Fix confirm name callback
Lukasz Rymanowski (3):
android: Add tracking for pending confirm name command
android: Cancel all pending confirm name before stop discovery
android: Send confirm name request with mgmt_send
android/bluetooth.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++----
1 file changed, 46 insertions(+), 4 deletions(-)
--
1.8.4
^ permalink raw reply
* [PATCH v2 1/3] android: Add tracking for pending confirm name command
From: Lukasz Rymanowski @ 2014-03-09 23:06 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Lukasz Rymanowski
In-Reply-To: <1394406397-6843-1-git-send-email-lukasz.rymanowski@tieto.com>
---
android/bluetooth.c | 39 +++++++++++++++++++++++++++++++++++----
1 file changed, 35 insertions(+), 4 deletions(-)
diff --git a/android/bluetooth.c b/android/bluetooth.c
index ba4f14b..60ca17d 100644
--- a/android/bluetooth.c
+++ b/android/bluetooth.c
@@ -97,6 +97,8 @@ struct device {
GSList *uuids;
bool found; /* if device is found in current discovery session */
+ unsigned int confirm_id; /* mgtm command id if command pending */
+
};
struct browse_req {
@@ -318,6 +320,9 @@ static struct device *find_device(const bdaddr_t *bdaddr)
static void free_device(struct device *dev)
{
+ if (dev->confirm_id)
+ mgmt_cancel(mgmt_if, dev->confirm_id);
+
g_free(dev->name);
g_free(dev->friendly_name);
g_slist_free_full(dev->uuids, g_free);
@@ -1023,10 +1028,31 @@ static void mgmt_discovering_event(uint16_t index, uint16_t length,
HAL_EV_DISCOVERY_STATE_CHANGED, sizeof(cp), &cp);
}
-static void confirm_device_name(const bdaddr_t *addr, uint8_t addr_type,
+static void confirm_device_name_cb(uint8_t status, uint16_t length,
+ const void *param, void *user_data)
+{
+ const struct mgmt_rp_confirm_name *rp = param;
+ struct device *dev;
+
+ DBG("Confirm name status: %s (0x%02x)", mgmt_errstr(status), status);
+
+ if (length < sizeof(*rp)) {
+ error("Wrong size of confirm name response");
+ return;
+ }
+
+ dev = find_device(&rp->addr.bdaddr);
+ if (!dev)
+ return;
+
+ dev->confirm_id = 0;
+}
+
+static unsigned int confirm_device_name(const bdaddr_t *addr, uint8_t addr_type,
bool resolve_name)
{
struct mgmt_cp_confirm_name cp;
+ unsigned int res;
memset(&cp, 0, sizeof(cp));
bacpy(&cp.addr.bdaddr, addr);
@@ -1035,9 +1061,13 @@ static void confirm_device_name(const bdaddr_t *addr, uint8_t addr_type,
if (!resolve_name)
cp.name_known = 1;
- if (mgmt_reply(mgmt_if, MGMT_OP_CONFIRM_NAME, adapter.index,
- sizeof(cp), &cp, NULL, NULL, NULL) == 0)
+ res = mgmt_reply(mgmt_if, MGMT_OP_CONFIRM_NAME, adapter.index,
+ sizeof(cp), &cp, confirm_device_name_cb,
+ NULL, NULL);
+ if (!res)
error("Failed to send confirm name request");
+
+ return res;
}
static int fill_hal_prop(void *buf, uint8_t type, uint16_t len,
@@ -1205,7 +1235,8 @@ static void update_found_device(const bdaddr_t *bdaddr, uint8_t bdaddr_type,
info("Device %s needs name confirmation (resolve_name=%d)",
addr, resolve_name);
- confirm_device_name(bdaddr, bdaddr_type, resolve_name);
+ dev->confirm_id = confirm_device_name(bdaddr, bdaddr_type,
+ resolve_name);
}
}
--
1.8.4
^ permalink raw reply related
* [PATCH v2 2/3] android: Cancel all pending confirm name before stop discovery
From: Lukasz Rymanowski @ 2014-03-09 23:06 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Lukasz Rymanowski
In-Reply-To: <1394406397-6843-1-git-send-email-lukasz.rymanowski@tieto.com>
If user wants to cancel discovery we should remove all the confirm name
requests from mgmt queues.
It is in order to make sure that stop discovery have a free way to
reach kernel.
This improves scenario when there is a big inflow of device found events and
mgmt queues become full of confirm name requests. In such case stop discovery
might stack in the queue.
---
android/bluetooth.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/android/bluetooth.c b/android/bluetooth.c
index 60ca17d..9286c67 100644
--- a/android/bluetooth.c
+++ b/android/bluetooth.c
@@ -2467,6 +2467,14 @@ static bool start_discovery(void)
return false;
}
+static void cancel_pending_confirm_name(gpointer data, gpointer user_data)
+{
+ struct device *dev = data;
+
+ mgmt_cancel(mgmt_if, dev->confirm_id);
+ dev->confirm_id = 0;
+}
+
static bool stop_discovery(void)
{
struct mgmt_cp_stop_discovery cp;
@@ -2481,6 +2489,9 @@ static bool stop_discovery(void)
DBG("type=0x%x", cp.type);
+ /* Lets drop all confirm name request as we don't need it anymore */
+ g_slist_foreach(cached_devices, cancel_pending_confirm_name, NULL);
+
if (mgmt_send(mgmt_if, MGMT_OP_STOP_DISCOVERY, adapter.index,
sizeof(cp), &cp, NULL, NULL, NULL) > 0)
return true;
--
1.8.4
^ permalink raw reply related
* [PATCH v2 3/3] android: Send confirm name request with mgmt_send
From: Lukasz Rymanowski @ 2014-03-09 23:06 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Lukasz Rymanowski
In-Reply-To: <1394406397-6843-1-git-send-email-lukasz.rymanowski@tieto.com>
This patch improves handling stop disvocery in scenarios when there is a big
inflow of device found events. In such case, number of confirm
name request might block mgmt queses and make stop discovery stack in the queue.
Even we cancel previous confirm name request, there is still possibility that
new incoming device found events produce confirm name request which will
might block stop discovery.
---
android/bluetooth.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/android/bluetooth.c b/android/bluetooth.c
index 9286c67..158eb2a 100644
--- a/android/bluetooth.c
+++ b/android/bluetooth.c
@@ -1061,7 +1061,7 @@ static unsigned int confirm_device_name(const bdaddr_t *addr, uint8_t addr_type,
if (!resolve_name)
cp.name_known = 1;
- res = mgmt_reply(mgmt_if, MGMT_OP_CONFIRM_NAME, adapter.index,
+ res = mgmt_send(mgmt_if, MGMT_OP_CONFIRM_NAME, adapter.index,
sizeof(cp), &cp, confirm_device_name_cb,
NULL, NULL);
if (!res)
--
1.8.4
^ permalink raw reply related
* DUNS for GPRS/EDGE-enabled 2G phone under BlueZ5.14
From: Ranjan Maitra @ 2014-03-10 2:35 UTC (permalink / raw)
To: linux-bluetooth
Hello,
I am new to this list and I am writing because I am in urgent need of
some pointers/help. I connect through a GPRS/EDGE-enabled 2G phone
using Bluetooth which worked seamlessly under Bluez4. However, I am
unable to get it to work under Bluez-5.14 (on Fedora 20). I tried using
bluetoothctl but I am unable to even pair the device.
Here is what I get:
$ bluetoothctl
[NEW] Controller B4:B6:76:57:B1:46 alakananda.stat.iastate.edu-0
[default] [NEW] Device FC:A1:3E:B8:26:D4 SGH-T249
[bluetooth]# power on
Changing power on succeeded
[bluetooth]# devices
Device FC:A1:3E:B8:26:D4 SGH-T249
[bluetooth]# pair FC:A1:3E:B8:26:D4
Attempting to pair with FC:A1:3E:B8:26:D4
[CHG] Device FC:A1:3E:B8:26:D4 Paired: yes
Pairing successful
[CHG] Device FC:A1:3E:B8:26:D4 Connected: yes
[CHG] Device FC:A1:3E:B8:26:D4 Paired: no
[CHG] Device FC:A1:3E:B8:26:D4 Connected: no
....
I do not know how to get this to work. Is DUNS no longer there under
Bluez5? Or am I missing some library?
I am sorry if this is a simple question but it would be really nice to
get some pointers. I am not afraid of reading manuals and going
through the commandline.
Please keep replies to the list.
Many thanks for any help!
Best wishes,
Ranjan
--
Important Notice: This mailbox is ignored: e-mails are set to be
deleted on receipt. Please respond to the mailing list if appropriate.
For those needing to send personal or professional e-mail, please use
appropriate addresses.
____________________________________________________________
Send any screenshot to your friends in seconds...
Works in all emails, instant messengers, blogs, forums and social networks.
TRY IM TOOLPACK at http://www.imtoolpack.com/default.aspx?rc=if2 for FREE
^ permalink raw reply
* [PATCH v2] Bluetooth: Make LTK and CSRK only persisent when bonding
From: Marcel Holtmann @ 2014-03-10 6:38 UTC (permalink / raw)
To: linux-bluetooth
In case the pairable option has been disabled, the pairing procedure
does not create keys for bonding. This means that these generated keys
should not be stored persistently.
For LTK and CSRK this is important to tell userspace to not store these
new keys. They will be available for the lifetime of the device, but
after the next power cycle they should not be used anymore.
Make sure that the SMP pairing procedures rememberes the authentication
request information for bonding and if both sides request bonding, then
inform userspace to actually store the keys persistently.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
---
include/net/bluetooth/hci_core.h | 5 +++--
net/bluetooth/mgmt.c | 9 +++++----
net/bluetooth/smp.c | 13 +++++++++----
net/bluetooth/smp.h | 1 +
4 files changed, 18 insertions(+), 10 deletions(-)
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index e869884fbfa9..b8cc39a4a9a5 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -1270,9 +1270,10 @@ void mgmt_remote_name(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type,
void mgmt_discovering(struct hci_dev *hdev, u8 discovering);
int mgmt_device_blocked(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type);
int mgmt_device_unblocked(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type);
-void mgmt_new_ltk(struct hci_dev *hdev, struct smp_ltk *key);
+void mgmt_new_ltk(struct hci_dev *hdev, struct smp_ltk *key, bool persistent);
void mgmt_new_irk(struct hci_dev *hdev, struct smp_irk *irk);
-void mgmt_new_csrk(struct hci_dev *hdev, struct smp_csrk *csrk);
+void mgmt_new_csrk(struct hci_dev *hdev, struct smp_csrk *csrk,
+ bool persistent);
void mgmt_reenable_advertising(struct hci_dev *hdev);
void mgmt_smp_complete(struct hci_conn *conn, bool complete);
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 9c7788914b4e..fbcf9d4f130b 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -5005,7 +5005,7 @@ void mgmt_new_link_key(struct hci_dev *hdev, struct link_key *key,
mgmt_event(MGMT_EV_NEW_LINK_KEY, hdev, &ev, sizeof(ev), NULL);
}
-void mgmt_new_ltk(struct hci_dev *hdev, struct smp_ltk *key)
+void mgmt_new_ltk(struct hci_dev *hdev, struct smp_ltk *key, bool persistent)
{
struct mgmt_ev_new_long_term_key ev;
@@ -5026,7 +5026,7 @@ void mgmt_new_ltk(struct hci_dev *hdev, struct smp_ltk *key)
(key->bdaddr.b[5] & 0xc0) != 0xc0)
ev.store_hint = 0x00;
else
- ev.store_hint = 0x01;
+ ev.store_hint = persistent;
bacpy(&ev.key.addr.bdaddr, &key->bdaddr);
ev.key.addr.type = link_to_bdaddr(LE_LINK, key->bdaddr_type);
@@ -5073,7 +5073,8 @@ void mgmt_new_irk(struct hci_dev *hdev, struct smp_irk *irk)
mgmt_event(MGMT_EV_NEW_IRK, hdev, &ev, sizeof(ev), NULL);
}
-void mgmt_new_csrk(struct hci_dev *hdev, struct smp_csrk *csrk)
+void mgmt_new_csrk(struct hci_dev *hdev, struct smp_csrk *csrk,
+ bool persistent)
{
struct mgmt_ev_new_csrk ev;
@@ -5092,7 +5093,7 @@ void mgmt_new_csrk(struct hci_dev *hdev, struct smp_csrk *csrk)
(csrk->bdaddr.b[5] & 0xc0) != 0xc0)
ev.store_hint = 0x00;
else
- ev.store_hint = 0x01;
+ ev.store_hint = persistent;
bacpy(&ev.key.addr.bdaddr, &csrk->bdaddr);
ev.key.addr.type = link_to_bdaddr(LE_LINK, csrk->bdaddr_type);
diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c
index fc652592daf6..aaedde9adafd 100644
--- a/net/bluetooth/smp.c
+++ b/net/bluetooth/smp.c
@@ -286,6 +286,8 @@ static void build_pairing_cmd(struct l2cap_conn *conn,
if (test_bit(HCI_PRIVACY, &hdev->dev_flags))
local_dist |= SMP_DIST_ID_KEY;
+ smp->auth_req = authreq;
+
if (rsp == NULL) {
req->io_capability = conn->hcon->io_capability;
req->oob_flag = SMP_OOB_NOT_PRESENT;
@@ -1209,32 +1211,35 @@ static void smp_notify_keys(struct l2cap_conn *conn)
struct smp_chan *smp = conn->smp_chan;
struct hci_conn *hcon = conn->hcon;
struct hci_dev *hdev = hcon->hdev;
+ bool persistent;
if (smp->remote_irk)
mgmt_new_irk(hdev, smp->remote_irk);
+ persistent = !!(smp->auth_req & SMP_AUTH_BONDING);
+
if (smp->csrk) {
smp->csrk->bdaddr_type = hcon->dst_type;
bacpy(&smp->csrk->bdaddr, &hcon->dst);
- mgmt_new_csrk(hdev, smp->csrk);
+ mgmt_new_csrk(hdev, smp->csrk, persistent);
}
if (smp->slave_csrk) {
smp->slave_csrk->bdaddr_type = hcon->dst_type;
bacpy(&smp->slave_csrk->bdaddr, &hcon->dst);
- mgmt_new_csrk(hdev, smp->slave_csrk);
+ mgmt_new_csrk(hdev, smp->slave_csrk, persistent);
}
if (smp->ltk) {
smp->ltk->bdaddr_type = hcon->dst_type;
bacpy(&smp->ltk->bdaddr, &hcon->dst);
- mgmt_new_ltk(hdev, smp->ltk);
+ mgmt_new_ltk(hdev, smp->ltk, persistent);
}
if (smp->slave_ltk) {
smp->slave_ltk->bdaddr_type = hcon->dst_type;
bacpy(&smp->slave_ltk->bdaddr, &hcon->dst);
- mgmt_new_ltk(hdev, smp->slave_ltk);
+ mgmt_new_ltk(hdev, smp->slave_ltk, persistent);
}
}
diff --git a/net/bluetooth/smp.h b/net/bluetooth/smp.h
index f223b9d38b61..b7c6f903e895 100644
--- a/net/bluetooth/smp.h
+++ b/net/bluetooth/smp.h
@@ -131,6 +131,7 @@ struct smp_chan {
u8 rrnd[16]; /* SMP Pairing Random (remote) */
u8 pcnf[16]; /* SMP Pairing Confirm */
u8 tk[16]; /* SMP Temporary Key */
+ u8 auth_req;
u8 enc_key_size;
u8 remote_key_dist;
bdaddr_t id_addr;
--
1.8.5.3
^ permalink raw reply related
* Re: [PATCH 1/2] unit/avrcp: Add /TP/NFY/BV-03-C test
From: Andrei Emeltchenko @ 2014-03-10 8:30 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1394206711-5508-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
On Fri, Mar 07, 2014 at 05:38:30PM +0200, Andrei Emeltchenko wrote:
> From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
>
> Test verifies that Target responds Register notification command with
> parameter AVRCP_EVENT_SETTINGS_CHANGED.
ping
> ---
> unit/test-avrcp.c | 24 ++++++++++++++++++++++++
> 1 file changed, 24 insertions(+)
>
> diff --git a/unit/test-avrcp.c b/unit/test-avrcp.c
> index 0e3bb51..c442001 100644
> --- a/unit/test-avrcp.c
> +++ b/unit/test-avrcp.c
> @@ -521,6 +521,12 @@ static ssize_t avrcp_handle_register_notification(struct avrcp *session,
> memset(&pdu[1], 0xff, 8);
> pdu_len += 8;
> break;
> + case AVRCP_EVENT_SETTINGS_CHANGED:
> + pdu[1] = 0x01;
> + pdu[2] = 0x01;
> + pdu[3] = 0x02;
> + pdu_len = 4;
> + break;
> default:
> return -EINVAL;
> }
> @@ -938,5 +944,23 @@ int main(int argc, char *argv[])
> 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> 0xff, 0xff));
>
> + /* Register notification - TG */
> + define_test("/TP/NFY/BV-03-C", test_server,
> + raw_pdu(0x00, 0x11, 0x0e, 0x03, 0x48, 0x00,
> + 0x00, 0x19, 0x58, AVRCP_REGISTER_NOTIFICATION,
> + 0x00, 0x00, 0x05,
> + AVRCP_EVENT_SETTINGS_CHANGED,
> + 0x00, 0x00, 0x00, 0x00),
> + raw_pdu(0x02, 0x11, 0x0e, AVC_CTYPE_INTERIM, 0x48, 0x00,
> + 0x00, 0x19, 0x58, AVRCP_REGISTER_NOTIFICATION,
> + 0x00, 0x00, 0x04,
> + AVRCP_EVENT_SETTINGS_CHANGED,
> + 0x01, 0x01, 0x02),
> + raw_pdu(0x02, 0x11, 0x0e, AVC_CTYPE_CHANGED, 0x48, 0x00,
> + 0x00, 0x19, 0x58, AVRCP_REGISTER_NOTIFICATION,
> + 0x00, 0x00, 0x04,
> + AVRCP_EVENT_SETTINGS_CHANGED,
> + 0x01, 0x01, 0x02));
> +
> return g_test_run();
> }
> --
> 1.8.3.2
>
> --
> 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
^ permalink raw reply
* Re: [PATCH 1/9] unit/avrcp: Add /TP/MDI/BV-01-C test
From: Andrei Emeltchenko @ 2014-03-10 8:32 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1394193113-32347-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
On Fri, Mar 07, 2014 at 01:51:45PM +0200, Andrei Emeltchenko wrote:
> From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
>
> Test verifies Get play status.
ping
> ---
> unit/test-avrcp.c | 31 +++++++++++++++++++++++++++++++
> 1 file changed, 31 insertions(+)
>
> diff --git a/unit/test-avrcp.c b/unit/test-avrcp.c
> index db1a67e..4f81954 100644
> --- a/unit/test-avrcp.c
> +++ b/unit/test-avrcp.c
> @@ -459,6 +459,23 @@ static ssize_t avrcp_handle_set_player_value(struct avrcp *session,
> return 1;
> }
>
> +static ssize_t avrcp_handle_get_play_status(struct avrcp *session,
> + uint8_t transaction,
> + uint16_t params_len,
> + uint8_t *params,
> + void *user_data)
> +{
> + DBG("");
> +
> + if (params_len)
> + return -EINVAL;
> +
> + avrcp_get_play_status_rsp(session, transaction, 0xaaaaaaaa, 0xbbbbbbbb,
> + 0x00);
> +
> + return -EAGAIN;
> +}
> +
> static const struct avrcp_control_handler control_handlers[] = {
> { AVRCP_GET_CAPABILITIES,
> AVC_CTYPE_STATUS, AVC_CTYPE_STABLE,
> @@ -481,6 +498,9 @@ static const struct avrcp_control_handler control_handlers[] = {
> { AVRCP_SET_PLAYER_VALUE,
> AVC_CTYPE_CONTROL, AVC_CTYPE_STABLE,
> avrcp_handle_set_player_value },
> + { AVRCP_GET_PLAY_STATUS,
> + AVC_CTYPE_STATUS, AVC_CTYPE_STABLE,
> + avrcp_handle_get_play_status },
> { },
> };
>
> @@ -782,5 +802,16 @@ int main(int argc, char *argv[])
> 0x00, 0x19, 0x58, AVRCP_GET_PLAY_STATUS,
> 0x00, 0x00, 0x00));
>
> + /* Get play status - TG */
> + define_test("/TP/MDI/BV-02-C", test_server,
> + raw_pdu(0x00, 0x11, 0x0e, 0x01, 0x48, 0x00,
> + 0x00, 0x19, 0x58, AVRCP_GET_PLAY_STATUS,
> + 0x00, 0x00, 0x00),
> + raw_pdu(0x02, 0x11, 0x0e, 0x0c, 0x48, 0x00,
> + 0x00, 0x19, 0x58, AVRCP_GET_PLAY_STATUS,
> + 0x00, 0x00, 0x09, 0xaa, 0xaa, 0xaa,
> + 0xaa, 0xbb, 0xbb, 0xbb, 0xbb, 0x00));
> +
> +
> return g_test_run();
> }
> --
> 1.8.3.2
>
> --
> 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
^ permalink raw reply
* [RC6 Bell Chime] Re: [PATCH 00/24] rfcomm fixes
From: Sander Eikelenboom @ 2014-03-10 8:38 UTC (permalink / raw)
To: Sander Eikelenboom, Marcel Holtmann, Gustavo F. Padovan,
Peter Hurley, Linus Torvalds
Cc: bluez mailin list (linux-bluetooth@vger.kernel.org), linux-kernel
In-Reply-To: <1335661753.20140303203853@eikelenboom.it>
Hi all,
Since:
- 3.14-RC6 has been cut
- this regression is known and reported since the merge window
- the fix (revert of 3 patches) is known for over a month now
- but it's still not in mainline
- my polite ping request from last week seems to have provoked exactly 0 (zero) response.
IT'S TIME TO CHIME SOME BELLS :-)
Hope that WILL be heard somewhere ...
--
Sander
PS. on the informative side the 3 commits to be reverted are:
f86772af6a0f643d3e13eb3f4f9213ae0c333ee4 Bluetooth: Remove rfcomm_carrier_raised()
4a2fb3ecc7467c775b154813861f25a0ddc11aa0 Bluetooth: Always wait for a connection on RFCOMM open()
e228b63390536f5b737056059a9a04ea016b1abf Bluetooth: Move rfcomm_get_device() before rfcomm_dev_activate()
Monday, March 3, 2014, 8:38:53 PM, you wrote:
> Wednesday, February 12, 2014, 12:06:44 PM, you wrote:
>> Monday, February 10, 2014, 11:09:38 PM, you wrote:
>>> Hi Peter,
>>>> This patch series addresses a number of previously unknown issues
>>>> with the RFCOMM tty device implementation, in addition to
>>>> addressing the locking regression recently reported [1].
>>>>
>>>> As Gianluca suggested and I agree, this series first reverts
>>>> 3 of the 4 patches of 3.14-rc1 for bluetooth/rfcomm/tty.c.
>>> so for 3.14 we should revert 3 patches. And then the other 21 are intended for 3.15 merge window.
>>> I realize that we still have to deal with some breakage, but we do not want regressions and I clearly not going to take 24 patches for 3.14 at this point in time.
>>> What I can do is take all 24 patches into bluetooth-next and let them sit for 1 week and have people test them. And then we go ahead with reverting 3 patches from 3.14. Does that make sense?
>> Reverting those 3 patches works for me.
>> --
>> Sander
>>> Regards
>>> Marcel
> Hi Marcel,
> Ping... it seems these 3 reverts are still not in 3.14-rc5 to fix the regressions ?
> --
> Sander
--
Best regards,
Sander mailto:linux@eikelenboom.it
^ permalink raw reply
* Re: [PATCH 9/9] doc: Update test coverage document
From: Szymon Janc @ 2014-03-10 9:04 UTC (permalink / raw)
To: Andrei Emeltchenko; +Cc: linux-bluetooth
In-Reply-To: <1393851227-23483-9-git-send-email-Andrei.Emeltchenko.news@gmail.com>
Hi Andrei,
On Monday 03 of March 2014 14:53:47 Andrei Emeltchenko wrote:
> From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
>
> Update AVRCP test numbers.
> ---
> doc/test-coverage.txt | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/doc/test-coverage.txt b/doc/test-coverage.txt
> index 7965f8e..89d884f 100644
> --- a/doc/test-coverage.txt
> +++ b/doc/test-coverage.txt
> @@ -18,7 +18,7 @@ test-ringbuf 3 Ring buffer functionality
> test-queue 1 Queue handling functionality
> test-avdtp 60 AVDTP qualification test cases
> test-avctp 9 AVCTP qualification test cases
> -test-avrcp 7 AVRCP qualification test cases
> +test-avrcp 23 AVRCP qualification test cases
> test-gobex 31 Generic OBEX functionality
> test-gobex-packet 9 OBEX packet handling
> test-gobex-header 28 OBEX header handling
>
Total tests count should be updated as well.
--
Best regards,
Szymon Janc
^ permalink raw reply
* [PATCHv2 01/10] unit/avrcp: Add /TP/MDI/BV-01-C test
From: Andrei Emeltchenko @ 2014-03-10 9:09 UTC (permalink / raw)
To: linux-bluetooth
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Test verifies Get play status.
---
unit/test-avrcp.c | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/unit/test-avrcp.c b/unit/test-avrcp.c
index db1a67e..4f81954 100644
--- a/unit/test-avrcp.c
+++ b/unit/test-avrcp.c
@@ -459,6 +459,23 @@ static ssize_t avrcp_handle_set_player_value(struct avrcp *session,
return 1;
}
+static ssize_t avrcp_handle_get_play_status(struct avrcp *session,
+ uint8_t transaction,
+ uint16_t params_len,
+ uint8_t *params,
+ void *user_data)
+{
+ DBG("");
+
+ if (params_len)
+ return -EINVAL;
+
+ avrcp_get_play_status_rsp(session, transaction, 0xaaaaaaaa, 0xbbbbbbbb,
+ 0x00);
+
+ return -EAGAIN;
+}
+
static const struct avrcp_control_handler control_handlers[] = {
{ AVRCP_GET_CAPABILITIES,
AVC_CTYPE_STATUS, AVC_CTYPE_STABLE,
@@ -481,6 +498,9 @@ static const struct avrcp_control_handler control_handlers[] = {
{ AVRCP_SET_PLAYER_VALUE,
AVC_CTYPE_CONTROL, AVC_CTYPE_STABLE,
avrcp_handle_set_player_value },
+ { AVRCP_GET_PLAY_STATUS,
+ AVC_CTYPE_STATUS, AVC_CTYPE_STABLE,
+ avrcp_handle_get_play_status },
{ },
};
@@ -782,5 +802,16 @@ int main(int argc, char *argv[])
0x00, 0x19, 0x58, AVRCP_GET_PLAY_STATUS,
0x00, 0x00, 0x00));
+ /* Get play status - TG */
+ define_test("/TP/MDI/BV-02-C", test_server,
+ raw_pdu(0x00, 0x11, 0x0e, 0x01, 0x48, 0x00,
+ 0x00, 0x19, 0x58, AVRCP_GET_PLAY_STATUS,
+ 0x00, 0x00, 0x00),
+ raw_pdu(0x02, 0x11, 0x0e, 0x0c, 0x48, 0x00,
+ 0x00, 0x19, 0x58, AVRCP_GET_PLAY_STATUS,
+ 0x00, 0x00, 0x09, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xbb, 0xbb, 0xbb, 0xbb, 0x00));
+
+
return g_test_run();
}
--
1.8.3.2
^ permalink raw reply related
* [PATCHv2 02/10] android/avrcp: Add avrcp_get_element_attributes() function
From: Andrei Emeltchenko @ 2014-03-10 9:09 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1394442593-4233-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
---
android/avrcp-lib.c | 13 +++++++++++++
android/avrcp-lib.h | 2 ++
2 files changed, 15 insertions(+)
diff --git a/android/avrcp-lib.c b/android/avrcp-lib.c
index b67fa32..5400f80 100644
--- a/android/avrcp-lib.c
+++ b/android/avrcp-lib.c
@@ -427,6 +427,19 @@ int avrcp_set_volume(struct avrcp *session, uint8_t volume, avctp_rsp_cb func,
func, user_data);
}
+int avrcp_get_element_attributes(struct avrcp *session, avctp_rsp_cb func,
+ void *user_data)
+{
+ uint8_t buf[9];
+
+ /* This returns all attributes */
+ memset(buf, 0, sizeof(buf));
+
+ return avrcp_send_req(session, AVC_CTYPE_STATUS, AVC_SUBUNIT_PANEL,
+ AVRCP_GET_ELEMENT_ATTRIBUTES, buf, sizeof(buf),
+ func, user_data);
+}
+
int avrcp_get_play_status_rsp(struct avrcp *session, uint8_t transaction,
uint32_t position, uint32_t duration,
uint8_t status)
diff --git a/android/avrcp-lib.h b/android/avrcp-lib.h
index 30d220e..4c845d3 100644
--- a/android/avrcp-lib.h
+++ b/android/avrcp-lib.h
@@ -150,6 +150,8 @@ int avrcp_get_play_status(struct avrcp *session, avctp_rsp_cb func,
void *user_data);
int avrcp_set_volume(struct avrcp *session, uint8_t volume, avctp_rsp_cb func,
void *user_data);
+int avrcp_get_element_attributes(struct avrcp *session, avctp_rsp_cb func,
+ void *user_data);
int avrcp_get_play_status_rsp(struct avrcp *session, uint8_t transaction,
uint32_t position, uint32_t duration,
--
1.8.3.2
^ permalink raw reply related
* [PATCHv2 03/10] unit/avrcp: Add /TP/MDI/BV-03-C test
From: Andrei Emeltchenko @ 2014-03-10 9:09 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1394442593-4233-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Test verifies that Get element attributes issued correctly.
---
unit/test-avrcp.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/unit/test-avrcp.c b/unit/test-avrcp.c
index 4f81954..9b334e6 100644
--- a/unit/test-avrcp.c
+++ b/unit/test-avrcp.c
@@ -553,6 +553,9 @@ static void test_client(gconstpointer data)
if (g_str_equal(context->data->test_name, "/TP/MDI/BV-01-C"))
avrcp_get_play_status(context->session, NULL, NULL);
+ if (g_str_equal(context->data->test_name, "/TP/MDI/BV-03-C"))
+ avrcp_get_element_attributes(context->session, NULL, NULL);
+
execute_context(context);
}
@@ -812,6 +815,12 @@ int main(int argc, char *argv[])
0x00, 0x00, 0x09, 0xaa, 0xaa, 0xaa,
0xaa, 0xbb, 0xbb, 0xbb, 0xbb, 0x00));
+ /* Get element attributes - CT */
+ define_test("/TP/MDI/BV-03-C", test_client,
+ raw_pdu(0x00, 0x11, 0x0e, 0x01, 0x48, 0x00,
+ 0x00, 0x19, 0x58, AVRCP_GET_ELEMENT_ATTRIBUTES,
+ 0x00, 0x00, 0x09, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00));
return g_test_run();
}
--
1.8.3.2
^ permalink raw reply related
* [PATCHv2 04/10] unit/avrcp: Add /TP/MDI/BV-04-C test
From: Andrei Emeltchenko @ 2014-03-10 9:09 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1394442593-4233-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Test verifies Get element attributes responded by Target.
---
unit/test-avrcp.c | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/unit/test-avrcp.c b/unit/test-avrcp.c
index 9b334e6..393afee 100644
--- a/unit/test-avrcp.c
+++ b/unit/test-avrcp.c
@@ -476,6 +476,22 @@ static ssize_t avrcp_handle_get_play_status(struct avrcp *session,
return -EAGAIN;
}
+static ssize_t avrcp_handle_get_element_attrs(struct avrcp *session,
+ uint8_t transaction,
+ uint16_t params_len,
+ uint8_t *params,
+ void *user_data)
+{
+ DBG("");
+
+ if (params_len < 9)
+ return -EINVAL;
+
+ avrcp_get_element_attrs_rsp(session, transaction, NULL, 0);
+
+ return -EAGAIN;
+}
+
static const struct avrcp_control_handler control_handlers[] = {
{ AVRCP_GET_CAPABILITIES,
AVC_CTYPE_STATUS, AVC_CTYPE_STABLE,
@@ -501,6 +517,9 @@ static const struct avrcp_control_handler control_handlers[] = {
{ AVRCP_GET_PLAY_STATUS,
AVC_CTYPE_STATUS, AVC_CTYPE_STABLE,
avrcp_handle_get_play_status },
+ { AVRCP_GET_ELEMENT_ATTRIBUTES,
+ AVC_CTYPE_STATUS, AVC_CTYPE_STABLE,
+ avrcp_handle_get_element_attrs },
{ },
};
@@ -822,5 +841,14 @@ int main(int argc, char *argv[])
0x00, 0x00, 0x09, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00));
+ /* Get element attributes - TG */
+ define_test("/TP/MDI/BV-04-C", test_server,
+ raw_pdu(0x00, 0x11, 0x0e, 0x01, 0x48, 0x00,
+ 0x00, 0x19, 0x58, AVRCP_GET_ELEMENT_ATTRIBUTES,
+ 0x00, 0x00, 0x09, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00),
+ raw_pdu(0x02, 0x11, 0x0e, 0x0c, 0x48, 0x00,
+ 0x00, 0x19, 0x58, AVRCP_GET_ELEMENT_ATTRIBUTES,
+ 0x00, 0x00, 0x00));
return g_test_run();
}
--
1.8.3.2
^ permalink raw reply related
* [PATCHv2 05/10] unit/avrcp: Add /TP/MDI/BV-05-C test
From: Andrei Emeltchenko @ 2014-03-10 9:09 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1394442593-4233-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Test verifies that Target responds to Get element attributes cmd.
---
unit/test-avrcp.c | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/unit/test-avrcp.c b/unit/test-avrcp.c
index 393afee..496dd1b 100644
--- a/unit/test-avrcp.c
+++ b/unit/test-avrcp.c
@@ -482,11 +482,14 @@ static ssize_t avrcp_handle_get_element_attrs(struct avrcp *session,
uint8_t *params,
void *user_data)
{
- DBG("");
+ DBG("params_len %d params[8] %d", params_len, params[8]);
if (params_len < 9)
return -EINVAL;
+ if (params_len != 9 + params[8] * 4)
+ return -EINVAL;
+
avrcp_get_element_attrs_rsp(session, transaction, NULL, 0);
return -EAGAIN;
@@ -850,5 +853,17 @@ int main(int argc, char *argv[])
raw_pdu(0x02, 0x11, 0x0e, 0x0c, 0x48, 0x00,
0x00, 0x19, 0x58, AVRCP_GET_ELEMENT_ATTRIBUTES,
0x00, 0x00, 0x00));
+
+ /* Get element attributes - TG */
+ define_test("/TP/MDI/BV-05-C", test_server,
+ raw_pdu(0x00, 0x11, 0x0e, 0x01, 0x48, 0x00,
+ 0x00, 0x19, 0x58, AVRCP_GET_ELEMENT_ATTRIBUTES,
+ 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
+ 0x00, 0x00, 0x00, 0x01),
+ raw_pdu(0x02, 0x11, 0x0e, 0x0c, 0x48, 0x00,
+ 0x00, 0x19, 0x58, AVRCP_GET_ELEMENT_ATTRIBUTES,
+ 0x00, 0x00, 0x00));
+
return g_test_run();
}
--
1.8.3.2
^ permalink raw reply related
* [PATCHv2 06/10] unit/avrcp: Add /TP/NFY/BV-01-C test
From: Andrei Emeltchenko @ 2014-03-10 9:09 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1394442593-4233-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Test verifies that Register notification command is issued by
Controller.
---
unit/test-avrcp.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/unit/test-avrcp.c b/unit/test-avrcp.c
index 496dd1b..fa4870d 100644
--- a/unit/test-avrcp.c
+++ b/unit/test-avrcp.c
@@ -578,6 +578,11 @@ static void test_client(gconstpointer data)
if (g_str_equal(context->data->test_name, "/TP/MDI/BV-03-C"))
avrcp_get_element_attributes(context->session, NULL, NULL);
+ if (g_str_equal(context->data->test_name, "/TP/NFY/BV-01-C"))
+ avrcp_register_notification(context->session,
+ AVRCP_EVENT_STATUS_CHANGED, 0,
+ NULL, NULL);
+
execute_context(context);
}
@@ -865,5 +870,14 @@ int main(int argc, char *argv[])
0x00, 0x19, 0x58, AVRCP_GET_ELEMENT_ATTRIBUTES,
0x00, 0x00, 0x00));
+ /* Notification Commands */
+
+ /* Register notification - CT */
+ define_test("/TP/NFY/BV-01-C", test_client,
+ raw_pdu(0x00, 0x11, 0x0e, 0x03, 0x48, 0x00,
+ 0x00, 0x19, 0x58, AVRCP_REGISTER_NOTIFICATION,
+ 0x00, 0x00, 0x05, AVRCP_EVENT_STATUS_CHANGED,
+ 0x00, 0x00, 0x00, 0x00));
+
return g_test_run();
}
--
1.8.3.2
^ permalink raw reply related
* [PATCHv2 07/10] unit/avrcp: Add /TP/NFY/BV-02-C test
From: Andrei Emeltchenko @ 2014-03-10 9:09 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1394442593-4233-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Test verifies that Target responds to Register notification command.
---
android/avrcp-lib.h | 3 +++
unit/test-avrcp.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 62 insertions(+)
diff --git a/android/avrcp-lib.h b/android/avrcp-lib.h
index 4c845d3..91a7d47 100644
--- a/android/avrcp-lib.h
+++ b/android/avrcp-lib.h
@@ -86,6 +86,9 @@
/* Company IDs for vendor dependent commands */
#define IEEEID_BTSIG 0x001958
+/* Parameters legths */
+#define AVRCP_REGISTER_NOTIFICATION_PARAM_LENGTH 5
+
struct avrcp;
struct avrcp_control_handler {
diff --git a/unit/test-avrcp.c b/unit/test-avrcp.c
index fa4870d..0e3bb51 100644
--- a/unit/test-avrcp.c
+++ b/unit/test-avrcp.c
@@ -162,6 +162,8 @@ static gboolean test_handler(GIOChannel *channel, GIOCondition cond,
ssize_t len;
int fd;
+ DBG("");
+
pdu = &context->data->pdu_list[context->pdu_offset++];
if (cond & (G_IO_NVAL | G_IO_ERR | G_IO_HUP)) {
@@ -495,6 +497,43 @@ static ssize_t avrcp_handle_get_element_attrs(struct avrcp *session,
return -EAGAIN;
}
+static ssize_t avrcp_handle_register_notification(struct avrcp *session,
+ uint8_t transaction,
+ uint16_t params_len,
+ uint8_t *params,
+ void *user_data)
+{
+ uint8_t event;
+ uint8_t pdu[1024];
+ size_t pdu_len;
+
+ DBG("");
+
+ if (params_len != AVRCP_REGISTER_NOTIFICATION_PARAM_LENGTH)
+ return -EINVAL;
+
+ event = params[0];
+ pdu[0] = event;
+ pdu_len = 1;
+
+ switch (event) {
+ case AVRCP_EVENT_TRACK_CHANGED:
+ memset(&pdu[1], 0xff, 8);
+ pdu_len += 8;
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ avrcp_register_notification_rsp(session, transaction, AVC_CTYPE_INTERIM,
+ pdu, pdu_len);
+
+ avrcp_register_notification_rsp(session, transaction, AVC_CTYPE_CHANGED,
+ pdu, pdu_len);
+
+ return -EAGAIN;
+}
+
static const struct avrcp_control_handler control_handlers[] = {
{ AVRCP_GET_CAPABILITIES,
AVC_CTYPE_STATUS, AVC_CTYPE_STABLE,
@@ -523,6 +562,9 @@ static const struct avrcp_control_handler control_handlers[] = {
{ AVRCP_GET_ELEMENT_ATTRIBUTES,
AVC_CTYPE_STATUS, AVC_CTYPE_STABLE,
avrcp_handle_get_element_attrs },
+ { AVRCP_REGISTER_NOTIFICATION,
+ AVC_CTYPE_NOTIFY, AVC_CTYPE_INTERIM,
+ avrcp_handle_register_notification },
{ },
};
@@ -879,5 +921,22 @@ int main(int argc, char *argv[])
0x00, 0x00, 0x05, AVRCP_EVENT_STATUS_CHANGED,
0x00, 0x00, 0x00, 0x00));
+ /* Register notification - TG */
+ define_test("/TP/NFY/BV-02-C", test_server,
+ raw_pdu(0x00, 0x11, 0x0e, 0x03, 0x48, 0x00,
+ 0x00, 0x19, 0x58, AVRCP_REGISTER_NOTIFICATION,
+ 0x00, 0x00, 0x05, AVRCP_EVENT_TRACK_CHANGED,
+ 0x00, 0x00, 0x00, 0x00),
+ raw_pdu(0x02, 0x11, 0x0e, AVC_CTYPE_INTERIM, 0x48, 0x00,
+ 0x00, 0x19, 0x58, AVRCP_REGISTER_NOTIFICATION,
+ 0x00, 0x00, 0x09, AVRCP_EVENT_TRACK_CHANGED,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff),
+ raw_pdu(0x02, 0x11, 0x0e, AVC_CTYPE_CHANGED, 0x48, 0x00,
+ 0x00, 0x19, 0x58, AVRCP_REGISTER_NOTIFICATION,
+ 0x00, 0x00, 0x09, AVRCP_EVENT_TRACK_CHANGED,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff));
+
return g_test_run();
}
--
1.8.3.2
^ permalink raw reply related
* [PATCHv2 08/10] unit/avrcp: Add /TP/NFY/BV-03-C test
From: Andrei Emeltchenko @ 2014-03-10 9:09 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1394442593-4233-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Test verifies that Target responds Register notification command with
parameter AVRCP_EVENT_SETTINGS_CHANGED.
---
unit/test-avrcp.c | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/unit/test-avrcp.c b/unit/test-avrcp.c
index 0e3bb51..c442001 100644
--- a/unit/test-avrcp.c
+++ b/unit/test-avrcp.c
@@ -521,6 +521,12 @@ static ssize_t avrcp_handle_register_notification(struct avrcp *session,
memset(&pdu[1], 0xff, 8);
pdu_len += 8;
break;
+ case AVRCP_EVENT_SETTINGS_CHANGED:
+ pdu[1] = 0x01;
+ pdu[2] = 0x01;
+ pdu[3] = 0x02;
+ pdu_len = 4;
+ break;
default:
return -EINVAL;
}
@@ -938,5 +944,23 @@ int main(int argc, char *argv[])
0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff));
+ /* Register notification - TG */
+ define_test("/TP/NFY/BV-03-C", test_server,
+ raw_pdu(0x00, 0x11, 0x0e, 0x03, 0x48, 0x00,
+ 0x00, 0x19, 0x58, AVRCP_REGISTER_NOTIFICATION,
+ 0x00, 0x00, 0x05,
+ AVRCP_EVENT_SETTINGS_CHANGED,
+ 0x00, 0x00, 0x00, 0x00),
+ raw_pdu(0x02, 0x11, 0x0e, AVC_CTYPE_INTERIM, 0x48, 0x00,
+ 0x00, 0x19, 0x58, AVRCP_REGISTER_NOTIFICATION,
+ 0x00, 0x00, 0x04,
+ AVRCP_EVENT_SETTINGS_CHANGED,
+ 0x01, 0x01, 0x02),
+ raw_pdu(0x02, 0x11, 0x0e, AVC_CTYPE_CHANGED, 0x48, 0x00,
+ 0x00, 0x19, 0x58, AVRCP_REGISTER_NOTIFICATION,
+ 0x00, 0x00, 0x04,
+ AVRCP_EVENT_SETTINGS_CHANGED,
+ 0x01, 0x01, 0x02));
+
return g_test_run();
}
--
1.8.3.2
^ 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