All of lore.kernel.org
 help / color / mirror / Atom feed
From: Iulia Tanasescu <iulia.tanasescu@nxp.com>
To: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>
Subject: ISO socket bugs/lack of support
Date: Fri, 3 Mar 2023 14:52:07 +0000	[thread overview]
Message-ID: <AS8PR04MB8898256F1388824FC19F67BFECB39@AS8PR04MB8898.eurprd04.prod.outlook.com> (raw)

Hello,

Earlier this week I submitted a BlueZ patch ([1]) containing an initial implementation of the Broadcast Audio Scan Service.

In order to perform some of the BASS procedures, the BASS Server is required to send specific HCI commands and to handle HCI events accordingly - for example, the "Set Broadcast_Code" operation of the Broadcast Audio Scan Control Point characteristic requires the BASS Server to issue the LE BIG Create Sync command with the Broadcast_Code parameter set to the characteristic value written by the BASS Client.

My approach was to open an HCI socket and to send the command directly from the BASS handler function. After my proposed implementation was reviewed, I was told I should use an ISO socket instead and let the Bluetooth kernel perform the BIG synchronization procedure. I investigated this solution and the problem that I encountered was that the kernel sends HCI commands with fixed parameters - calling the "listen" API on an ISO socket will always attempt to send the LE BIG Create Sync command with the Broadcast_Code parameter set to 0. I couldn't find a way to provide my desired parameters to the HCI command.

I also discovered 2 kernel issues when calling "listen" on an ISO socket:

The first issue is that the "hci_pa_create_sync" function attempts to send the LE Periodic Advertising Create Sync command with the Sync_Timeout parameter set to 0 - according to the Bluetooth Core specification version 5.3, this parameter should be in the 0x000A - 0x4000 range. This is why the Controller will reject this command, as shown in the following btmon capture:


< HCI Command: LE Periodic Advertising Create Sync (0x08|0x0044) plen 14
        Options: 0x0000
        Use advertising SID, Advertiser Address Type and address
        Reporting initially enabled
        SID: 0x01
        Adv address type: Public (0x00)
        Adv address: C0:07:E8:8B:69:F2 (OUI C0-07-E8)
        Skip: 0x0000
        Sync timeout: 0 msec (0x0000)
        Sync CTE type: 0x0000

> HCI Event: Command Status (0x0f) plen 4
      LE Periodic Advertising Create Sync (0x08|0x0044) ncmd 1
        Status: Invalid HCI Command Parameters (0x12)

Updating the "hci_pa_create_sync" function and setting the "sync_timeout" field of the command parameters to a value in the required range solves the problem.

The same issue appears when the kernel attempts to send the LE BIG Create Sync command with the BIG_Sync_Timeout parameter set to 0:


< HCI Command: LE Broadcast Isochronous Group Create Sync (0x08|0x006b) plen 25
        BIG Handle: 0x00
        BIG Sync Handle: 0x0000
        Encryption: Encrypted (0x00)
        Broadcast Code: 00000000000000000000000000000000
        Maximum Number Subevents: 0x00
        Timeout: 0 ms (0x0000)
        Number of BIS: 1
        BIS ID: 0x01

> HCI Event: Command Status (0x0f) plen 4
      LE Broadcast Isochronous Group Create Sync (0x08|0x006b) ncmd 1
        Status: Parameter Out Of Manadatory Range (0x30)

Updating the "hci_le_big_create_sync" function and setting the "timeout" field of the command parameters to a valid value solves the issue.

Hopefully someone can confirm the kernel issues I described and the fixes can be committed. I would also like to ask for some guidance regarding the ISO socket usage when it comes to personalizing HCI command parameters - is there a way to set the parameters from BlueZ? Or should this support be implemented in the Bluetooth kernel?

Thank you in advance

Iulia

[1]	[BlueZ,0/2] Add initial BASS support - Patchwork (kernel.org)


             reply	other threads:[~2023-03-03 14:52 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-03 14:52 Iulia Tanasescu [this message]
2023-03-03 17:48 ` ISO socket bugs/lack of support Luiz Augusto von Dentz
2023-03-15 19:42   ` Luiz Augusto von Dentz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=AS8PR04MB8898256F1388824FC19F67BFECB39@AS8PR04MB8898.eurprd04.prod.outlook.com \
    --to=iulia.tanasescu@nxp.com \
    --cc=linux-bluetooth@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.