* [PATCH 1/5] unit/avrcp: Pass context to control handlers
From: Andrei Emeltchenko @ 2014-03-10 13:39 UTC (permalink / raw)
To: linux-bluetooth
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
---
unit/test-avrcp.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/unit/test-avrcp.c b/unit/test-avrcp.c
index 9760420..fe7009a 100644
--- a/unit/test-avrcp.c
+++ b/unit/test-avrcp.c
@@ -578,7 +578,7 @@ static void test_server(gconstpointer data)
avrcp_set_passthrough_handlers(context->session, passthrough_handlers,
context);
- avrcp_set_control_handlers(context->session, control_handlers, NULL);
+ avrcp_set_control_handlers(context->session, control_handlers, context);
g_idle_add(send_pdu, context);
--
1.8.3.2
^ permalink raw reply related
* Re: Passive scanning of iBeacons results in a "Data Buffer Overflow"
From: Anderson Lizardo @ 2014-03-10 13:21 UTC (permalink / raw)
To: Terry Hardie; +Cc: BlueZ development
In-Reply-To: <alpine.DEB.2.02.1403072307490.21384@orcas.net>
Hi Terry,
On Sat, Mar 8, 2014 at 3:19 AM, Terry Hardie <terryh@orcas.net> wrote:
> The problem is when running a lescan (hcitool lescan) with a LE device in
> paring mode, which is transmitting a lot of LE Advertising report packets,
> the HCI drivers eventually loses sync. I've traced it down to a duplicate
> USB fragment.
I think your logs show missing USB packets (not duplicated)... More
details below.
> I added some code to btusb_intr_complete to print each urb as it comes up
> from the USB stack. Here's the output for the above problem. Note the extra
> "00 02 c7" -- Should not be there...
>
> Mar 8 06:32:12 arm kernel: [ 122.915094] hci1 urb df4a8540 status 0 count
> 16 flags 768
> Mar 8 06:32:12 arm kernel: [ 122.915176] hci1 urb contents: 3e 21 02 01
> 00 01 3c 30 05 7c f9 e1 15 02 01 05
> Mar 8 06:32:12 arm kernel: [ 122.916004] hci1 urb df4a8540 status 0 count
> 16 flags 768
> Mar 8 06:32:12 arm kernel: [ 122.916085] hci1 urb contents: 0d 09 53 63
> 6f 73 63 68 65 20 50 52 4f 58 03 19
> Mar 8 06:32:12 arm kernel: [ 122.916985] hci1 urb df4a8540 status 0 count
> 3 flags 768
> Mar 8 06:32:12 arm kernel: [ 122.917018] hci1 urb contents: 00 02 c2
> Mar 8 06:32:12 arm kernel: [ 122.942995] hci1 urb df4a8540 status 0 count
> 3 flags 768
There is a missing whole 16 byte USB packet right here.
> Mar 8 06:32:12 arm kernel: [ 122.943028] hci1 urb contents: 00 02 c7
The bytes above are part of the Advertising data, plus the RSSI (the
last byte) for the truncated packet.
> I used usbmon to do a "sniff" of the USB traffic. Here's a snippet of a
> correct HCI LE Advertising report event, followed by one where the middle
> fragment is repeated (frame 1300 is a repeat) This is a different capture
> from the above example. I can provide the pcap somewhere if needed
>
> No. Time Source Destination
> Protocol Length Info
> 1291 2014-03-07 02:40:16.942573 host 3.1
> USB 64 URB_INTERRUPT in
> 1292 2014-03-07 02:40:16.959480 3.1 host
> HCI_USB 80 Rcvd Fragment
> 3e21020100013c30057cf9e115020105
> 1293 2014-03-07 02:40:16.959624 host 3.1
> USB 64 URB_INTERRUPT in
> 1294 2014-03-07 02:40:16.960449 3.1 host
> HCI_USB 80 Rcvd Fragment
> 0d0953636f736368652050524f580319
> 1295 2014-03-07 02:40:16.960546 host 3.1
> USB 64 URB_INTERRUPT in
> 1296 2014-03-07 02:40:16.961455 3.1 host
> HCI_EVT 67 Rcvd LE Meta (LE Advertising Report)
> 0002ae
> 1297 2014-03-07 02:40:16.961560 host 3.1
> USB 64 URB_INTERRUPT in
> 1298 2014-03-07 02:40:16.981627 3.1 host
> HCI_USB 80 Rcvd Fragment
> 3e21020100013c30057cf9e115020105
> 1299 2014-03-07 02:40:16.981696 host 3.1
> USB 64 URB_INTERRUPT in
> 1300 2014-03-07 02:40:17.002651 3.1 host
> HCI_USB 80 Rcvd Fragment
> 3e21020100013c30057cf9e115020105
There are two missing fragments between right here.
> 1301 2014-03-07 02:40:17.002720 host 3.1
> USB 64 URB_INTERRUPT in
> 1302 2014-03-07 02:40:17.003560 3.1 host
> HCI_USB 80 Rcvd Fragment
> 0d0953636f736368652050524f580319
> 1303 2014-03-07 02:40:17.003649 host 3.1
> USB 64 URB_INTERRUPT in
> 1304 2014-03-07 02:40:17.004567 3.1 host
> HCI_USB 67 Rcvd Fragment
> 0002b5
In summary, it is expected that for devices that don't change address,
the only byte to change is the RSSI (last byte of the last fragment).
That's why the 2 first fragments are usually the same for all
advertising packets.
--
Anderson Lizardo
http://www.indt.org/?lang=en
INdT - Manaus - Brazil
^ permalink raw reply
* Re: Passive scanning of iBeacons results in a "Data Buffer Overflow"
From: Anderson Lizardo @ 2014-03-10 13:09 UTC (permalink / raw)
To: Adam Warski; +Cc: BlueZ development
In-Reply-To: <A6C5B873-6614-45B3-AD4C-B3E08831E6D8@warski.org>
Hi Adam,
Duplicate filtering is done inside the controller. If you disable
filtering, the controller will receive a lot more packets (the
quantity will depend on device's advertising parameters, but it is
several times more packets).
Even if your Gimbal device changes address on every packet (which is
unusual, usually address changes are time based), what you actually
see without using --duplicate is still a small fraction of what the
controller receives over the air. Try comparing Gimbal on using
--duplicates versus not using (instead of comparing different devices
with different firmware and adv. parameters). Try counting number of
adv. reports on both situations. I expect to see a lot more when
--duplicate is enabled...
Regarding the logs, it seems your dmesg.txt seems only to show the
last lines of debugging... maybe the dmesg buffer is too short. Can
you check if there is a more complete log generated in one of the
/var/log/kern.log.* files ?
Fortunately, It contains one snippet showing problems with HCI
reassembly from USB packets:
[ 878.184532] btusb_intr_complete: hci0 urb d9a8d300 status 0 count 16
[ 878.185499] btusb_intr_complete: hci0 urb d9a8d300 status 0 count 16
[ 878.186498] btusb_intr_complete: hci0 urb d9a8d300 status 0 count 12
[ 878.386548] btusb_intr_complete: hci0 urb d9a8d300 status 0 count 16
[ 878.387530] btusb_intr_complete: hci0 urb d9a8d300 status 0 count 16
[ 878.387664] hci_rx_work: hci0
[ 878.387693] hci_send_to_monitor: hdev d9a4e000 len 64
[ 878.387783] hci_send_to_sock: hdev d9a4e000 len 64
[ 878.387803] hci_rx_work: hci0 Event packet
[ 878.387822] hci_event_packet: hci0 event 0xbc
[ 878.387847] hci_send_to_monitor: hdev d9a4e000 len 4
[ 878.387896] hci_send_to_sock: hdev d9a4e000 len 4
[ 878.387913] hci_rx_work: hci0 Event packet
[ 878.387930] hci_req_cmd_complete: opcode 0x200c status 0x00
[ 878.387945] hci_sent_cmd_data: hci0 opcode 0x200c
[ 878.387959] hci_event_packet: hci0 event 0x00
[ 878.388058] hci_sock_recvmsg: sock da567840, sk daa9c800
It contains 3 bogus events:
> HCI Event: Unknown (0xbc) plen 62
> HCI Event: Unknown (0x00) plen 2
> HCI Event: Physical Link Complete (0x40) plen 127
For me, it still points out to corrupted/truncated USB packets.
Unfortunately, it is just indirect evidence as the logs don't show raw
USB packets. But you can definitively confirm by using a USB sniffer
tool. I recommend using tshark (wireshark's command line interface).
It works just fine on raspberry. See this post for instructions:
http://nagaraj-embedded.blogspot.com.br/2012/03/capturing-usb-data-through-wireshark.html
Note that on raspberry there is just "usbmon1" (i.e. Bus 1), and
everything is attached to it. So the logs will get other unrelated
traffic (like ethernet packets), but wireshark GUI is powerful enough
to filter only traffic related to a specific device.
Best Regards,
--
Anderson Lizardo
http://www.indt.org/?lang=en
INdT - Manaus - Brazil
^ permalink raw reply
* Re: [PATCHv2 01/10] unit/avrcp: Add /TP/MDI/BV-01-C test
From: Luiz Augusto von Dentz @ 2014-03-10 13:01 UTC (permalink / raw)
To: Andrei Emeltchenko; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <1394442593-4233-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
Hi Andrei,
On Mon, Mar 10, 2014 at 11:09 AM, Andrei Emeltchenko
<Andrei.Emeltchenko.news@gmail.com> wrote:
> 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
Applied, thanks.
--
Luiz Augusto von Dentz
^ permalink raw reply
* Re: [PATCH v4 1/3] android/avrcp: Fill attributes in case of empty for GetElementAttributes
From: Luiz Augusto von Dentz @ 2014-03-10 12:12 UTC (permalink / raw)
To: linux-bluetooth@vger.kernel.org
In-Reply-To: <1394453116-9354-1-git-send-email-luiz.dentz@gmail.com>
Hi,
On Mon, Mar 10, 2014 at 2:05 PM, Luiz Augusto von Dentz
<luiz.dentz@gmail.com> wrote:
> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
>
> This has to be done since Android do not interpret empty list as get all
> attributes as it should.
> ---
> v2: Move empty list handling to daemon side and fix starting with attribute
> 0x00 which is illegal.
> v3: Fix not handling response code properly in set_volume_rsp
> v4: Add fix to pass correct type to volume changed notification
>
> android/avrcp.c | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
> diff --git a/android/avrcp.c b/android/avrcp.c
> index e26ddf2..70266f7 100644
> --- a/android/avrcp.c
> +++ b/android/avrcp.c
> @@ -655,11 +655,23 @@ static ssize_t handle_get_element_attrs_cmd(struct avrcp *session,
> return -EINVAL;
>
> params += 9;
> +
> + /* Set everything in case of empty list */
> + if (ev->number == 0) {
> + for (i = 0; i < HAL_AVRCP_MEDIA_ATTR_DURATION; i++) {
> + /* Skip 0x00 as the attributes start with 0x01 */
> + ev->attrs[i] = i + 1;
> + }
> + ev->number = i;
> + goto done;
> + }
> +
> for (i = 0; i < ev->number; i++) {
> ev->attrs[i] = bt_get_be32(params);
> params += 4;
> }
>
> +done:
> ipc_send_notif(hal_ipc, HAL_SERVICE_ID_AVRCP,
> HAL_EV_AVRCP_GET_ELEMENT_ATTRS,
> sizeof(*ev) + ev->number, ev);
> --
> 1.8.5.3
Pushed.
--
Luiz Augusto von Dentz
^ permalink raw reply
* [PATCH v4 3/3] android/avrcp: Fix setting wrong type for volume changed event
From: Luiz Augusto von Dentz @ 2014-03-10 12:05 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1394453116-9354-1-git-send-email-luiz.dentz@gmail.com>
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Notification for volume changed should carry the original ctype and
not translate to HAL_AVRCP_EVENT_TYPE_INTERIM or
HAL_AVRCP_EVENT_TYPE_CHANGED which are only valid for register
notification command.
---
android/avrcp.c | 12 +-----------
1 file changed, 1 insertion(+), 11 deletions(-)
diff --git a/android/avrcp.c b/android/avrcp.c
index eab519a..f0a6d59 100644
--- a/android/avrcp.c
+++ b/android/avrcp.c
@@ -788,17 +788,7 @@ static gboolean register_notification_rsp(struct avctp *conn,
if (params == NULL || params[0] != AVRCP_EVENT_VOLUME_CHANGED)
return FALSE;
- switch (code) {
- case AVC_CTYPE_INTERIM:
- ev.type = HAL_AVRCP_EVENT_TYPE_INTERIM;
- break;
- case AVC_CTYPE_CHANGED:
- ev.type = HAL_AVRCP_EVENT_TYPE_CHANGED;
- break;
- default:
- return FALSE;
- }
-
+ ev.type = code;
ev.volume = params[1] & 0x7F;
ipc_send_notif(hal_ipc, HAL_SERVICE_ID_AVRCP,
--
1.8.5.3
^ permalink raw reply related
* [PATCH v4 2/3] android/avrcp: Fix not handling SetAbsoluteVolume response
From: Luiz Augusto von Dentz @ 2014-03-10 12:05 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1394453116-9354-1-git-send-email-luiz.dentz@gmail.com>
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This follow what is stated in AVRCP specification 1.5 page 83:
" When the volume is changed on the TG by this command the Volume Change
notification shall not be completed."
Therefore the only option is to treat the response and self generate
changed notification.
---
android/avrcp.c | 33 ++++++++++++++++++++++++++++++++-
1 file changed, 32 insertions(+), 1 deletion(-)
diff --git a/android/avrcp.c b/android/avrcp.c
index 70266f7..eab519a 100644
--- a/android/avrcp.c
+++ b/android/avrcp.c
@@ -330,6 +330,36 @@ done:
HAL_OP_AVRCP_REGISTER_NOTIFICATION, status);
}
+static gboolean set_volume_rsp(struct avctp *conn,
+ uint8_t code, uint8_t subunit,
+ uint8_t *operands, size_t operand_count,
+ void *user_data)
+{
+ struct hal_ev_avrcp_volume_changed ev;
+ uint8_t *params;
+
+ if (code != AVC_CTYPE_ACCEPTED) {
+ ev.volume = 0;
+ ev.type = code;
+ goto done;
+ }
+
+ if (operands == NULL || operand_count < 7)
+ return FALSE;
+
+ params = &operands[7];
+
+ ev.volume = params[0] & 0x7F;
+ ev.type = code;
+
+done:
+ ipc_send_notif(hal_ipc, HAL_SERVICE_ID_AVRCP,
+ HAL_EV_AVRCP_VOLUME_CHANGED,
+ sizeof(ev), &ev);
+
+ return FALSE;
+}
+
static void handle_set_volume(const void *buf, uint16_t len)
{
struct hal_cmd_avrcp_set_volume *cmd = (void *) buf;
@@ -350,7 +380,8 @@ static void handle_set_volume(const void *buf, uint16_t len)
*/
dev = devices->data;
- ret = avrcp_set_volume(dev->session, cmd->value & 0x7f, NULL, NULL);
+ ret = avrcp_set_volume(dev->session, cmd->value & 0x7f, set_volume_rsp,
+ dev);
if (ret < 0) {
status = HAL_STATUS_FAILED;
goto done;
--
1.8.5.3
^ permalink raw reply related
* [PATCH v4 1/3] android/avrcp: Fill attributes in case of empty for GetElementAttributes
From: Luiz Augusto von Dentz @ 2014-03-10 12:05 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This has to be done since Android do not interpret empty list as get all
attributes as it should.
---
v2: Move empty list handling to daemon side and fix starting with attribute
0x00 which is illegal.
v3: Fix not handling response code properly in set_volume_rsp
v4: Add fix to pass correct type to volume changed notification
android/avrcp.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/android/avrcp.c b/android/avrcp.c
index e26ddf2..70266f7 100644
--- a/android/avrcp.c
+++ b/android/avrcp.c
@@ -655,11 +655,23 @@ static ssize_t handle_get_element_attrs_cmd(struct avrcp *session,
return -EINVAL;
params += 9;
+
+ /* Set everything in case of empty list */
+ if (ev->number == 0) {
+ for (i = 0; i < HAL_AVRCP_MEDIA_ATTR_DURATION; i++) {
+ /* Skip 0x00 as the attributes start with 0x01 */
+ ev->attrs[i] = i + 1;
+ }
+ ev->number = i;
+ goto done;
+ }
+
for (i = 0; i < ev->number; i++) {
ev->attrs[i] = bt_get_be32(params);
params += 4;
}
+done:
ipc_send_notif(hal_ipc, HAL_SERVICE_ID_AVRCP,
HAL_EV_AVRCP_GET_ELEMENT_ATTRS,
sizeof(*ev) + ev->number, ev);
--
1.8.5.3
^ permalink raw reply related
* Re: [PATCH 00/20] More Android Handsfree work
From: Szymon Janc @ 2014-03-10 11:50 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1394238004-15691-1-git-send-email-szymon.janc@tieto.com>
On Saturday 08 of March 2014 01:19:44 Szymon Janc wrote:
> Hi,
>
> This patchset adds support for basic handsfree functionality.
>
> What is done:
> - indicators (without callheld)
> - placing, accepting, cancelling calls etc.
> - vendor (unknown) AT command handling
> - extended error codes
> - DTMF codes
> - query current calls
> - voice recognition on/off
> - disabling echo cancellation
> - subscriber and operator identification
>
> Missing features:
> - proper three way calling support (AT+CHLD is supported but callheld
> and CCWA are missing).
> - WBS and codec negotiation
> - audio
>
>
Updated version of this patchset (fixing comments from Marcel) is now upstream.
--
Best regards,
Szymon Janc
^ permalink raw reply
* Re: [PATCH 1/2] android/hal-ipc-api: Fix not describing call numbers as strings
From: Szymon Janc @ 2014-03-10 11:49 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1394296531-22469-1-git-send-email-szymon.janc@tieto.com>
On Saturday 08 of March 2014 17:35:30 Szymon Janc wrote:
> ---
> android/hal-ipc-api.txt | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/android/hal-ipc-api.txt b/android/hal-ipc-api.txt
> index 1ecf75f..e4a4e9c 100644
> --- a/android/hal-ipc-api.txt
> +++ b/android/hal-ipc-api.txt
> @@ -898,7 +898,7 @@ Commands and responses:
> Call mode (1 octet)
> Call multiparty type (1 octet)
> Call number type (1 octet)
> - Call number (variable)
> + Call number (string)
> Response parameters: <none>
>
> Valid call directions: 0x00 = Outgoing
> @@ -930,7 +930,7 @@ Commands and responses:
> Number of held calls (1 octet)
> Call setup state (1 octet)
> Call number type (1 octet)
> - Call number (variable)
> + Call number (string)
> Response parameters: <none>
>
> Valid call setup states: 0x00 = Active
>
Patch 1 is now pushed.
--
Best regards,
Szymon Janc
^ permalink raw reply
* Re: [PATCH 2/5] android/handsfree: Add support for handling incoming SCO connections
From: Szymon Janc @ 2014-03-10 11:48 UTC (permalink / raw)
To: Marcin Kraglak; +Cc: linux-bluetooth
In-Reply-To: <1394223800-11961-2-git-send-email-marcin.kraglak@tieto.com>
Hi Marcin,
On Friday 07 of March 2014 21:23:17 Marcin Kraglak wrote:
> This adds support for accepting SCO connections from remote devices.
> ---
> android/handsfree.c | 148 ++++++++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 148 insertions(+)
>
> diff --git a/android/handsfree.c b/android/handsfree.c
> index fa27f10..40f3652 100644
> --- a/android/handsfree.c
> +++ b/android/handsfree.c
> @@ -83,11 +83,14 @@ static const struct indicator inds_defaults[] = {
> static struct {
> bdaddr_t bdaddr;
> uint8_t state;
> + uint8_t audio_state;
> uint32_t features;
> bool indicators_enabled;
> struct indicator inds[IND_COUNT];
> bool hsp;
> struct hfp_gw *gw;
> + GIOChannel *sco;
> + guint sco_watch;
> } device;
>
> static bdaddr_t adapter_addr;
> @@ -99,6 +102,8 @@ static GIOChannel *hfp_server = NULL;
> static uint32_t hsp_record_id = 0;
> static GIOChannel *hsp_server = NULL;
>
> +static GIOChannel *sco_server = NULL;
> +
> static void device_set_state(uint8_t state)
> {
> struct hal_ev_handsfree_conn_state ev;
> @@ -119,6 +124,26 @@ static void device_set_state(uint8_t state)
> HAL_EV_HANDSFREE_CONN_STATE, sizeof(ev), &ev);
> }
>
> +static void device_set_audio_state(uint8_t state)
> +{
> + struct hal_ev_handsfree_audio_state ev;
> + char address[18];
> +
> + if (device.audio_state == state)
> + return;
> +
> + device.audio_state = state;
> +
> + ba2str(&device.bdaddr, address);
> + DBG("device %s audio state %u", address, state);
> +
> + bdaddr2android(&device.bdaddr, ev.bdaddr);
> + ev.state = state;
> +
> + ipc_send_notif(hal_ipc, HAL_SERVICE_ID_HANDSFREE,
> + HAL_EV_HANDSFREE_AUDIO_STATE, sizeof(ev), &ev);
> +}
> +
> static void device_init(const bdaddr_t *bdaddr)
> {
> bacpy(&device.bdaddr, bdaddr);
> @@ -137,6 +162,19 @@ static void device_cleanup(void)
>
> device_set_state(HAL_EV_HANDSFREE_CONN_STATE_DISCONNECTED);
>
> + if (device.sco_watch) {
> + g_source_remove(device.sco_watch);
> + device.sco_watch = 0;
> + }
> +
> + if (device.sco) {
> + g_io_channel_shutdown(device.sco, TRUE, NULL);
> + g_io_channel_unref(device.sco);
> + device.sco = NULL;
> + }
> +
> + device_set_audio_state(HAL_EV_HANDSFREE_AUDIO_STATE_DISCONNECTED);
> +
> memset(&device, 0, sizeof(device));
> }
>
> @@ -739,6 +777,42 @@ failed:
> HAL_OP_HANDSFREE_DISCONNECT, status);
> }
>
> +static gboolean sco_watch_cb(GIOChannel *chan, GIOCondition cond,
> + gpointer user_data)
> +{
> + g_source_remove(device.sco_watch);
> + device.sco_watch = 0;
> +
> + g_io_channel_shutdown(device.sco, TRUE, NULL);
> + g_io_channel_unref(device.sco);
> + device.sco = NULL;
> +
> + device_set_audio_state(HAL_EV_HANDSFREE_AUDIO_STATE_DISCONNECTED);
> +
> + return FALSE;
> +}
> +
> +static void connect_sco_cb(GIOChannel *chan, GError *err, gpointer user_data)
> +{
> + if (err) {
> + uint8_t status;
> +
> + error("SCO: connect failed (%s)", err->message);
> + status = HAL_EV_HANDSFREE_AUDIO_STATE_DISCONNECTED;
> + device_set_audio_state(status);
> +
> + return;
> + }
> +
> + g_io_channel_set_close_on_unref(chan, TRUE);
> +
> + device.sco = g_io_channel_ref(chan);
> + device.sco_watch = g_io_add_watch(chan, G_IO_ERR | G_IO_HUP | G_IO_NVAL,
> + sco_watch_cb, NULL);
> +
> + device_set_audio_state(HAL_EV_HANDSFREE_AUDIO_STATE_CONNECTED);
> +}
> +
> static void handle_connect_audio(const void *buf, uint16_t len)
> {
> DBG("");
> @@ -1044,6 +1118,46 @@ static sdp_record_t *headset_ag_record(void)
> return record;
> }
>
> +static void confirm_sco_cb(GIOChannel *chan, gpointer user_data)
> +{
> + char address[18];
> + bdaddr_t bdaddr;
> + GError *err = NULL;
> +
> + if (device.sco)
> + goto drop;
> +
> + bt_io_get(chan, &err,
> + BT_IO_OPT_DEST, address,
> + BT_IO_OPT_DEST_BDADDR, &bdaddr,
> + BT_IO_OPT_INVALID);
> + if (err) {
> + error("SCO: confirm failed (%s)", err->message);
> + g_error_free(err);
> + goto drop;
> + }
> +
> + DBG("incoming SCO connection from %s", address);
> +
> + if (device.state != HAL_EV_HANDSFREE_CONN_STATE_SLC_CONNECTED ||
> + bacmp(&device.bdaddr, &bdaddr)) {
> + error("SCO: connection from %s rejected", address);
> + goto drop;
> + }
> +
> + if (!bt_io_accept(chan, connect_sco_cb, NULL, NULL, NULL)) {
> + error("SCO: failed to accept connection");
> + goto drop;
> + }
> +
> + device_set_audio_state(HAL_EV_HANDSFREE_AUDIO_STATE_CONNECTING);
> +
> + return;
> +
> +drop:
> + g_io_channel_shutdown(chan, TRUE, NULL);
> +}
> +
> static bool enable_hsp_ag(void)
> {
> sdp_record_t *rec;
> @@ -1233,6 +1347,33 @@ static void cleanup_hfp_ag(void)
> }
> }
>
> +static bool enable_sco_server(void)
> +{
> + GError *err = NULL;
> +
> + sco_server = bt_io_listen(NULL, confirm_sco_cb, NULL, NULL, &err,
> + BT_IO_OPT_SOURCE_BDADDR, &adapter_addr,
> + BT_IO_OPT_INVALID);
> + if (!sco_server) {
> + error("Failed to listen on SCO: %s", err->message);
> + g_error_free(err);
> + cleanup_hsp_ag();
> + cleanup_hfp_ag();
> + return false;
> + }
> +
> + return true;
> +}
> +
> +static void disable_sco_server(void)
> +{
> + if (sco_server) {
> + g_io_channel_shutdown(sco_server, TRUE, NULL);
> + g_io_channel_unref(sco_server);
> + sco_server = NULL;
> + }
> +}
> +
> bool bt_handsfree_register(struct ipc *ipc, const bdaddr_t *addr, uint8_t mode)
> {
> DBG("mode 0x%x", mode);
> @@ -1247,6 +1388,12 @@ bool bt_handsfree_register(struct ipc *ipc, const bdaddr_t *addr, uint8_t mode)
> return false;
> }
>
> + if (!enable_sco_server()) {
> + cleanup_hsp_ag();
> + cleanup_hfp_ag();
> + return false;
> + }
> +
> hal_ipc = ipc;
> ipc_register(hal_ipc, HAL_SERVICE_ID_HANDSFREE, cmd_handlers,
> G_N_ELEMENTS(cmd_handlers));
> @@ -1263,4 +1410,5 @@ void bt_handsfree_unregister(void)
>
> cleanup_hfp_ag();
> cleanup_hsp_ag();
> + disable_sco_server();
> }
>
Patches 2, 3 and 4 are now also upstream (with minor fixed we discussed
offline), thanks.
--
Best regards,
Szymon Janc
^ permalink raw reply
* [PATCH v3 2/2] android/gatt: Handle Unregister gatt client command
From: Grzegorz Kolodziejczyk @ 2014-03-10 11:19 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1394450344-32472-1-git-send-email-grzegorz.kolodziejczyk@tieto.com>
This adds unregister gatt client app command handling.
---
android/gatt.c | 29 ++++++++++++++++++++++++++++-
1 file changed, 28 insertions(+), 1 deletion(-)
diff --git a/android/gatt.c b/android/gatt.c
index 084ba7f..9ea82fb 100644
--- a/android/gatt.c
+++ b/android/gatt.c
@@ -54,6 +54,14 @@ static int find_client_uuid(gconstpointer data, gconstpointer user_data)
return memcmp(exp_uuid, client->uuid, sizeof(client->uuid));
}
+static int find_client_if(gconstpointer data, gconstpointer user_data)
+{
+ int32_t exp_cif = GPOINTER_TO_INT(user_data);
+ const struct gatt_clients *client = data;
+
+ return client->client_if != exp_cif;
+}
+
static void handle_client_register(const void *buf, uint16_t len)
{
const struct hal_cmd_gatt_client_register *cmd = buf;
@@ -100,10 +108,29 @@ failed:
static void handle_client_unregister(const void *buf, uint16_t len)
{
+ const struct hal_cmd_gatt_client_unregister *cmd = buf;
+ GSList *found_client_if;
+ uint8_t status;
+
DBG("");
+ found_client_if = g_slist_find_custom(gatt_clients_list,
+ GINT_TO_POINTER(cmd->client_if),
+ find_client_if);
+ if (!found_client_if) {
+ error("gatt: client_if=%d not found", cmd->client_if);
+ status = HAL_STATUS_FAILED;
+ goto failed;
+ }
+
+ gatt_clients_list = g_slist_remove(gatt_clients_list,
+ found_client_if->data);
+
+ status = HAL_STATUS_SUCCESS;
+
+failed:
ipc_send_rsp(hal_ipc, HAL_SERVICE_ID_GATT,
- HAL_OP_GATT_CLIENT_UNREGISTER, HAL_STATUS_FAILED);
+ HAL_OP_GATT_CLIENT_UNREGISTER, status);
}
static void handle_client_scan(const void *buf, uint16_t len)
--
1.8.5.2
^ permalink raw reply related
* [PATCH v3 1/2] android/gatt: Handle Register gatt client command
From: Grzegorz Kolodziejczyk @ 2014-03-10 11:19 UTC (permalink / raw)
To: linux-bluetooth
This adds register gatt client app command handling.
---
android/gatt.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 53 insertions(+), 2 deletions(-)
diff --git a/android/gatt.c b/android/gatt.c
index ce85af4..084ba7f 100644
--- a/android/gatt.c
+++ b/android/gatt.c
@@ -31,20 +31,71 @@
#include <glib.h>
#include "ipc.h"
+#include "ipc-common.h"
#include "lib/bluetooth.h"
#include "gatt.h"
#include "src/log.h"
#include "hal-msg.h"
+struct gatt_clients {
+ int32_t client_if;
+ uint8_t uuid[16];
+};
+
static struct ipc *hal_ipc = NULL;
static bdaddr_t adapter_addr;
+static GSList *gatt_clients_list = NULL;
+
+static int find_client_uuid(gconstpointer data, gconstpointer user_data)
+{
+ const uint8_t *exp_uuid = user_data;
+ const struct gatt_clients *client = data;
+
+ return memcmp(exp_uuid, client->uuid, sizeof(client->uuid));
+}
static void handle_client_register(const void *buf, uint16_t len)
{
+ const struct hal_cmd_gatt_client_register *cmd = buf;
+ struct hal_ev_gatt_client_register_client ev;
+ struct gatt_clients *client;
+ static int32_t client_if_counter = 1;
+ uint8_t status;
+
DBG("");
- ipc_send_rsp(hal_ipc, HAL_SERVICE_ID_GATT, HAL_OP_GATT_CLIENT_REGISTER,
- HAL_STATUS_FAILED);
+ if (!cmd->uuid) {
+ error("gatt: no uuid received");
+ status = HAL_STATUS_FAILED;
+ goto failed;
+ }
+
+ if (g_slist_find_custom(gatt_clients_list, &cmd->uuid,
+ find_client_uuid)) {
+ error("gatt: client uuid is already on list");
+ status = HAL_STATUS_FAILED;
+ goto failed;
+ }
+
+ client = g_new0(struct gatt_clients, 1);
+ memcpy(client->uuid, cmd->uuid, sizeof(client->uuid));
+
+ client->client_if = client_if_counter++;
+
+ gatt_clients_list = g_slist_prepend(gatt_clients_list, client);
+
+ status = HAL_STATUS_SUCCESS;
+
+ ev.status = status;
+ ev.client_if = client->client_if;
+ memcpy(ev.app_uuid, client->uuid, sizeof(client->uuid));
+
+ ipc_send_notif(hal_ipc, HAL_SERVICE_ID_GATT,
+ HAL_EV_GATT_CLIENT_REGISTER_CLIENT, sizeof(ev), &ev);
+
+failed:
+ ipc_send_rsp(hal_ipc, HAL_SERVICE_ID_GATT,
+ HAL_OP_GATT_CLIENT_REGISTER, status);
}
static void handle_client_unregister(const void *buf, uint16_t len)
--
1.8.5.2
^ permalink raw reply related
* [PATCH v2 2/2] android/gatt: Handle Unregister gatt client command
From: Grzegorz Kolodziejczyk @ 2014-03-10 11:04 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1394449453-31266-1-git-send-email-grzegorz.kolodziejczyk@tieto.com>
This adds unregister gatt client app command handling.
---
android/gatt.c | 30 +++++++++++++++++++++++++++++-
1 file changed, 29 insertions(+), 1 deletion(-)
diff --git a/android/gatt.c b/android/gatt.c
index 5206f5e..bc90814 100644
--- a/android/gatt.c
+++ b/android/gatt.c
@@ -55,6 +55,15 @@ static int find_client_uuid(gconstpointer data, gconstpointer user_data)
return memcmp(exp_uuid, cur_uuid, sizeof(client->uuid));
}
+static int find_client_if(gconstpointer data, gconstpointer user_data)
+{
+ const int32_t exp_cif = GPOINTER_TO_INT(user_data);
+ const struct gatt_clients *client = data;
+ const int32_t cur_cif = client->client_if;
+
+ return cur_cif != exp_cif;
+}
+
static void handle_client_register(const void *buf, uint16_t len)
{
const struct hal_cmd_gatt_client_register *cmd = buf;
@@ -101,10 +110,29 @@ failed:
static void handle_client_unregister(const void *buf, uint16_t len)
{
+ const struct hal_cmd_gatt_client_unregister *cmd = buf;
+ GSList *found_client_if;
+ uint8_t status;
+
DBG("");
+ found_client_if = g_slist_find_custom(gatt_clients_list,
+ GINT_TO_POINTER(cmd->client_if),
+ find_client_if);
+ if (!found_client_if) {
+ error("gatt: client_if: %d not found", cmd->client_if);
+ status = HAL_STATUS_FAILED;
+ goto failed;
+ }
+
+ gatt_clients_list = g_slist_remove(gatt_clients_list,
+ found_client_if->data);
+
+ status = HAL_STATUS_SUCCESS;
+
+failed:
ipc_send_rsp(hal_ipc, HAL_SERVICE_ID_GATT,
- HAL_OP_GATT_CLIENT_UNREGISTER, HAL_STATUS_FAILED);
+ HAL_OP_GATT_CLIENT_UNREGISTER, status);
}
static void handle_client_scan(const void *buf, uint16_t len)
--
1.8.5.2
^ permalink raw reply related
* [PATCH v2 1/2] android/gatt: Handle Register gatt client command
From: Grzegorz Kolodziejczyk @ 2014-03-10 11:04 UTC (permalink / raw)
To: linux-bluetooth
This adds register gatt client app command handling.
---
android/gatt.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 54 insertions(+), 2 deletions(-)
diff --git a/android/gatt.c b/android/gatt.c
index ce85af4..5206f5e 100644
--- a/android/gatt.c
+++ b/android/gatt.c
@@ -31,20 +31,72 @@
#include <glib.h>
#include "ipc.h"
+#include "ipc-common.h"
#include "lib/bluetooth.h"
#include "gatt.h"
#include "src/log.h"
#include "hal-msg.h"
+struct gatt_clients {
+ int32_t client_if;
+ uint8_t uuid[16];
+};
+
static struct ipc *hal_ipc = NULL;
static bdaddr_t adapter_addr;
+static GSList *gatt_clients_list = NULL;
+
+static int find_client_uuid(gconstpointer data, gconstpointer user_data)
+{
+ const uint8_t *exp_uuid = user_data;
+ const struct gatt_clients *client = data;
+ const uint8_t *cur_uuid = client->uuid;
+
+ return memcmp(exp_uuid, cur_uuid, sizeof(client->uuid));
+}
static void handle_client_register(const void *buf, uint16_t len)
{
+ const struct hal_cmd_gatt_client_register *cmd = buf;
+ struct hal_ev_gatt_client_register_client ev;
+ struct gatt_clients *client;
+ static int32_t client_if_counter;
+ uint8_t status;
+
DBG("");
- ipc_send_rsp(hal_ipc, HAL_SERVICE_ID_GATT, HAL_OP_GATT_CLIENT_REGISTER,
- HAL_STATUS_FAILED);
+ if (!cmd->uuid) {
+ error("gatt: no uuid received");
+ status = HAL_STATUS_FAILED;
+ goto failed;
+ }
+
+ if (g_slist_find_custom(gatt_clients_list, &cmd->uuid,
+ find_client_uuid)) {
+ error("gatt: client uuid is already on list");
+ status = HAL_STATUS_FAILED;
+ goto failed;
+ }
+
+ client = g_new0(struct gatt_clients, 1);
+ memcpy(client->uuid, cmd->uuid, sizeof(client->uuid));
+
+ client->client_if = ++client_if_counter;
+
+ gatt_clients_list = g_slist_prepend(gatt_clients_list, client);
+
+ status = HAL_STATUS_SUCCESS;
+
+ ev.status = status;
+ ev.client_if = client->client_if;
+ memcpy(ev.app_uuid, client->uuid, sizeof(client->uuid));
+
+ ipc_send_notif(hal_ipc, HAL_SERVICE_ID_GATT,
+ HAL_EV_GATT_CLIENT_REGISTER_CLIENT, sizeof(ev), &ev);
+
+failed:
+ ipc_send_rsp(hal_ipc, HAL_SERVICE_ID_GATT,
+ HAL_OP_GATT_CLIENT_REGISTER, status);
}
static void handle_client_unregister(const void *buf, uint16_t len)
--
1.8.5.2
^ permalink raw reply related
* [PATCH] bluetooth: Fix aborting eSCO connection in case of error 0x20
From: Andrew Earl @ 2014-03-10 10:31 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Andrew Earl
In-Reply-To: <1394447464-29164-1-git-send-email-andrewx.earl@intel.com>
Add additional error case to attempt alternative configuration for SCO. Error
occurs with Intel BT controller where fallback is not attempted as the error
0x20 Unsupported LMP Parameter value is not included in the list of errors
where a retry should be attempted.
The problem also affects PTS test case TC_HF_ACS_BV_05_I.
See the HCI log below for details:
< HCI Command: Setup Synchronous Connection (0x01|0x0028) plen 17
handle 256 voice setting 0x0060 ptype 0x0380
> HCI Event: Command Status (0x0f) plen 4
Setup Synchronous Connection (0x01|0x0028) status 0x00 ncmd 1
> HCI Event: Max Slots Change (0x1b) plen 3
handle 256 slots 1
> HCI Event: Synchronous Connect Complete (0x2c) plen 17
status 0x20 handle 0 bdaddr 00:80:98:09:0B:19 type eSCO
Error: Unsupported LMP Parameter Value
< HCI Command: Setup Synchronous Connection (0x01|0x0028) plen 17
handle 256 voice setting 0x0060 ptype 0x0380
> HCI Event: Command Status (0x0f) plen 4
Setup Synchronous Connection (0x01|0x0028) status 0x00 ncmd 1
> HCI Event: Max Slots Change (0x1b) plen 3
handle 256 slots 5
> HCI Event: Synchronous Connect Complete (0x2c) plen 17
status 0x20 handle 0 bdaddr 00:80:98:09:0B:19 type eSCO
Error: Unsupported LMP Parameter Value
< HCI Command: Setup Synchronous Connection (0x01|0x0028) plen 17
handle 256 voice setting 0x0060 ptype 0x03c8
> HCI Event: Command Status (0x0f) plen 4
Setup Synchronous Connection (0x01|0x0028) status 0x00 ncmd 1
> HCI Event: Max Slots Change (0x1b) plen 3
handle 256 slots 1
> HCI Event: Synchronous Connect Complete (0x2c) plen 17
status 0x00 handle 257 bdaddr 00:80:98:09:0B:19 type eSCO
Air mode: CVSD
See btmon log for further details:
> HCI Event (0x0f) plen 4 [hci0] 44.888063
Setup Synchronous Connection (0x01|0x0028) ncmd 1
Status: Success (0x00)
> HCI Event (0x1b) plen 3 [hci0] 44.893064
Handle: 256
Max slots: 1
> HCI Event (0x2c) plen 17 [hci0] 44.942080
Status: Unsupported LMP Parameter Value (0x20)
Handle: 0
Address: 00:1B:DC:06:04:B0 (OUI 00-1B-DC)
Link type: eSCO (0x02)
Transmission interval: 0x00
Retransmission window: 0x01
RX packet length: 0
TX packet length: 0
Air mode: CVSD (0x02)
> HCI Event (0x1b) plen 3 [hci0] 44.948054
Handle: 256
Max slots: 5
Signed-off-by: Andrew Earl <andrewx.earl@intel.com>
---
net/bluetooth/hci_event.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 5f81245..59e1b45 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -2905,6 +2905,7 @@ static void hci_sync_conn_complete_evt(struct hci_dev *hdev,
case 0x1c: /* SCO interval rejected */
case 0x1a: /* Unsupported Remote Feature */
case 0x1f: /* Unspecified error */
+ case 0x20: /* Unsupported LMP Parameter value */
if (conn->out) {
conn->pkt_type = (hdev->esco_type & SCO_ESCO_MASK) |
(hdev->esco_type & EDR_ESCO_MASK);
--
1.7.11.7
^ permalink raw reply related
* Re: [PATCH] bluetooth: Fix aborting eSCO connection in case of error 0x20
From: Andrew Earl @ 2014-03-10 10:31 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Andrew Earl
A new patch fix has been created with updated commit message containing the btmon trace and sign off as requested.
Thanks,
Andrew
Andrew Earl (1):
bluetooth: Fix aborting eSCO connection in case of error 0x20
net/bluetooth/hci_event.c | 1 +
1 file changed, 1 insertion(+)
--
1.7.11.7
^ permalink raw reply
* [PATCH v3 2/2] android/avrcp: Fix not handling SetAbsoluteVolume response
From: Luiz Augusto von Dentz @ 2014-03-10 9:45 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1394444747-7508-1-git-send-email-luiz.dentz@gmail.com>
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This follow what is stated in AVRCP specification 1.5 page 83:
" When the volume is changed on the TG by this command the Volume Change
notification shall not be completed."
Therefore the only option is to treat the response and self generate
changed notification.
---
android/avrcp.c | 28 +++++++++++++++++++++++++++-
1 file changed, 27 insertions(+), 1 deletion(-)
diff --git a/android/avrcp.c b/android/avrcp.c
index 70266f7..3bed166 100644
--- a/android/avrcp.c
+++ b/android/avrcp.c
@@ -330,6 +330,31 @@ done:
HAL_OP_AVRCP_REGISTER_NOTIFICATION, status);
}
+static gboolean set_volume_rsp(struct avctp *conn,
+ uint8_t code, uint8_t subunit,
+ uint8_t *operands, size_t operand_count,
+ void *user_data)
+{
+ struct hal_ev_avrcp_volume_changed ev;
+ uint8_t *params;
+
+ if (code != AVC_CTYPE_ACCEPTED)
+ return FALSE;
+
+ if (operands == NULL || operand_count < 7)
+ return FALSE;
+
+ params = &operands[7];
+
+ ev.volume = params[0] & 0x7F;
+
+ ipc_send_notif(hal_ipc, HAL_SERVICE_ID_AVRCP,
+ HAL_EV_AVRCP_VOLUME_CHANGED,
+ sizeof(ev), &ev);
+
+ return FALSE;
+}
+
static void handle_set_volume(const void *buf, uint16_t len)
{
struct hal_cmd_avrcp_set_volume *cmd = (void *) buf;
@@ -350,7 +375,8 @@ static void handle_set_volume(const void *buf, uint16_t len)
*/
dev = devices->data;
- ret = avrcp_set_volume(dev->session, cmd->value & 0x7f, NULL, NULL);
+ ret = avrcp_set_volume(dev->session, cmd->value & 0x7f, set_volume_rsp,
+ dev);
if (ret < 0) {
status = HAL_STATUS_FAILED;
goto done;
--
1.8.5.3
^ permalink raw reply related
* [PATCH v3 1/2] android/avrcp: Fill attributes in case of empty for GetElementAttributes
From: Luiz Augusto von Dentz @ 2014-03-10 9:45 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This has to be done since Android do not interpret empty list as get all
attributes as it should.
---
v2: Move empty list handling to daemon side and fix starting with attribute
0x00 which is illegal.
v3: Fix not handling response code properly in set_volume_rsp
android/avrcp.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/android/avrcp.c b/android/avrcp.c
index e26ddf2..70266f7 100644
--- a/android/avrcp.c
+++ b/android/avrcp.c
@@ -655,11 +655,23 @@ static ssize_t handle_get_element_attrs_cmd(struct avrcp *session,
return -EINVAL;
params += 9;
+
+ /* Set everything in case of empty list */
+ if (ev->number == 0) {
+ for (i = 0; i < HAL_AVRCP_MEDIA_ATTR_DURATION; i++) {
+ /* Skip 0x00 as the attributes start with 0x01 */
+ ev->attrs[i] = i + 1;
+ }
+ ev->number = i;
+ goto done;
+ }
+
for (i = 0; i < ev->number; i++) {
ev->attrs[i] = bt_get_be32(params);
params += 4;
}
+done:
ipc_send_notif(hal_ipc, HAL_SERVICE_ID_AVRCP,
HAL_EV_AVRCP_GET_ELEMENT_ATTRS,
sizeof(*ev) + ev->number, ev);
--
1.8.5.3
^ permalink raw reply related
* [PATCH v2 2/2] android/avrcp: Fix not handling SetAbsoluteVolume response
From: Luiz Augusto von Dentz @ 2014-03-10 9:33 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1394443988-6004-1-git-send-email-luiz.dentz@gmail.com>
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This follow what is stated in AVRCP specification 1.5 page 83:
" When the volume is changed on the TG by this command the Volume Change
notification shall not be completed."
Therefore the only option is to treat the response and self generate
changed notification.
---
android/avrcp.c | 28 +++++++++++++++++++++++++++-
1 file changed, 27 insertions(+), 1 deletion(-)
diff --git a/android/avrcp.c b/android/avrcp.c
index b9085e6..5891a08 100644
--- a/android/avrcp.c
+++ b/android/avrcp.c
@@ -330,6 +330,31 @@ done:
HAL_OP_AVRCP_REGISTER_NOTIFICATION, status);
}
+static gboolean set_volume_rsp(struct avctp *conn,
+ uint8_t code, uint8_t subunit,
+ uint8_t *operands, size_t operand_count,
+ void *user_data)
+{
+ struct hal_ev_avrcp_volume_changed ev;
+ uint8_t *params;
+
+ if (code != AVC_CTYPE_INTERIM && code != AVC_CTYPE_CHANGED)
+ return FALSE;
+
+ if (operands == NULL || operand_count < 7)
+ return FALSE;
+
+ params = &operands[7];
+
+ ev.volume = params[0] & 0x7F;
+
+ ipc_send_notif(hal_ipc, HAL_SERVICE_ID_AVRCP,
+ HAL_EV_AVRCP_VOLUME_CHANGED,
+ sizeof(ev), &ev);
+
+ return FALSE;
+}
+
static void handle_set_volume(const void *buf, uint16_t len)
{
struct hal_cmd_avrcp_set_volume *cmd = (void *) buf;
@@ -350,7 +375,8 @@ static void handle_set_volume(const void *buf, uint16_t len)
*/
dev = devices->data;
- ret = avrcp_set_volume(dev->session, cmd->value & 0x7f, NULL, NULL);
+ ret = avrcp_set_volume(dev->session, cmd->value & 0x7f, set_volume_rsp,
+ dev);
if (ret < 0) {
status = HAL_STATUS_FAILED;
goto done;
--
1.8.5.3
^ permalink raw reply related
* [PATCH v2 1/2] android/avrcp: Fill attributes in case of empty for GetElementAttributes
From: Luiz Augusto von Dentz @ 2014-03-10 9:33 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This has to be done since Android do not interpret empty list as get all
attributes as it should.
---
v2: Move empty list handling to daemon side and fix starting with attribute
0x00 which is illegal.
android/avrcp.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/android/avrcp.c b/android/avrcp.c
index e26ddf2..b9085e6 100644
--- a/android/avrcp.c
+++ b/android/avrcp.c
@@ -655,11 +655,22 @@ static ssize_t handle_get_element_attrs_cmd(struct avrcp *session,
return -EINVAL;
params += 9;
+
+ /* Set everything in case of empty list */
+ if (ev->number == 0) {
+ for (i = 0; i < HAL_AVRCP_MEDIA_ATTR_DURATION; i++)
+ /* Skip 0x00 as the attributes start with 0x01 */
+ ev->attrs[i] = i + 1;
+ ev->number = i;
+ goto done;
+ }
+
for (i = 0; i < ev->number; i++) {
ev->attrs[i] = bt_get_be32(params);
params += 4;
}
+done:
ipc_send_notif(hal_ipc, HAL_SERVICE_ID_AVRCP,
HAL_EV_AVRCP_GET_ELEMENT_ATTRS,
sizeof(*ev) + ev->number, ev);
--
1.8.5.3
^ permalink raw reply related
* Re: [PATCH 1/3] android: Change property name for valgrind
From: Szymon Janc @ 2014-03-10 9:27 UTC (permalink / raw)
To: Lukasz Rymanowski; +Cc: linux-bluetooth
In-Reply-To: <1394098681-18983-1-git-send-email-lukasz.rymanowski@tieto.com>
Hi Łukasz,
On Thursday 06 of March 2014 10:37:59 Lukasz Rymanowski wrote:
> ---
> android/bluetoothd-wrapper.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/android/bluetoothd-wrapper.c b/android/bluetoothd-wrapper.c
> index 122e6b0..3a9f32e 100644
> --- a/android/bluetoothd-wrapper.c
> +++ b/android/bluetoothd-wrapper.c
> @@ -22,7 +22,7 @@
>
> #include <cutils/properties.h>
>
> -#define PROPERTY_NAME "persist.sys.bluetooth.valgrind"
> +#define PROPERTY_VALGRIND_NAME "persist.sys.bluetooth.valgrind"
>
> #define VALGRIND_BIN "/system/bin/valgrind"
>
> @@ -62,7 +62,7 @@ int main(int argc, char *argv[])
> {
> char value[PROPERTY_VALUE_MAX];
>
> - if (property_get(PROPERTY_NAME, value, "") > 0 &&
> + if (property_get(PROPERTY_VALGRIND_NAME, value, "") > 0 &&
> (!strcasecmp(value, "true") || atoi(value) > 0))
> run_valgrind();
>
>
All patches applied, thanks.
--
Best regards,
Szymon Janc
^ permalink raw reply
* [PATCHv2 10/10] doc: Update test coverage document
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>
---
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 244e0c6..7dbe9b5 100644
--- a/doc/test-coverage.txt
+++ b/doc/test-coverage.txt
@@ -19,7 +19,7 @@ test-queue 1 Queue handling functionality
test-hfp 9 HFP Audio Gateway functionality
test-avdtp 60 AVDTP qualification test cases
test-avctp 9 AVCTP qualification test cases
-test-avrcp 24 AVRCP qualification test cases
+test-avrcp 37 AVRCP qualification test cases
test-gobex 31 Generic OBEX functionality
test-gobex-packet 9 OBEX packet handling
test-gobex-header 28 OBEX header handling
--
1.8.3.2
^ permalink raw reply related
* [PATCHv2 09/10] unit/avrcp: Add /TP/NFY/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 that Target responds to Register notification - Track
Changed - No Selected Track.
---
unit/test-avrcp.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/unit/test-avrcp.c b/unit/test-avrcp.c
index c442001..6b5f615 100644
--- a/unit/test-avrcp.c
+++ b/unit/test-avrcp.c
@@ -962,5 +962,17 @@ int main(int argc, char *argv[])
AVRCP_EVENT_SETTINGS_CHANGED,
0x01, 0x01, 0x02));
+ /* Register notification - Track Changed - No Selected Track - TG */
+ define_test("/TP/NFY/BV-04-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));
+
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