platform/upstream/bluez.git
6 months agoshared/bass: Introduce Add Source opcode handler
Iulia Tanasescu [Thu, 29 Jun 2023 08:07:35 +0000 (11:07 +0300)]
shared/bass: Introduce Add Source opcode handler

This implements the Control Point handler for the Add Source operation.

6 months agobtio: Add options for binding iso broadcast address
Iulia Tanasescu [Thu, 29 Jun 2023 08:07:34 +0000 (11:07 +0300)]
btio: Add options for binding iso broadcast address

This adds additional btio options, to allow binding a socket
to a broadcaster address.

6 months agoplugins/admin: Fix heap-use-after-free when using 2 controllers
Vlad Pruteanu [Tue, 4 Jul 2023 05:56:43 +0000 (08:56 +0300)]
plugins/admin: Fix heap-use-after-free when using 2 controllers

This commit fixes the heap-use-after-free error when connecting 2
controllers. When a controller is connected
admin_policy_adapter_probe is called. If policy_data was already
allocated it gets freed, if not, it only gets allocated. Eventually
add_interface is called. Here policy_data is put in the "data" variable
(specific for each controller) and the process_changes task is called
with idle priority. This function ultimately accesses policy_data from
the "data" variable.

When Bluez crashes the flow is:
1)first controller is attached
2)admin_policy_adapter_probe is called and policy_data is allocated
4)second controller is attached
5)admin_policy_adapter_probe is called and policy_data is freed, then
allocated again
6)process_changes runs and the policy_data for the first controller is
read, but it was already freed, thus the crash

6 months agomonitor: Add decoding support for Sync Receiver events
Claudia Draghicescu [Tue, 4 Jul 2023 07:41:44 +0000 (10:41 +0300)]
monitor: Add decoding support for Sync Receiver events

This commit adds decoding support for PA Sync Established,
BIG Sync Established and BIG Sync Lost events.

6 months agobap: wait for CIG to become configurable before recreating CIS
Pauli Virtanen [Sun, 2 Jul 2023 18:43:05 +0000 (21:43 +0300)]
bap: wait for CIG to become configurable before recreating CIS

ISO sockets cannot be reconnected before all sockets in the same CIG
have been closed, if the CIG was previously active.

Keep track which endpoints have active CIG, and postpone connecting CIS
until their CIG is no longer active.

This addresses getting EBUSY from connect() when multiple CIS in the
same CIG move streaming -> qos at the same time, which disconnects CIS
and recreates them.  The EBUSY originates from COMMAND_DISALLOWED
response to Set CIG Parameters.

This requires the kernel side do the Disconnect CIS / Remove CIG / Set
CIG Parameters HCI command steps in the right order, when all old
sockets are closed first before connecting new ones.

6 months agoshared/bap: detach io for source ASEs only after Stop Ready
Pauli Virtanen [Sun, 2 Jul 2023 18:43:04 +0000 (21:43 +0300)]
shared/bap: detach io for source ASEs only after Stop Ready

The Client may terminate a CIS when sink is in QOS and source in
Disabling states (BAP v1.0.1 Sec 5.6.5).  It may also terminate it when
Receiver Stop Ready has completed successfully (BAP v1.0.1 Sec 5.6.5.1).

It appears Samsung Galaxy Buds2 Pro (R510XXUOAWA5) ignores the Receiver
Stop Ready command if CIS is already disconnected, and then gets stuck
in disabling state. It works if CIS is disconnected after Receiver Stop
Ready.

For better compatibility as client for this device, and since it
shouldn't matter for us in which order we do it, disconnect CIS after
completion of Receiver Stop Ready, instead of immediately in Disabling.

We disconnect also if Receiver Stop Ready fails, given that
disconnecting in Disabled state should be OK.

Link: https://github.com/bluez/bluez/issues/516
6 months agomgmt-tester: Add a regression test hitting hci_sync bug
Pauli Virtanen [Thu, 15 Jun 2023 20:02:51 +0000 (23:02 +0300)]
mgmt-tester: Add a regression test hitting hci_sync bug

Add a test "Add + Remove Device Nowait - Success" that hits a race
condition in kernel hci_sync.c.  On current kernels this causes

BUG: KASAN: slab-use-after-free in hci_update_passive_scan_sync+0x857/0x1230

due to unsafe iteration of hdev->pend_le_conns (in Linux <= 6.4-rc4).

This seems to hit the race condition also without the added emulator
delay (since the emulator runs in the same thread), but it's better to
add the delay since otherwise it'll depend on timings on kernel side.

6 months agodoc/tester-config: enable DEBUG_KERNEL, PROVE_RCU, DEBUG_ATOMIC_SLEEP
Pauli Virtanen [Tue, 4 Jul 2023 17:06:51 +0000 (20:06 +0300)]
doc/tester-config: enable DEBUG_KERNEL, PROVE_RCU, DEBUG_ATOMIC_SLEEP

Add more lock/sleep debugging to the default tester config.

Enable DEBUG_KERNEL since olddefconfig won't enable PROVE_LOCKING
without it. Enable PROVE_RCU to also check RCU usage. Enable
DEBUG_ATOMIC_SLEEP to catch those as well.

6 months agoshared/bap: use only nonzero req->id
Pauli Virtanen [Sun, 2 Jul 2023 19:34:19 +0000 (22:34 +0300)]
shared/bap: use only nonzero req->id

In bap_req_new, use same pattern as elsewhere to not use zero as
a valid id.

6 months agotransport: handle BAP Enabling state correctly when resuming
Pauli Virtanen [Sun, 2 Jul 2023 19:34:18 +0000 (22:34 +0300)]
transport: handle BAP Enabling state correctly when resuming

If BAP stream is in Enabling state when transport acquire is attempted,
we should wait for bap_state_changed to emit the completion event.

transport->resume() is only called with new owner with no
owner->pending, and shall return nonzero completion id on success.
Currently if BAP stream is Enabling, it returns zero which fails the
acquire operation.

To fix this, return valid completion id in this case instead.  Also keep
track of the g_idle_add resume id, so that we don't try to give it to
bt_bap_stream_cancel.

Fixes sound server getting spurious Not Authorized errors when trying to
acquire a pending transport.  This can happen on BAP server: linked
transports become pending when the first of the two enters Streaming. If
sound server tries to acquire the other linked transport whose stream is
still Enabling, the acquire fails (media_owner_free +
btd_error_not_authorized).

Log:
===============================================================
profiles/audio/transport.c:bap_state_changed() stream 0x25c2880: qos(2) -> enabling(3)
...
profiles/audio/transport.c:bap_state_changed() stream 0x25cc590: qos(2) -> enabling(3)
...
src/shared/bap.c:bap_stream_state_changed() stream 0x25cc590 dir 0x01: enabling -> streaming
profiles/audio/bap.c:bap_state() stream 0x25cc590: enabling(3) -> streaming(4)
profiles/audio/transport.c:bap_state_changed() stream 0x25cc590: enabling(3) -> streaming(4)
/org/bluez/hci0/dev_XX_XX_XX_XX_XX_XX/fd1: fd(36) ready
profiles/audio/transport.c:transport_update_playing() /org/bluez/hci0/dev_XX_XX_XX_XX_XX_XX/fd1 State=TRANSPORT_STATE_IDLE Playing=1
profiles/audio/transport.c:transport_set_state() State changed /org/bluez/hci0/dev_XX_XX_XX_XX_XX_XX/fd1: TRANSPORT_STATE_IDLE -> TRANSPORT_STATE_PENDING
profiles/audio/transport.c:transport_set_state() State changed /org/bluez/hci0/dev_XX_XX_XX_XX_XX_XX/fd0: TRANSPORT_STATE_IDLE -> TRANSPORT_STATE_PENDING
profiles/audio/transport.c:media_owner_create() Owner created: sender=:1.1242
profiles/audio/transport.c:media_owner_free() Owner :1.1242
===============================================================

6 months agoRelease 5.68
Marcel Holtmann [Fri, 30 Jun 2023 19:39:03 +0000 (21:39 +0200)]
Release 5.68

6 months agotransport: Fix crash on Transport.Acquire
Luiz Augusto von Dentz [Fri, 30 Jun 2023 19:24:54 +0000 (12:24 -0700)]
transport: Fix crash on Transport.Acquire

This fixes crash introduced by 3030883 which caused requests not be
initialized properly for A2DP.

Fixes: https://github.com/bluez/bluez/issues/542

6 months agoRelease 5.67
Marcel Holtmann [Fri, 30 Jun 2023 08:09:06 +0000 (10:09 +0200)]
Release 5.67

6 months agobuild: Use LT_INIT instead of AC_PROG_LIBTOOL
Marcel Holtmann [Fri, 30 Jun 2023 07:35:21 +0000 (09:35 +0200)]
build: Use LT_INIT instead of AC_PROG_LIBTOOL

6 months agobuild: Update library version
Marcel Holtmann [Fri, 30 Jun 2023 07:30:40 +0000 (09:30 +0200)]
build: Update library version

6 months agoshared/bap: Fix handling of codec fields
Luiz Augusto von Dentz [Tue, 27 Jun 2023 23:47:09 +0000 (16:47 -0700)]
shared/bap: Fix handling of codec fields

Codec fields needs to be converted when codec.id is 0xff as the host
endian may not always be little endian.

6 months agoshared/bap: Fix parsing of vendor specific codecs
Luiz Augusto von Dentz [Tue, 27 Jun 2023 16:45:55 +0000 (09:45 -0700)]
shared/bap: Fix parsing of vendor specific codecs

While parsing vendor specific codecs cid and vid fields need to be
converted using le16_to_cpu.

6 months agoandroid: Fix compiler warning from GCC
Marcel Holtmann [Tue, 27 Jun 2023 16:08:19 +0000 (18:08 +0200)]
android: Fix compiler warning from GCC

This ignores the following two warnings from the compiler.

  CC       android/gatt.o
android/gatt.c: In function ‘handle_client_register_for_notification’:
android/gatt.c:3733:9: error: ‘memcpy’ offset [0, 16] is out of the bounds [0, 0] [-Werror=array-bounds=]
 3733 |         memcpy(&notification->ch, &cmd->char_id, sizeof(notification->ch));
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  CC       android/gatt.o
android/gatt.c: In function ‘handle_client_register_for_notification’:
android/gatt.c:3735:9: error: ‘memcpy’ writing 17 bytes into a region of size 0 overflows the destination [-Werror=stringop-overflow=]
 3735 |         memcpy(&notification->ch, &cmd->char_id, sizeof(notification->ch));
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

It could be possible that these warnings are valid or they might be a
false positive. However since this is Android based code based on
Android HAL headers, just set pragma to ignore them.

6 months agoisotest: Add check after accepting connection
Iulia Tanasescu [Fri, 23 Jun 2023 07:44:06 +0000 (10:44 +0300)]
isotest: Add check after accepting connection

This checks for the POLLERR event on a newly accepted connection,
to determine if the connection was successful or not.

6 months agoiso-tester: Fix checks of latency and interval
Luiz Augusto von Dentz [Fri, 23 Jun 2023 21:17:46 +0000 (14:17 -0700)]
iso-tester: Fix checks of latency and interval

Due to rounding of latency, BAP uses msec while HCI uses slots of
1.25 ms, values may not return an exact match which is fine since the
BAP QoS suggests they are the maximum latency/interval so values bellow
that shall be considered a match.

6 months agobtdev: Fix CIS Established Event parameters
Luiz Augusto von Dentz [Fri, 23 Jun 2023 21:16:02 +0000 (14:16 -0700)]
btdev: Fix CIS Established Event parameters

ISO Interval and Transport Latency were inverted.

6 months agobtdev: Fix LE CIS Established Event
Luiz Augusto von Dentz [Thu, 22 Jun 2023 19:06:17 +0000 (12:06 -0700)]
btdev: Fix LE CIS Established Event

LE CIS Established Event Transport Latency shall follow the formula from
the spec:

 BLUETOOTH CORE SPECIFICATION Version 5.3 | Vol 6, Part G
 page 3050:

 Transport_Latency_C_To_P = CIG_Sync_Delay + FT_C_To_P ×
 ISO_Interval - SDU_Interval_C_To_P
 Transport_Latency_P_To_C = CIG_Sync_Delay + FT_P_To_C ×
 ISO_Interval - SDU_Interval_P_To_C

6 months agomonitor: Use get_le24 to convert 24 bits values
Luiz Augusto von Dentz [Wed, 21 Jun 2023 22:05:31 +0000 (15:05 -0700)]
monitor: Use get_le24 to convert 24 bits values

This uses get_le24 to convert 24 bits microseconds values.

6 months agobtdev: Fix CIS Establish ISO Interval
Luiz Augusto von Dentz [Tue, 20 Jun 2023 22:37:35 +0000 (15:37 -0700)]
btdev: Fix CIS Establish ISO Interval

ISO Interval is actually using 1.25 ms slots so it needs to be properly
converted.

6 months agomonitor: Fix decoding of HCI CIS Established Event
Luiz Augusto von Dentz [Tue, 20 Jun 2023 22:35:37 +0000 (15:35 -0700)]
monitor: Fix decoding of HCI CIS Established Event

The ISO Interval is actually using set using 1.25ms slots:

BLUETOOTH CORE SPECIFICATION Version 5.3 | Vol 4, Part E
page 2304:

  Time = N * 1.25 ms

6 months agoadapter: Handle Device Found Event with Scan Response flag
Luiz Augusto von Dentz [Tue, 20 Jun 2023 20:37:53 +0000 (13:37 -0700)]
adapter: Handle Device Found Event with Scan Response flag

This handles recently introduced Scan Response flag since that
shouldn't affect connectable flag the device would be considered
connectable but it shall not create a new device by itself.

6 months agomonitor: Add missing flags to MGMT Device Found Event
Luiz Augusto von Dentz [Tue, 20 Jun 2023 20:36:35 +0000 (13:36 -0700)]
monitor: Add missing flags to MGMT Device Found Event

This adds the missing flags to MGMT Device Found Event so they can be
decoded properly.

6 months agomgmt-api: Update Device Found Event documentation
Luiz Augusto von Dentz [Tue, 20 Jun 2023 20:33:50 +0000 (13:33 -0700)]
mgmt-api: Update Device Found Event documentation

This updates Device Found Event documentation to mention the new flag
introduced to track when the event is generated due a interleaved Scan
Response that couldn't be merged.

6 months agoshared/bap: Pass bcode as a reference instead of value
Luiz Augusto von Dentz [Mon, 19 Jun 2023 20:30:32 +0000 (13:30 -0700)]
shared/bap: Pass bcode as a reference instead of value

This makes bcode field a pointer which makes it simpler to detect when
it is set and also fixes the usage of util_iov_free which expects it to
be allocated.

6 months agoclient/player: Fix transport.acquire for linked transports
Luiz Augusto von Dentz [Mon, 19 Jun 2023 20:30:31 +0000 (13:30 -0700)]
client/player: Fix transport.acquire for linked transports

Linked (bi-directional) transports can be acquired on single D-Bus
method call which was not being handled properly by the current code
causing unexpected errors.

6 months agoclient/player: Fix auto registration of broadcast endpoint
Luiz Augusto von Dentz [Mon, 19 Jun 2023 20:30:30 +0000 (13:30 -0700)]
client/player: Fix auto registration of broadcast endpoint

For broadcast endpoint broadcast must be set properly.

6 months agoclient: Print integers decimal value
Luiz Augusto von Dentz [Mon, 19 Jun 2023 20:30:29 +0000 (13:30 -0700)]
client: Print integers decimal value

This make the code print D-Bus integer iterators also in decimal format
in addition to hexadecimal.

6 months agoshared/bap: Add unespecified bit in audio context to PAC records
Luiz Augusto von Dentz [Mon, 19 Jun 2023 20:30:28 +0000 (13:30 -0700)]
shared/bap: Add unespecified bit in audio context to PAC records

This makes sure unespecified bit is properly marked in both audio
contexts since that required by many platforms in order to work properly
and while doing that add proper defines to the defaults values used in
PACS.

6 months agoshared/bass: Implement CP opcode handlers
Iulia Tanasescu [Tue, 13 Jun 2023 14:16:25 +0000 (17:16 +0300)]
shared/bass: Implement CP opcode handlers

This adds handlers for the following BASS Broadcast Audio Scan
Control Point opcodes:
   Remote Scan Stopped
   Remote Scan Started
   Remove Source

6 months agogatt-server: Check pointer before memcpy
Iulia Tanasescu [Tue, 13 Jun 2023 14:16:24 +0000 (17:16 +0300)]
gatt-server: Check pointer before memcpy

This adds a check before calling memcpy inside
bt_gatt_server_send_notification, to avoid getting
the following error in case the user wants to send
an empty notification for an attribute:

src/shared/gatt-server.c:1789:3: runtime error:
null pointer passed as argument 2, which is declared to never be null

6 months agoshared/vcp.c: Make VOCS as an included service of VCS
Nitin Jadhav [Mon, 12 Jun 2023 13:32:51 +0000 (19:02 +0530)]
shared/vcp.c: Make VOCS as an included service of VCS

Fixed the following issue observed during PTS testing
- Specified Upper and Lower Limit for Volume offset
- Corrected the number of handles for VOCS
- VOCS is made as included service of VCS
  (VOCS is secondary service and VSC is primary service)

6 months agoshared/vcp: Add initial code for handling VOCS
Nitin Jadhav [Mon, 12 Jun 2023 13:32:50 +0000 (19:02 +0530)]
shared/vcp: Add initial code for handling VOCS

Summary:
- This adds implementation for VOCS service and characteristics
- Implementation based on VOCS_v1.0.pdf specification
- Tested using PTS with reference to VOCS.TS.p1.pdf

6 months agolib/uuid.h: Add VOCS characteristic uuid(s)
Nitin Jadhav [Mon, 12 Jun 2023 13:32:49 +0000 (19:02 +0530)]
lib/uuid.h: Add VOCS characteristic uuid(s)

6 months agomesh: Fix build error
Luiz Augusto von Dentz [Tue, 13 Jun 2023 20:28:47 +0000 (13:28 -0700)]
mesh: Fix build error

This fixes the following error:

In function ‘get_composition’,
    inlined from ‘cfg_srv_pkt’ at mesh/cfgmod-server.c:801:8:
mesh/cfgmod-server.c:758:9: error: ‘comp’ may be used
uninitialized [-Werror=maybe-uninitialized]
  758 |         memcpy(buf, comp, len);
      |         ^~~~~~~~~~~~~~~~~~~~~~
mesh/cfgmod-server.c: In function ‘cfg_srv_pkt’:
mesh/cfgmod-server.c:739:24: note: ‘comp’ was declared here
  739 |         const uint8_t *comp;
      |                        ^~~~

6 months agobtdev: Fix build error
Luiz Augusto von Dentz [Tue, 13 Jun 2023 20:25:34 +0000 (13:25 -0700)]
btdev: Fix build error

This fixes the following build error:

emulator/btdev.c: In function ‘le_cis_estabilished’:
emulator/btdev.c:5947:22: error: ‘cis_idx’ may be used
uninitialized [-Werror=maybe-uninitialized]
 5947 |         int cig_idx, cis_idx;
      |                      ^~~~~~~

6 months agobap: Add broadcast source support
Silviu Florian Barbulescu [Wed, 7 Jun 2023 08:23:00 +0000 (11:23 +0300)]
bap: Add broadcast source support

This updates BAP plugin with broadcast source support.

6 months agoshared/bap: Add initial code for BAP broadcast source
Silviu Florian Barbulescu [Wed, 7 Jun 2023 08:22:59 +0000 (11:22 +0300)]
shared/bap: Add initial code for BAP broadcast source

This adds initial support for BAP broadcast source.

6 months agoclient/player: Add support for broadcast source
Silviu Florian Barbulescu [Wed, 7 Jun 2023 08:22:58 +0000 (11:22 +0300)]
client/player: Add support for broadcast source

This adds bluetoothctl support for broadcast source.
To test the current implementation use bluetoothctl with the commands:
endpoint.register 00001852-0000-1000-8000-00805f9b34fb 0x06
endpoint.config <created endpoint> <local endpoint> 16_2_1
transport.acquire <created transport>
transport.send <created transport> <file.wav>

6 months agoshared/bap: Split unicast and broadcast structures
Silviu Florian Barbulescu [Wed, 7 Jun 2023 08:22:57 +0000 (11:22 +0300)]
shared/bap: Split unicast and broadcast structures

This splits bt_bap_qos structure into unicast and broadcast structures.

6 months agomedia: Register app objects in proxy_added_cb()
Arkadiusz Bokowy [Sat, 27 May 2023 23:14:58 +0000 (01:14 +0200)]
media: Register app objects in proxy_added_cb()

The proxy_added_cb() function is called every time a new client is added
to the application object manager. Registering media endpoint and player
in that proxy_added_cb() callback function will allow to register new
endpoints and players not only during the initial RegisterApplication
call, but also during the application lifetime. For instance, this might
allow to dynamically enable/disable support for additional codecs.

6 months agobattery: Check interface before getting property
Arkadiusz Bokowy [Sun, 28 May 2023 07:44:45 +0000 (09:44 +0200)]
battery: Check interface before getting property

Client can export other interfaces than the BatteryProvide1 on the
registered object manager. So, before getting battery provider specific
property, validate that we are operating on the right interface.

This change will allow client to implement only one object manger for
media applications, players and battery providers without triggering
error message.

6 months agoshared/bap: Don't overwrite attribute declaration
Luiz Augusto von Dentz [Thu, 1 Jun 2023 23:28:09 +0000 (16:28 -0700)]
shared/bap: Don't overwrite attribute declaration

The attribute declaration (e.g. characteristic properties) shall not be
overwritten as they are part of the information that is part of the
cache beside the same information is already stored as part of the
bt_bap instance.

6 months agomonitor: Only print credentials if PID is set
Luiz Augusto von Dentz [Thu, 1 Jun 2023 23:26:15 +0000 (16:26 -0700)]
monitor: Only print credentials if PID is set

If PID is not set don't print anything since this is likely a packet
originated by the kernel itself.

6 months agounit: Introduce test-bass
Iulia Tanasescu [Mon, 29 May 2023 08:46:50 +0000 (11:46 +0300)]
unit: Introduce test-bass

This adds 3 unit tests for BASS server, to simulate the
Generic GATT Integrated Test suite for BASS.

Test Summary
------------
BASS/SR/SGGIT/SER/BV-01-C                            Passed
BASS/SR/SGGIT/CHA/BV-01-C                            Passed
BASS/SR/SGGIT/CHA/BV-02-C                            Passed
Total: 3, Passed: 3 (100.0%), Failed: 0, Not Run: 0

6 months agoshared/bass: Add Write Without Response property to the CP characteristic
Iulia Tanasescu [Mon, 29 May 2023 08:46:49 +0000 (11:46 +0300)]
shared/bass: Add Write Without Response property to the CP characteristic

This adds the Write Without Response property to the Broadcast Audio
Scan Control Point characteristic, which is mandatory according to
specification.

6 months agoiso-tester: Add BAP Broadcast AC tests
Iulia Tanasescu [Mon, 29 May 2023 06:24:58 +0000 (09:24 +0300)]
iso-tester: Add BAP Broadcast AC tests

This adds the following tests based on BAP Broadcast Audio Configurations:

ISO Broadcaster AC 12 - Success
ISO Broadcaster AC 13 - Success
ISO Broadcaster AC 14 - Success

6 months agobtdev: Support multiple BIS
Iulia Tanasescu [Mon, 29 May 2023 06:24:57 +0000 (09:24 +0300)]
btdev: Support multiple BIS

This adds support for creating a BIG with multiple BISes.

6 months agoisotest: Add support for creating/synchronizing to multiple BISes
Iulia Tanasescu [Mon, 29 May 2023 06:27:34 +0000 (09:27 +0300)]
isotest: Add support for creating/synchronizing to multiple BISes

This adds an additional command line option for the Broadcast exercise,
so that the user can indicate the number of BISes to create as part of a
BIG (Broadcast Source), or the number of BISes to synchronize
to (Broadcast Sink).

For the Broadcast Source exercise, issue the following command,
in order to create a BIG with handle 0x01, associated with the
advertising handle 0x01, with 2 BISes:

    tools/isotest -i hci0 -s 00:00:00:00:00:00 -N 2 -G 1 -T 1

The isotest and btmon logs will look something like this:

isotest[7178]: mgmt socket: fd 3
isotest[7178]: mgmt_set_le: err 0
isotest[7178]: mgmt_set_experimental: err 0
isotest[7179]: Exit
isotest[7178]: Connecting 00:00:00:00:00:00 ...
isotest[7178]: Connected [00:00:00:00:00:00]
isotest[7178]: QoS [BIG 0x01 BIS 0x01 Packing 0x00 Framing 0x00 Encryption 0x00]
isotest[7178]: Input QoS [Interval 10000 us Latency 10 ms SDU 0 PHY 0x00 RTN 2]
isotest[7178]: Output QoS [Interval 10000 us Latency 10 ms SDU 40 PHY 0x02 RTN 2]
isotest[7178]: Connecting 00:00:00:00:00:00 ...
isotest[7178]: Connected [00:00:00:00:00:00]
isotest[7178]: QoS [BIG 0x01 BIS 0x01 Packing 0x00 Framing 0x00 Encryption 0x00]
isotest[7178]: Input QoS [Interval 10000 us Latency 10 ms SDU 0 PHY 0x00 RTN 2]
isotest[7178]: Output QoS [Interval 10000 us Latency 10 ms SDU 40 PHY 0x02 RTN 2]
isotest[7183]: Sending ...
isotest[7183]: Number of packets: 1
isotest[7183]: Socket jitter buffer: 80 buffer
isotest[7183]: [seq 0] 40 bytes buffered 92 (3712 bytes)
isotest[7184]: Sending ...
isotest[7184]: Number of packets: 1
isotest[7184]: Socket jitter buffer: 80 buffer
isotest[7184]: [seq 0] 40 bytes buffered 92 (3712 bytes)
isotest[7178]: Exit

< HCI Command: LE Create Broadcast Isochronous Group (0x08|0x0068) plen 31
        Handle: 0x01
        Advertising Handle: 0x01
        Number of BIS: 2
        SDU Interval: 10000 us (0x002710)
        Maximum SDU size: 40
        Maximum Latency: 10 ms (0x000a)
        RTN: 0x02
        PHY: LE 2M (0x02)
        Packing: Sequential (0x00)
        Framing: Unframed (0x00)
        Encryption: 0x00
        Broadcast Code: 00000000000000000000000000000000

> HCI Event: Command Status (0x0f) plen 4
      LE Create Broadcast Isochronous Group (0x08|0x0068) ncmd 1
        Status: Success (0x00)

> HCI Event: LE Meta Event (0x3e) plen 23
      LE Broadcast Isochronous Group Complete (0x1b)
        Status: Success (0x00)
        Handle: 0x01
        BIG Synchronization Delay: 1974 us (0x0007b6)
        Transport Latency: 1974 us (0x0007b6)
        PHY: LE 2M (0x02)
        NSE: 3
        BN: 1
        PTO: 1
        IRC: 3
        Maximum PDU: 40
        ISO Interval: 10.00 msec (0x0008)
        Connection Handle #0: 10
        Connection Handle #1: 11

< HCI Command: LE Setup Isochronous Data Path (0x08|0x006e) plen 13
        Handle: 10
        Data Path Direction: Input (Host to Controller) (0x00)
        Data Path: HCI (0x00)
        Coding Format: Transparent (0x03)
        Company Codec ID: Ericsson Technology Licensing (0)
        Vendor Codec ID: 0
        Controller Delay: 0 us (0x000000)
        Codec Configuration Length: 0
        Codec Configuration:

> HCI Event: Command Complete (0x0e) plen 6
      LE Setup Isochronous Data Path (0x08|0x006e) ncmd 1
        Status: Success (0x00)
        Handle: 10

< HCI Command: LE Setup Isochronous Data Path (0x08|0x006e) plen 13
        Handle: 11
        Data Path Direction: Input (Host to Controller) (0x00)
        Data Path: HCI (0x00)
        Coding Format: Transparent (0x03)
        Company Codec ID: Ericsson Technology Licensing (0)
        Vendor Codec ID: 0
        Controller Delay: 0 us (0x000000)
        Codec Configuration Length: 0
        Codec Configuration:

> HCI Event: Command Complete (0x0e) plen 6
      LE Setup Isochronous Data Path (0x08|0x006e) ncmd 1
        Status: Success (0x00)
        Handle: 11

< ISO Data TX: Handle 10 flags 0x02 dlen 44

< ISO Data TX: Handle 11 flags 0x02 dlen 44

> HCI Event: Number of Completed Packets (0x13) plen 5
        Num handles: 1
        Handle: 10
        Count: 1

> HCI Event: Number of Completed Packets (0x13) plen 5
        Num handles: 1
        Handle: 11
        Count: 1

For the Broadcast Sink exercise, issue the following command,
in order to synchronize to the BISes created by the source:

    tools/isotest -i hci1 -r 36:13:00:E1:1B:F0 -V le_random -N 2 -G 1

The flow is shown by the isotest log and the filtered btmon snippet below:

isotest[4033]: mgmt socket: fd 3
isotest[4034]: Exit
isotest[4033]: mgmt_set_le: err 0
isotest[4033]: mgmt_set_experimental: err 0
isotest[4033]: Waiting for connection 36:13:00:E1:1B:F0...
isotest[4036]: Connected [36:13:00:E1:1B:F0]
isotest[4036]: QoS [BIG 0x01 BIS 0x00 Packing 0x00 Framing 0x00 Encryption 0x00]
isotest[4036]: Input QoS [Interval 1974 us Latency 10 ms SDU 40 PHY 0x00 RTN 0]
isotest[4036]: Output QoS [Interval 0 us Latency 0 ms SDU 0 PHY 0x00 RTN 0]
isotest[4036]: Receiving ...
isotest[4037]: Connected [36:13:00:E1:1B:F0]
isotest[4037]: QoS [BIG 0x01 BIS 0x00 Packing 0x00 Framing 0x00 Encryption 0x00]
isotest[4037]: Input QoS [Interval 1974 us Latency 10 ms SDU 40 PHY 0x00 RTN 0]
isotest[4037]: Output QoS [Interval 0 us Latency 0 ms SDU 0 PHY 0x00 RTN 0]
isotest[4037]: Receiving ...
isotest[4037]: [seq 0] 280 bytes in 6.48 sec speed 0.34 kb/s
isotest[4036]: [seq 0] 280 bytes in 6.54 sec speed 0.33 kb/s
isotest[4037]: [seq 1] 280 bytes in 7.01 sec speed 0.31 kb/s
isotest[4036]: [seq 1] 280 bytes in 7.02 sec speed 0.31 kb/s
isotest[4037]: [seq 2] 280 bytes in 7.06 sec speed 0.31 kb/s
isotest[4036]: [seq 2] 280 bytes in 7.04 sec speed 0.31 kb/s

< 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: 0x00
        Adv address type: Random (0x01)
        Adv address: 36:13:00:E1:1B:F0 (Non-Resolvable)
        Skip: 0x0000
        Sync timeout: 163840 msec (0x4000)
        Sync CTE type: 0x0000

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

< HCI Command: LE Set Extended Scan Parameters (0x08|0x0041) plen 13
        Own address type: Public (0x00)
        Filter policy: Ignore not in accept list (0x01)
        PHYs: 0x05
        Entry 0: LE 1M
          Type: Passive (0x00)
          Interval: 60.000 msec (0x0060)
          Window: 30.000 msec (0x0030)
        Entry 1: LE Coded
          Type: Passive (0x00)
          Interval: 60.000 msec (0x0060)
          Window: 30.000 msec (0x0030)

> HCI Event: Command Complete (0x0e) plen 4
      LE Set Extended Scan Parameters (0x08|0x0041) ncmd 1
        Status: Success (0x00)

< HCI Command: LE Set Extended Scan Enable (0x08|0x0042) plen 6
        Extended scan: Enabled (0x01)
        Filter duplicates: Enabled (0x01)
        Duration: 0 msec (0x0000)
        Period: 0.00 sec (0x0000)

> HCI Event: Command Complete (0x0e) plen 4
      LE Set Extended Scan Enable (0x08|0x0042) ncmd 1
        Status: Success (0x00)

> HCI Event: LE Meta Event (0x3e) plen 16
      LE Periodic Advertising Sync Established (0x0e)
        Status: Success (0x00)
        Sync handle: 0
        Advertising SID: 0x00
        Advertiser address type: Random (0x01)
        Advertiser address: 36:13:00:E1:1B:F0 (Non-Resolvable)
        Advertiser PHY: LE 2M (0x02)
        Periodic advertising interval: 10.00 msec (0x0008)
        Advertiser clock accuracy: 0x00

> HCI Event: LE Meta Event (0x3e) plen 8
      LE Periodic Advertising Report (0x0f)
        Sync handle: 0
        TX power: 127 dbm (0x7f)
        RSSI: -47 dBm (0xd1)
        CTE Type: No Constant Tone Extension (0xff)
        Data status: Complete
        Data length: 0x00

> HCI Event: LE Meta Event (0x3e) plen 20
      LE Broadcast Isochronous Group Info Advertising Report (0x22)
        Sync Handle: 0x0000
        Number BIS: 2
        NSE: 3
        ISO Interval: 10.00 msec (0x0008)
        BN: 1
        PTO: 1
        IRC: 3
        Maximum PDU: 40
        SDU Interval: 10000 us (0x002710)
        Maximum SDU: 40
        PHY: LE 2M (0x02)
        Framing: Unframed (0x00)
        Encryption: 0x00

< HCI Command: LE Broadcast Isochronous Group Create Sync (0x08|0x006b) plen 26
        BIG Handle: 0x01
        BIG Sync Handle: 0x0000
        Encryption: Unencrypted (0x00)
        Broadcast Code: 00000000000000000000000000000000
        Maximum Number Subevents: 0x00
        Timeout: 163840 ms (0x4000)
        Number of BIS: 2
        BIS ID: 0x01
        BIS ID: 0x02

> HCI Event: LE Meta Event (0x3e) plen 19
      LE Broadcast Isochronous Group Sync Estabilished (0x1d)
        Status: Success (0x00)
        BIG Handle: 0x01
        Transport Latency: 1974 us (0x0007b6)
        NSE: 3
        BN: 1
        PTO: 1
        IRC: 3
        Maximum PDU: 40
        ISO Interval: 10.00 msec (0x0008)
        Connection Handle #0: 10
        Connection Handle #1: 11

< HCI Command: LE Setup Isochronous Data Path (0x08|0x006e) plen 13
        Handle: 10
        Data Path Direction: Output (Controller to Host) (0x01)
        Data Path: HCI (0x00)
        Coding Format: Transparent (0x03)
        Company Codec ID: Ericsson Technology Licensing (0)
        Vendor Codec ID: 0
        Controller Delay: 0 us (0x000000)
        Codec Configuration Length: 0
        Codec Configuration:

> HCI Event: Command Complete (0x0e) plen 6
      LE Setup Isochronous Data Path (0x08|0x006e) ncmd 1
        Status: Success (0x00)
        Handle: 10

< HCI Command: LE Setup Isochronous Data Path (0x08|0x006e) plen 13
        Handle: 11
        Data Path Direction: Output (Controller to Host) (0x01)
        Data Path: HCI (0x00)
        Coding Format: Transparent (0x03)
        Company Codec ID: Ericsson Technology Licensing (0)
        Vendor Codec ID: 0
        Controller Delay: 0 us (0x000000)
        Codec Configuration Length: 0
        Codec Configuration:

> HCI Event: Command Complete (0x0e) plen 6
      LE Setup Isochronous Data Path (0x08|0x006e) ncmd 1
        Status: Success (0x00)
        Handle: 11

> ISO Data RX: Handle 10 flags 0x06 dlen 48

> ISO Data RX: Handle 11 flags 0x06 dlen 48

6 months agotest-runner: enable no_hash_pointers=1
Pauli Virtanen [Sun, 28 May 2023 17:39:16 +0000 (17:39 +0000)]
test-runner: enable no_hash_pointers=1

Set no_hash_pointers=1 to avoid printk printing "___ptrval___" for %p.
This happens with test-runner since the kernel is not running long
enough to gather entropy and so refuses to print addresses, and makes
debugging harder.  As test-runner is only used for testing and
debugging, pointer hashing is not needed.

6 months agobtdev: check LE Create CIS error conditions
Pauli Virtanen [Sun, 28 May 2023 17:39:15 +0000 (17:39 +0000)]
btdev: check LE Create CIS error conditions

Check LE Create CIS input parameter are valid and return correct status
codes (Core v5.3 Vol 4 Part E Sec. 7.8.99).

On current bluetooth-next kernel, this results to

ISO AC 6(i) - Success                                Failed
ISO AC 7(i) - Success                                Failed
ISO AC 8(i) - Success                                Failed
ISO AC 9(i) - Success                                Failed
ISO AC 11(i) - Success                               Failed

as in these tests the kernel is sending new Create CIS commands before
it has seen all events from the previous, which is not allowed:

< HCI Command: LE Create Co.. (0x08|0x0064) plen 9  #129 [hci0]
        Number of CIS: 2
        CIS Handle: 257
        ACL Handle: 42
        CIS Handle: 258
        ACL Handle: 42
> HCI Event: Command Status (0x0f) plen 4           #130 [hci0]
      LE Create Connected Isochronous Stream (0x08|0x0064) ncmd 1
        Status: Success (0x00)
> HCI Event: LE Meta Event (0x3e) plen 29           #131 [hci0]
      LE Connected Isochronous Stream Established (0x19)
        Status: Success (0x00)
        Connection Handle: 257
        ...
< HCI Command: LE Setup Is.. (0x08|0x006e) plen 13  #132 [hci0]
        ...
> HCI Event: Command Complete (0x0e) plen 6         #133 [hci0]
      LE Setup Isochronous Data Path (0x08|0x006e) ncmd 1
        ...
< HCI Command: LE Create Co.. (0x08|0x0064) plen 5  #134 [hci0]
        Number of CIS: 1
        CIS Handle: 258
        ACL Handle: 42
> HCI Event: Command Status (0x0f) plen 4           #135 [hci0]
      LE Create Connected Isochronous Stream (0x08|0x0064) ncmd 1
        Status: ACL Connection Already Exists (0x0b)
> HCI Event: LE Meta Event (0x3e) plen 29           #136 [hci0]
      LE Connected Isochronous Stream Established (0x19)
        Status: Success (0x00)
        Connection Handle: 258
        ...

The emulator uses Already Exists error code here, not Command
Disallowed, since the Established events are logically generated
immediately after the first status event, even though the kernel hasn't
yet processed them.

6 months agobtdev: fix inactive CIG configurable status
Pauli Virtanen [Sun, 28 May 2023 17:39:14 +0000 (17:39 +0000)]
btdev: fix inactive CIG configurable status

CIG shall not be configurable after the first Create CIS until Remove
CIG is issued (Core v5.3 Vol 6 Part B Sec. 4.5.14.3).  We currently have
it configurable in the inactive state (Create CIS done and all CIS
closed), which is incorrect.

Track CIG state and allow reconfigure only in nonexistent/configured
state, i.e., when no CIS have been created yet.

6 months agoiso-tester: Add tests for AC configuration reconnect
Pauli Virtanen [Sun, 28 May 2023 17:39:13 +0000 (17:39 +0000)]
iso-tester: Add tests for AC configuration reconnect

Add test for reconnecting a CIG with two CIS, either both with same peer
or with different peers.

ISO Reconnect AC 6(i) - Success
ISO Reconnect AC 6(ii) - Success

6 months agobtio: Add support for setsockopt (BT_IO_OPT_BASE)
Silviu Florian Barbulescu [Thu, 25 May 2023 15:34:50 +0000 (18:34 +0300)]
btio: Add support for setsockopt (BT_IO_OPT_BASE)

This adds btio support for setting the BT_IO_OPT_BASE socket option.

6 months agolib: Add macro definitions for BAP broadcast source support
Silviu Florian Barbulescu [Thu, 25 May 2023 15:34:48 +0000 (18:34 +0300)]
lib: Add macro definitions for BAP broadcast source support

This adds macro definitions for BAP broadcast source support.

6 months agomonitor: Decode broadcast bits of MGMT settings
Silviu Florian Barbulescu [Thu, 25 May 2023 15:34:49 +0000 (18:34 +0300)]
monitor: Decode broadcast bits of MGMT settings

This adds bits for broadcast support to mgmt_settings_table.

6 months agodoc: Update Docs for BAP broadcast source
Silviu Florian Barbulescu [Thu, 25 May 2023 15:34:47 +0000 (18:34 +0300)]
doc: Update Docs for BAP broadcast source

This adds broadcast properties to the SetConfiguration method and
bits for Broadcast support to the Supported_Settings bitmask.

6 months agomonitor: Print process information
Luiz Augusto von Dentz [Thu, 25 May 2023 20:30:42 +0000 (13:30 -0700)]
monitor: Print process information

This prints the process information when available:

bluetoothd[35]: @ MGMT Command: Rea.. (0x0001) plen 0  {0x0001}
@ MGMT Event: Command Complete (0x0001) plen 6         {0x0001}
    Read Management Version Information (0x0001) plen 3

6 months agomonitor: Add latency information per channel
Luiz Augusto von Dentz [Tue, 23 May 2023 20:48:05 +0000 (13:48 -0700)]
monitor: Add latency information per channel

This attempts to print latency information per channel in addition to
per connection/handle:

> HCI Event: Number of Completed Packets (0x13) plen 5
        Num handles: 1
        Handle: 256 Address: XX:XX:XX:XX:XX:XX
        Count: 1
        Latency: 15 msec (3-39 msec ~18 msec)
        Channel: 68 [PSM 25 mode Basic (0x00)] {chan 2}
        Channel Latency: 15 msec (6-35 msec ~18 msec)

6 months agoiso-tester: Make QoS parameters reflect the tests names
Luiz Augusto von Dentz [Tue, 23 May 2023 17:47:09 +0000 (10:47 -0700)]
iso-tester: Make QoS parameters reflect the tests names

AC 1 + 2 tests shall use their respective QoS parameters.

6 months agoiso-tester: Add tests for AC 1 + 2
Pauli Virtanen [Sun, 21 May 2023 15:27:38 +0000 (15:27 +0000)]
iso-tester: Add tests for AC 1 + 2

Add tests connecting two CIS using different CIG_ID, with fixed and
auto-allocated IDs.

ISO AC 1 + 2 - Success
ISO AC 1 + 2 CIG 0x01/0x02 - Success

The CIS are connected sequentially so that the first is closed after the
second is connected. In the auto/auto case the kernel shall pick a new
CIG_ID since the first CIG_ID is no longer in a configurable state.

6 months agobtdev: report right reason for local Disconnect complete
Pauli Virtanen [Sun, 21 May 2023 15:27:37 +0000 (15:27 +0000)]
btdev: report right reason for local Disconnect complete

Disconnect initiated by local host should get Connection Terminated by
Local Host (0x16) as termination reason.

6 months agobtdev: support multiple CIG
Pauli Virtanen [Sun, 21 May 2023 15:27:36 +0000 (15:27 +0000)]
btdev: support multiple CIG

Add support for more than one CIG simultaneously.

6 months agoshared/tester: retain test failure status
Pauli Virtanen [Sun, 21 May 2023 15:27:35 +0000 (15:27 +0000)]
shared/tester: retain test failure status

If a test has called tester_test_failed, consider the test failed, even
if the test also called tester_test_passed/abort.

This avoids reporting success for misbehaving tests that call the
status report functions multiple times.

6 months agoiso-tester: always use DEFER_SETUP for multiple CIS in same CIG
Pauli Virtanen [Sun, 21 May 2023 15:27:34 +0000 (15:27 +0000)]
iso-tester: always use DEFER_SETUP for multiple CIS in same CIG

There is a race between multiple connect() for CIS in the same CIG.
connect() will both reconfigure the CIG and connect the CIS, but CIG
cannot be reconfigured once one CIS has already connected.  That these
tests pass currently relies on some timing/event ordering in the
emulator.

Connecting multiple CIS in same CIG is meant to be done using
DEFER_SETUP, so change the tests to use it, so we test the intended
usage.

6 months agomonitor: Add latency when decoding BT_HCI_EVT_NUM_COMPLETED_PACKETS
Luiz Augusto von Dentz [Thu, 18 May 2023 23:14:49 +0000 (16:14 -0700)]
monitor: Add latency when decoding BT_HCI_EVT_NUM_COMPLETED_PACKETS

This adds latency, min-max, and median information when decoding
BT_HCI_EVT_NUM_COMPLETED_PACKETS so it works similarly to --analyze:

> HCI Event: Number of Completed Packets (0x13) plen 5
        Num handles: 1
        Handle: 256 Address: XX:XX:XX:XX:XX:XX
        Count: 1
        Latency: 23 msec (2-66 msec ~19 msec)

6 months agomonitor: Fix not parsing BT_HCI_EVT_NUM_COMPLETED_PACKETS properly
Luiz Augusto von Dentz [Thu, 18 May 2023 16:53:12 +0000 (09:53 -0700)]
monitor: Fix not parsing BT_HCI_EVT_NUM_COMPLETED_PACKETS properly

BT_HCI_EVT_NUM_COMPLETED_PACKETS may contain multiple handles but the
code was just parsing the very first one.

6 months agomonitor: Fix using PACKET_FILTER_SHOW_SCO_DATA for ISO packets
Luiz Augusto von Dentz [Wed, 17 May 2023 21:27:14 +0000 (14:27 -0700)]
monitor: Fix using PACKET_FILTER_SHOW_SCO_DATA for ISO packets

This fixes the uses of PACKET_FILTER_SHOW_SCO_DATA for ISO packets and
introduce a dedicated flag for it in the form of
PACKET_FILTER_SHOW_ISO_DATA which can be enabled with use of -I/--iso.

6 months agotools/test-runner: add option to start Pipewire inside the VM
Pauli Virtanen [Sat, 13 May 2023 16:08:37 +0000 (16:08 +0000)]
tools/test-runner: add option to start Pipewire inside the VM

Add option for launching Pipewire inside the VM to serve Bluetooth
endpoints, which can be used in tests.

Make the option to optionally take path to the audio daemon, so e.g.
Pulseaudio support can be added later.

6 months agotest-runner: revert udevd and audio support
Pauli Virtanen [Sat, 13 May 2023 16:08:36 +0000 (16:08 +0000)]
test-runner: revert udevd and audio support

Tests running inside the VM don't need access to sound cards running on
the host.

This reverts commit 91a48af52efb0751fab396b2b9026c9186b10b88
This reverts commit e20e7e0b05c7edb74255c9b092916ac5bb99c97f

6 months agomain: Rework config option parsing
Luiz Augusto von Dentz [Tue, 16 May 2023 17:05:05 +0000 (10:05 -0700)]
main: Rework config option parsing

This rework config option parsing adding helper function to make it
simpler to parse new options.

6 months agoadmin: Mark driver as experimental
Luiz Augusto von Dentz [Tue, 16 May 2023 17:12:19 +0000 (10:12 -0700)]
admin: Mark driver as experimental

This uses the btd_profile.experimental to mark the driver as
experimental.

6 months agoadapter: Add support for experimental flag
Luiz Augusto von Dentz [Tue, 16 May 2023 17:33:24 +0000 (10:33 -0700)]
adapter: Add support for experimental flag

This adds experimental field to btd_adapter_driver so the plugin can
indicate drivers that depends on experimental to be enabled.

6 months agoplugin: Treat -ENOTSUP as -ENOSYS
Luiz Augusto von Dentz [Mon, 15 May 2023 21:02:33 +0000 (14:02 -0700)]
plugin: Treat -ENOTSUP as -ENOSYS

If plugin .init returns -ENOTSUP treat it as the system doesn't
support the driver since that is the error returned by
btd_profile_register when experimental is disabled.

6 months agovcp: Mark driver as experimental
Luiz Augusto von Dentz [Mon, 15 May 2023 21:01:28 +0000 (14:01 -0700)]
vcp: Mark driver as experimental

This uses the btd_profile.experimental to mark the driver as
experimental.

6 months agocsip: Mark driver as experimental
Luiz Augusto von Dentz [Mon, 15 May 2023 20:51:15 +0000 (13:51 -0700)]
csip: Mark driver as experimental

This uses the btd_profile.experimental to mark the driver as
experimental.

6 months agobass: Mark driver as experimental
Luiz Augusto von Dentz [Mon, 15 May 2023 20:50:47 +0000 (13:50 -0700)]
bass: Mark driver as experimental

This uses the btd_profile.experimental to mark the driver as
experimental.

6 months agobap: Mark driver as experimental
Luiz Augusto von Dentz [Mon, 15 May 2023 20:49:27 +0000 (13:49 -0700)]
bap: Mark driver as experimental

This uses the btd_profile.experimental to mark the driver as
experimental.

6 months agoprofile: Add support for experimental flag
Luiz Augusto von Dentz [Mon, 15 May 2023 20:22:51 +0000 (13:22 -0700)]
profile: Add support for experimental flag

This adds experimental field to btd_profile so the plugin can indicate
drivers that depends on experimental to be enabled.

6 months agoclient/player: Add codec as parameter to endpoint.presets
Luiz Augusto von Dentz [Thu, 11 May 2023 23:43:34 +0000 (16:43 -0700)]
client/player: Add codec as parameter to endpoint.presets

This changes endpoint.presets command to take codec as parameter.

6 months agoclient/player: Fix not checking for SupportedUUIDs
Luiz Augusto von Dentz [Thu, 11 May 2023 20:23:40 +0000 (13:23 -0700)]
client/player: Fix not checking for SupportedUUIDs

When registering an endpoint it should always check for SupportedUUIDs.

6 months agoclient/player: Add support to Max Transports in endpoint.register
Luiz Augusto von Dentz [Thu, 16 Mar 2023 23:33:07 +0000 (16:33 -0700)]
client/player: Add support to Max Transports in endpoint.register

[bluetooth]# endpoint.register 00002bc9-0000-1000-8000-00805f9b34fb 0x06
[/local/endpoint/ep0] Auto Accept (yes/no): y
[/local/endpoint/ep0] Max Transports (auto/value): 1
[/local/endpoint/ep0] CIG (auto/value): a
[/local/endpoint/ep0] CIS (auto/value): a

6 months agoshared/bap: Fix not sending ASE Receiver Stop Ready
Luiz Augusto von Dentz [Wed, 10 May 2023 23:54:54 +0000 (16:54 -0700)]
shared/bap: Fix not sending ASE Receiver Stop Ready

This fixes not sending ASE Receiver Stop Ready if stream is on disabling
state when CIS is disconnected.

Fixes: https://github.com/bluez/bluez/issues/516

6 months agoclient/player: Fix crashes accessing metadata
Luiz Augusto von Dentz [Wed, 10 May 2023 23:29:55 +0000 (16:29 -0700)]
client/player: Fix crashes accessing metadata

If metadata is not set the respective iovec is left NULL so it needs to
be checked before accessing its fields.

6 months agomesh: Update the behavior of --io option
Inga Stotland [Fri, 5 May 2023 19:39:31 +0000 (12:39 -0700)]
mesh: Update the behavior of --io option

This aligns the behavior of command line option --io to
add new "auto" value and modify the behavior of "generic"
value:

*auto* - Use first available controller: via MGMT interface
if kernel supports it, otherwise, via raw HCI socket (i.e.,
default to *generic*).

*generic:[hci]<index>* - Use generic HCI io on interface hci<index>

The default value is now *auto*, whereas *generic* is used
only if the specific HCI controller is explicitly specified.

6 months agomonitor/intel: Skip packet/error counters if 0
Luiz Augusto von Dentz [Tue, 9 May 2023 21:07:42 +0000 (14:07 -0700)]
monitor/intel: Skip packet/error counters if 0

This skips printing TLVs related to packet/error count if they are 0 and
also update the missing TLVs:

> HCI Event: Vendor (0xff) plen 188
        Vendor Prefix (0x8780)
      Intel Extended Telemetry (0x03)
        Extended event type (0x01): Perform Stats (0x05)
        ACL connection handle (0x4a): 0x0100
        Rx HEC errors (0x4b): 3
        Packets from host (0x4d): 375
        Tx packets (0x4e): 375
        Tx packets 0 retries (0x4f): 354
        Tx packets 1 retries (0x50): 20
        Tx packets 3 retries (0x52): 1
        Tx 3DH5 packets (0x5c): 375
        Rx packets (0x5d): 400
        ACL link throughput (bps) (0x5e): 533419
        ACL max packet latency (us) (0x5f): 36875
        ACL avg packet latency (us) (0x60): 19441
        ACL RX RSSI moving avg (0x61): 65329
        ACL RX SNR Bad Margin Counter (0x62): 1M 59 2M 0 3M 0
        ACL RX RSSI Bad Counter (0x63): 1M 1711 2M 0 3M 0
        ACL TX RSSI Bad Counter (0x64): 1M 1024 2M 0 3M 0

6 months agomonitor/intel: Fix not skipping unknown TLV types
Luiz Augusto von Dentz [Tue, 9 May 2023 20:59:42 +0000 (13:59 -0700)]
monitor/intel: Fix not skipping unknown TLV types

The code was stopping at first time it detected an unknown TLV type when
it could continue:

> HCI Event: Vendor (0xff) plen 82
        Vendor Prefix (0x8780)
      Intel Extended Telemetry (0x03)
        Extended event type (0x01): Audio Link Quality Report Type (0x05)
        Unknown extended subevent 0x81
        01 01 05 81 04 88 13 00 00 82 10 6a e6 6c 00 00  ...........j.l..
        00 00 00 4b 45 53 00 00 00 00 00 83 04 00 00 00  ...KES..........
        00 84 04 01 03 07 19 85 04 3f 08 00 00 86 08 00  .........?......
        00 00 00 00 00 00 00 87 04 00 00 00 00 88 04 00  ................
        00 00 00 89 04 00 00 00 00 8a 04 b9 49 0c 00     ............I..

So this changes it to:

> HCI Event: Vendor (0xff) plen 82
        Vendor Prefix (0x8780)
      Intel Extended Telemetry (0x03)
        Extended event type (0x01): Audio Link Quality Report Type (0x05)
        Unknown extended subevent 0x81
        88 13 00 00                                      ....
        Unknown extended subevent 0x82
        04 97 6c 00 00 00 00 00 68 44 53 00 00 00 00 00  ..l.....hDS.....
        Unknown extended subevent 0x83
        00 00 00 00                                      ....
        Unknown extended subevent 0x84
        01 03 07 19                                      ....
        Unknown extended subevent 0x85
        3a 08 00 00                                      :...
        Unknown extended subevent 0x86
        00 00 00 00 00 00 00 00                          ........
        Unknown extended subevent 0x87
        00 00 00 00                                      ....
        Unknown extended subevent 0x88
        00 00 00 00                                      ....
        Unknown extended subevent 0x89
        00 00 00 00                                      ....
        Unknown extended subevent 0x8a
        9f 1a 2f 00                                      ../.

6 months agomonitor: Fix misaligment errors
Luiz Augusto von Dentz [Fri, 5 May 2023 20:20:25 +0000 (13:20 -0700)]
monitor: Fix misaligment errors

This fixes the following errors:

monitor/packet.c:11968:27: runtime error: member access within
misaligned address 0x565448026d55 for type
'const struct monitor_l2cap_hdr', which requires 2 byte alignment
monitor/packet.c:11968:4: runtime error: member access within
misaligned address 0x565448026d55 for type
'const struct monitor_l2cap_hdr', which requires 2 byte alignment

6 months agomonitor/att: Attempt to insert discovered attributes
Luiz Augusto von Dentz [Fri, 5 May 2023 00:07:44 +0000 (17:07 -0700)]
monitor/att: Attempt to insert discovered attributes

This attempts to insert discovered attributes into monitor gatt_db
instance if their respective discover procedures are used which enables
decoding traces injected by user via unit testing:

> sudo unit/test-bap -m -s "34

= test-bap: BAP/UCL/SCC/BV-034-C [UCL SNK Config Codec, VS] - run
> test-bap: User Data RX
      ATT: Read Request (0x0a) len 2
        Handle: 0x0003 Type: Sink PAC (0x2bc9)
< test-bap: User Data TX
      ATT: Read Response (0x0b) len 8
        Handle: 0x0003 Type: Sink PAC (0x2bc9)
        Value: 01ff010001000000
          Number of PAC(s): 1
          PAC #0:
            Codec: Vendor specific (0xff)
            Codec Company ID: Nokia Mobile Phones (0x0001)
            Codec Vendor ID: 0x0001
> test-bap: User Data RX
      ATT: Read Request (0x0a) len 2
        Handle: 0x0006 Type: Sink Audio Locations (0x2bca)
< test-bap: User Data TX
      ATT: Read Response (0x0b) len 4
        Handle: 0x0006 Type: Sink Audio Locations (0x2bca)
        Value: 03000000
           Location: 0x00000003
              Front Left (0x00000001)
              Front Right (0x00000002)
> test-bap: User Data RX
      ATT: Read Request (0x0a) len 2
        Handle: 0x0009 Type: Source PAC (0x2bcb)
< test-bap: User Data TX
      ATT: Read Response (0x0b) len 8
        Handle: 0x0009 Type: Source PAC (0x2bcb)
        Value: 01ff010001000000
          Number of PAC(s): 1
          PAC #0:
            Codec: Vendor specific (0xff)
            Codec Company ID: Nokia Mobile Phones (0x0001)
            Codec Vendor ID: 0x0001
> test-bap: User Data RX
      ATT: Read Request (0x0a) len 2
        Handle: 0x000c Type: Source Audio Locations (0x2bcc)
< test-bap: User Data TX
      ATT: Read Response (0x0b) len 4
        Handle: 0x000c Type: Source Audio Locations (0x2bcc)
        Value: 03000000
           Location: 0x00000003
              Front Left (0x00000001)
              Front Right (0x00000002)
> test-bap: User Data RX
      ATT: Read Request (0x0a) len 2
        Handle: 0x000f Type: Available Audio Contexts (0x2bcd)
< test-bap: User Data TX
      ATT: Read Response (0x0b) len 4
        Handle: 0x000f Type: Available Audio Contexts (0x2bcd)
        Value: ff0f0e00
          Sink Context: 0x0fff
            Unspecified (0x0001)
            Conversational (0x0002)
            Media (0x0004)
            Game (0x0008)
            Instructional (0x0010)
            Voice Assistants (0x0020)
            Live (0x0040)
            Sound Effects (0x0080)
            Notifications (0x0100)
            Ringtone (0x0200)
            Alerts (0x0400)
            Emergency alarm (0x0800)
          Source Context: 0x000e
            Conversational (0x0002)
            Media (0x0004)
            Game (0x0008)
> test-bap: User Data RX
      ATT: Read Request (0x0a) len 2
        Handle: 0x0012 Type: Supported Audio Contexts (0x2bce)
< test-bap: User Data TX
      ATT: Read Response (0x0b) len 4
        Handle: 0x0012 Type: Supported Audio Contexts (0x2bce)
        Value: ff0f0e00
          Sink Context: 0x0fff
            Unspecified (0x0001)
            Conversational (0x0002)
            Media (0x0004)
            Game (0x0008)
            Instructional (0x0010)
            Voice Assistants (0x0020)
            Live (0x0040)
            Sound Effects (0x0080)
            Notifications (0x0100)
            Ringtone (0x0200)
            Alerts (0x0400)
            Emergency alarm (0x0800)
          Source Context: 0x000e
            Conversational (0x0002)
            Media (0x0004)
            Game (0x0008)
> test-bap: User Data RX
      ATT: Read Request (0x0a) len 2
        Handle: 0x0016 Type: Sink ASE (0x2bc4)
< test-bap: User Data TX
      ATT: Read Response (0x0b) len 2
        Handle: 0x0016 Type: Sink ASE (0x2bc4)
        Value: 0100
            ASE ID: 1
            State: Idle (0x00)
> test-bap: User Data RX
      ATT: Write Request (0x12) len 4
        Handle: 0x0017
          Data: 0100
< test-bap: User Data TX
      ATT: Write Response (0x13) len 0
> test-bap: User Data RX
      ATT: Read Request (0x0a) len 2
        Handle: 0x0019 Type: Sink ASE (0x2bc4)
< test-bap: User Data TX
      ATT: Read Response (0x0b) len 2
        Handle: 0x0019 Type: Sink ASE (0x2bc4)
        Value: 0200
            ASE ID: 2
            State: Idle (0x00)
> test-bap: User Data RX
      ATT: Write Request (0x12) len 4
        Handle: 0x001a
          Data: 0100
< test-bap: User Data TX
      ATT: Write Response (0x13) len 0
> test-bap: User Data RX
      ATT: Read Request (0x0a) len 2
        Handle: 0x001c Type: Source ASE (0x2bc5)
< test-bap: User Data TX
      ATT: Read Response (0x0b) len 2
        Handle: 0x001c Type: Source ASE (0x2bc5)
        Value: 0300
            ASE ID: 3
            State: Idle (0x00)
> test-bap: User Data RX
      ATT: Write Request (0x12) len 4
        Handle: 0x001d
          Data: 0100
< test-bap: User Data TX
      ATT: Write Response (0x13) len 0
> test-bap: User Data RX
      ATT: Read Request (0x0a) len 2
        Handle: 0x001f Type: Source ASE (0x2bc5)
< test-bap: User Data TX
      ATT: Read Response (0x0b) len 2
        Handle: 0x001f Type: Source ASE (0x2bc5)
        Value: 0400
            ASE ID: 4
            State: Idle (0x00)
> test-bap: User Data RX
      ATT: Write Request (0x12) len 4
        Handle: 0x0020
          Data: 0100
< test-bap: User Data TX
      ATT: Write Response (0x13) len 0
> test-bap: User Data RX
      ATT: Write Request (0x12) len 4
        Handle: 0x0023
          Data: 0100
< test-bap: User Data TX
      ATT: Write Response (0x13) len 0
> test-bap: User Data RX
      ATT: Write Command (0x52) len 13
        Handle: 0x0022 Type: ASE Control Point (0x2bc6)
          Data: 0101030202ff0100010000
            Opcode: Codec Configuration (0x01)
            Number of ASE(s): 1
            ASE: #0
            ASE ID: 0x03
            Target Latency: Balance Latency/Reliability (0x02)
            PHY: 0x02
            LE 2M PHY (0x02)
            Codec: Vendor specific (0xff)
            Codec Company ID: Nokia Mobile Phones (0x0001)
            Codec Vendor ID: 0x0001
< test-bap: User Data TX
      ATT: Handle Value Notification (0x1b) len 7
        Handle: 0x0022 Type: ASE Control Point (0x2bc6)
          Data: 0101030000
            Opcode: Codec Configuration (0x01)
            Number of ASE(s): 1
            ASE: #0
            ASE ID: 0x03
            ASE Response Code: Success (0x00)
            ASE Response Reason: None (0x00)
< test-bap: User Data TX
      ATT: Handle Value Notification (0x1b) len 27
        Handle: 0x001c Type: Source ASE (0x2bc5)
          Data: 03010102010a00204e00409c00204e00409c00ff0100010000
            ASE ID: 3
            State: Codec Configured (0x01)
            Framing: Unframed PDUs not supported (0x01)
            PHY: 0x02
            LE 2M PHY preffered (0x02)
            RTN: 1
            Max Transport Latency: 10
            Presentation Delay Min: 20000 us
            Presentation Delay Max: 40000 us
            Preferred Presentation Delay Min: 20000 us
            Preferred Presentation Delay Max: 40000 us
            Codec: Vendor specific (0xff)
            Codec Company ID: Nokia Mobile Phones (0x0001)
            Codec Vendor ID: 0x0001

6 months agoprofiles: Add initial code for BASS plugin
Iulia Tanasescu [Fri, 5 May 2023 08:29:43 +0000 (11:29 +0300)]
profiles: Add initial code for BASS plugin

This adds initial code for BASS plugin.

6 months agoshared/bass: Add initial code for handling BASS
Iulia Tanasescu [Fri, 5 May 2023 08:29:42 +0000 (11:29 +0300)]
shared/bass: Add initial code for handling BASS

This adds initial code for Broadcast Audio Scan Service.

6 months agoshared/util: Add iovec helpers
Iulia Tanasescu [Fri, 5 May 2023 08:29:41 +0000 (11:29 +0300)]
shared/util: Add iovec helpers

This adds iovec helper functions for handling byteorder and alignment
in place.

6 months agoshared/att-types: Add BT_ERROR_WRITE_REQUEST_REJECTED error code
Iulia Tanasescu [Fri, 5 May 2023 08:29:40 +0000 (11:29 +0300)]
shared/att-types: Add BT_ERROR_WRITE_REQUEST_REJECTED error code

This adds Write Request Rejected Common Profile and Service
Error Code.

6 months agolib/uuid: Add BASS UUIDs
Iulia Tanasescu [Fri, 5 May 2023 08:29:39 +0000 (11:29 +0300)]
lib/uuid: Add BASS UUIDs

This adds BASS UUIDs which will be used by Basic Audio Profile.

6 months agoshared/shell: Fix smatch warning
Luiz Augusto von Dentz [Mon, 1 May 2023 22:42:49 +0000 (15:42 -0700)]
shared/shell: Fix smatch warning

This fixes the following warning:

src/shared/shell.c:615:21: warning: non-ANSI function declaration of
function 'bt_shell_usage'

6 months agoshared/shell: Fix not releasing prompt
Luiz Augusto von Dentz [Mon, 1 May 2023 19:59:57 +0000 (12:59 -0700)]
shared/shell: Fix not releasing prompt

This fixes not releasing prompt when queueing a line to be executed
since it can be considered as user input if the init script is
attempting to enter it as response to prompt input.