platform/upstream/bluez.git
6 months agoadapter: Update ConnectDevice documentation
Simon Mikuda [Mon, 31 Jul 2023 04:12:29 +0000 (06:12 +0200)]
adapter: Update ConnectDevice documentation

6 months agoadapter: Be able to use ConnectDevice for discovered devices
Simon Mikuda [Mon, 31 Jul 2023 04:12:28 +0000 (06:12 +0200)]
adapter: Be able to use ConnectDevice for discovered devices

This can be useful when you want to specify trasport type for already
paired device (e.g. use LE transport for dual mode device).

6 months agomonitor/analyze: Fix not calculating latency for ISO/SCO packets
Luiz Augusto von Dentz [Fri, 28 Jul 2023 21:53:13 +0000 (14:53 -0700)]
monitor/analyze: Fix not calculating latency for ISO/SCO packets

ISO/SCO packets latency was not being calculated because no connection was
being assigned to them.

6 months agomonitor/analyze: Fix not dequeing TX packet properly
Luiz Augusto von Dentz [Fri, 28 Jul 2023 21:48:43 +0000 (14:48 -0700)]
monitor/analyze: Fix not dequeing TX packet properly

num_completed_packets_evt contain a count for how many packets have been
completed per handle.

6 months agomonitor: Fix not calculating latency for ISO/SCO packets
Luiz Augusto von Dentz [Fri, 28 Jul 2023 21:26:13 +0000 (14:26 -0700)]
monitor: Fix not calculating latency for ISO/SCO packets

ISO/SCO packets latency was not being calculated because no connection
was assigned to them.

6 months agomonitor: Fix not dequeing TX packet properly
Luiz Augusto von Dentz [Fri, 28 Jul 2023 21:24:41 +0000 (14:24 -0700)]
monitor: Fix not dequeing TX packet properly

num_completed_packets_evt contain a count for how many packets have been
completed per handle.

6 months agomonitor: Consolidate code around latency calculation
Luiz Augusto von Dentz [Thu, 27 Jul 2023 23:55:25 +0000 (16:55 -0700)]
monitor: Consolidate code around latency calculation

This move latency calculations to a helper function called
packet_latency_add so it can get reused by the likes of l2cap.c and
analyze.c

6 months agomonitor: Update documentation
Luiz Augusto von Dentz [Fri, 28 Jul 2023 00:16:58 +0000 (17:16 -0700)]
monitor: Update documentation

This updates the documentation to mention gnuplot usage.

6 months agomonitor: Use gnuplot to plot graph of Latency-Packets
Luiz Augusto von Dentz [Wed, 26 Jul 2023 22:14:26 +0000 (15:14 -0700)]
monitor: Use gnuplot to plot graph of Latency-Packets

This make use of gnuplot when using -a/--analyze to plot a graph of
Latency-Packets:

  Found BR-ACL connection with handle 256
        Address: XX:XX:XX:XX:XX:XX (Sony Home Entertainment&Sound Products Inc)
        60 RX packets
        22548 TX packets
        22547 TX completed packets
        3 msec min latency
        73 msec max latency
        11 msec median latency
        6 octets TX min packet size
        850 octets TX max packet size
        847 octets TX median packet size

  10000 +-+----------------------------------------------------------------+
         +|      ++                                                        |
         +|      ||+                                       Packets +-----+ |
         +|      |||                                                       |
   1000 +-|      |||++                                                     |
         +|      |||||  +                                                  |
         +|      |||||++|                                                  |
         +|      ||||||||+++                                               |
    100 +-|      |||||||||||  +                                            |
         +|      |||||||||||+++  +                                         |
         +|      ||||||||||||||  |                                         |
         +| ++   ||||||||||||||++|+                                        |
          | ||   |||||||||||||||||++                                       |
     10 +-| ||   |||||||||||||||||||+                                      |
         +| ||   ||||||||||||||||||||  +                                   |
         +| || ++||||||||||||||||||||++|++++       +                       |
          | || |||||||||||||||||||||||||||||       |                       |
      1 +-| ||+||||||||||||||||||||||||||||| +  +  |                 +     |
         ++----------------------------------------------------------------+
          +       +       +       +        +       +       +       +       +
          0       10      20      30       40      50      60      70      80
                                    Latency (ms)

6 months agogatt-client: Add read-only handles to dbus
Simon Mikuda [Fri, 28 Jul 2023 04:49:44 +0000 (06:49 +0200)]
gatt-client: Add read-only handles to dbus

This can be usefull when mapping names for services and characteristics
to their handle numbers.

6 months agoadvertising: Fix peripheral adverts when Discoverable = false
Simon Mikuda [Fri, 28 Jul 2023 10:56:04 +0000 (12:56 +0200)]
advertising: Fix peripheral adverts when Discoverable = false

There is a problem with this configuration: Type = peripheral,
Discoverable = false and Adapter is discoverable

In this state device will start advertise discoverable advertisements
even when user wanted non-discoverable advertisements.

This change will add empty Flags when "Discoverable" parameter is set.

6 months agoadapter: Fix generating IRK for adapter with privacy enabled
Simon Mikuda [Fri, 28 Jul 2023 04:45:56 +0000 (06:45 +0200)]
adapter: Fix generating IRK for adapter with privacy enabled

When root folder for adapter doesn't exist we will get this runtime error:
src/adapter.c:generate_and_write_irk() Unable set contents for
 /var/lib/bluetooth/00:00:00:00:00:00/identity:
 (Failed to create file “/var/lib/bluetooth/00:00:00:00:00:00/identity.EKQ581”:
 No such file or directory)

6 months agobap: Fix memory leaks
Luiz Augusto von Dentz [Wed, 26 Jul 2023 19:36:21 +0000 (12:36 -0700)]
bap: Fix memory leaks

This fixes the following memory leaks on exit:

g32 bytes in 1 blocks are definitely lost in loss record 170 of 800
g   at 0x484182F: malloc (vg_replace_malloc.c:431)
g   by 0x47C942: util_malloc (util.c:46)
g   by 0x47AD6A: queue_new (queue.c:47)
g   by 0x379CB6: bap_data_new (bap.c:1565)
g   by 0x379E24: bap_probe (bap.c:1757)
g   by 0x4048F3: service_probe (service.c:153)
g   by 0x4190D5: probe_service (device.c:4817)
g   by 0x41927D: dev_probe (device.c:4836)
g   by 0x403918: btd_profile_foreach (profile.c:740)
g   by 0x421861: device_probe_profiles (device.c:4896)
g   by 0x3E5023: probe_devices (adapter.c:4590)
g   by 0x498022F: g_slist_foreach (in /usr/lib64/libglib-2.0.so.0.7600.4)
g
g64 bytes in 2 blocks are definitely lost in loss record 556 of 800
g   at 0x484182F: malloc (vg_replace_malloc.c:431)
g   by 0x47C942: util_malloc (util.c:46)
g   by 0x47AD6A: queue_new (queue.c:47)
g   by 0x379CB6: bap_data_new (bap.c:1565)
g   by 0x37DEA7: bap_adapter_probe (bap.c:1843)
g   by 0x3CDB51: probe_profile (adapter.c:5066)
g   by 0x403918: btd_profile_foreach (profile.c:740)
g   by 0x3F557E: adapter_register (adapter.c:9288)
g   by 0x3F557E: read_info_complete (adapter.c:10186)
g   by 0x480D91: request_complete (mgmt.c:306)
g   by 0x484466: can_read_data (mgmt.c:394)
g   by 0x4ED93F: watch_callback (io-glib.c:157)
g   by 0x496348B: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.7600.4)

6 months agoshared/vcp: Reserve one more handle in VCS for VOCS
Nitin Jadhav [Tue, 25 Jul 2023 13:47:42 +0000 (16:47 +0300)]
shared/vcp: Reserve one more handle in VCS for VOCS

Fix: As per specs, VOCS is a secondary service;
hence it should be included under a primary service VCS.
The current number of handles is increased to accommodate the
included service

6 months agoshared/vcp: Fix issues of audio location and descriptor
Nitin Jadhav [Tue, 25 Jul 2023 13:47:41 +0000 (16:47 +0300)]
shared/vcp: Fix issues of audio location and descriptor

Issues
- Audio output descriptor & location read functions requires code
correction.
- During reading audio location descriptor value was checked
instead of the pointer. DBG statement wrongly accessed value
to print the log that caused the crash.

Fix
- Corrected audio output descriptor read variable
- Corrected the audio location debug printing function
- Allocated the memory as a char pointer to the audio descriptor variable.
- Corrected the audio descriptor pointer checking condition

6 months agoshared/vcp: Fix the crash observed with VOCS
Nitin Jadhav [Tue, 25 Jul 2023 13:47:40 +0000 (16:47 +0300)]
shared/vcp: Fix the crash observed with VOCS

Root cause
- There are two types of database- Remote and Local (rdb and ldb).
- In client mode currently the code was written to access ldb.

Fix
- Correcting it, to access rdb has resolved the problem in VOCS.
- Same correction is done for VCS.

Reported-by: Pauli Virtanen <pav@iki.fi>
6 months agobtmon: Make BIG identifier consistent
Łukasz Rymanowski [Fri, 21 Jul 2023 12:03:20 +0000 (14:03 +0200)]
btmon: Make BIG identifier consistent

Bluetooth spec uses BIG Handle as a BIG identifier.
Btmon sometimes use this and sometimes BIG ID.
This patch makes code consistent

6 months agobtmon: Fix obvious typo
Łukasz Rymanowski [Fri, 21 Jul 2023 12:03:19 +0000 (14:03 +0200)]
btmon: Fix obvious typo

6 months agomonitor: Fix invalid Create BIG Test command
Grzegorz Kolodziejczyk [Fri, 21 Jul 2023 12:03:18 +0000 (14:03 +0200)]
monitor: Fix invalid Create BIG Test command

As per Bluetooth Core 5.4 Vol 4 Part E, 7.8.104,
max pdu is 2 octect long and there is no adv_handle before encyption
flag

6 months agomonitor: Fix adv_handle size in the set info transfer packet
Jakub Tyszkowski [Fri, 21 Jul 2023 12:03:17 +0000 (14:03 +0200)]
monitor: Fix adv_handle size in the set info transfer packet

As per Bluetooth Core 5.4 Vol 4. Part E, 7.8.90,
adv_handle is 1 octet size and not 2.

6 months agoclient: Add bluetoothctl-monitor.1 man page
Luiz Augusto von Dentz [Wed, 19 Jul 2023 20:30:37 +0000 (13:30 -0700)]
client: Add bluetoothctl-monitor.1 man page

This adds bluetoothctl-monitor.rst which is then converted to
bluetoothctl-mgmt.1 using rst2man.

6 months agoclient: Add bluetoothctl-mgmt.1 man page
Luiz Augusto von Dentz [Wed, 19 Jul 2023 20:11:07 +0000 (13:11 -0700)]
client: Add bluetoothctl-mgmt.1 man page

This adds bluetoothctl-mgmt.rst which is then converted to
bluetooth-mgmt.1 using rst2man.

6 months agobtmgmt: Add man page
Luiz Augusto von Dentz [Mon, 17 Jul 2023 23:01:45 +0000 (16:01 -0700)]
btmgmt: Add man page

This adds btmgmt.rst which is then converted to btmgmt.1 using rst2man.

6 months agomidi: Fix build errors
Luiz Augusto von Dentz [Mon, 17 Jul 2023 19:36:15 +0000 (12:36 -0700)]
midi: Fix build errors

This fixes the following build errors:

unit/test-midi.c:541:82: error: function definition is not allowed here
void compare_events_cb(const struct midi_write_parser *parser,
void *user_data) {
 ^
unit/test-midi.c:587:17: error: use of undeclared identifier
'compare_events_cb'; did you mean 'compare_events'?
                                     compare_events_cb, &midi_data);
                                     ^~~~~~~~~~~~~~~~~
                                     compare_events

profiles/midi/midi.c:61:75: error: function definition is not allowed
here
void foreach_cb(const struct midi_write_parser *parser, void *user_data) {
                                                                         ^
profiles/midi/midi.c:78:40: error: use of undeclared identifier 'foreach_cb'
                midi_read_ev(&midi->midi_out, event, foreach_cb, midi);
                                                     ^

6 months agoclient: Add support for mgmt submenu
Luiz Augusto von Dentz [Fri, 14 Jul 2023 22:14:02 +0000 (15:14 -0700)]
client: Add support for mgmt submenu

This moves the functionality of btmgmt into client/mgmt.c so its
commands become available on bluetoothctl via mgmt submenu.

6 months agoiso-tester: Add test for BT_PKT_STATUS sockopt
Luiz Augusto von Dentz [Thu, 13 Jul 2023 22:40:20 +0000 (15:40 -0700)]
iso-tester: Add test for BT_PKT_STATUS sockopt

This adds a test for setting BT_PKT_STATUS sockopt and checks if
BT_SCM_PKT_STATUS is properly received.

6 months agobthost: Add support to set ISO Packet Status
Luiz Augusto von Dentz [Thu, 13 Jul 2023 22:38:28 +0000 (15:38 -0700)]
bthost: Add support to set ISO Packet Status

This adds support to set ISO Packet Status to bthost_send_iso.

6 months agotest-runner: fix behavior when no audio server
Pauli Virtanen [Wed, 12 Jul 2023 21:22:49 +0000 (00:22 +0300)]
test-runner: fix behavior when no audio server

If no audio server, don't pass NULL to printf and parse TESTAUDIO
correctly.

6 months agotest-runner: set non-quiet printk before running tests
Pauli Virtanen [Wed, 12 Jul 2023 21:22:48 +0000 (00:22 +0300)]
test-runner: set non-quiet printk before running tests

It is useful to see WARN_ON etc. messages when running the tests.

The 'quiet' in cmdline suppresses levels >= WARN, so re-enable them
explicitly after boot, so that it is on by default and doesn't need to
be handled in local test scripts.

6 months agoconfigure: Fix check ell path for cross compiling
Rudi Heitbaum [Sat, 1 Jul 2023 04:12:52 +0000 (04:12 +0000)]
configure: Fix check ell path for cross compiling

Use of AC_CHECK_FILE prevents cross compilation.
Instead use test to support cross compiling.

6 months agotest-eir: Run tests using bt_ad
Luiz Augusto von Dentz [Wed, 12 Jul 2023 19:36:37 +0000 (12:36 -0700)]
test-eir: Run tests using bt_ad

This enables the same tests done with eir_data using bt_ad.

6 months agoshared/ad: Make use of util_iov_pull_* to parse data
Luiz Augusto von Dentz [Wed, 12 Jul 2023 19:34:20 +0000 (12:34 -0700)]
shared/ad: Make use of util_iov_pull_* to parse data

This makes use of util_iov_pull_* helpers to parse data.

6 months agoshared/util: Introduce strisutf8
Luiz Augusto von Dentz [Tue, 11 Jul 2023 23:45:07 +0000 (16:45 -0700)]
shared/util: Introduce strisutf8

This introduces strisutf8 which can be used to verify if a string is
encoded using UTF-8 format.

6 months agomain: Remove DEFAULT_SIRK
Luiz Augusto von Dentz [Mon, 10 Jul 2023 22:19:24 +0000 (15:19 -0700)]
main: Remove DEFAULT_SIRK

DEFAULT_SIRK is currently not used.

6 months agoshared/ad: Use util_iov_push_* helpers to generate data
Luiz Augusto von Dentz [Mon, 10 Jul 2023 20:27:34 +0000 (13:27 -0700)]
shared/ad: Use util_iov_push_* helpers to generate data

This makes use of util_iov_push_* helpers to generate the data.

6 months agoadvertising: Fix build warning
Luiz Augusto von Dentz [Mon, 10 Jul 2023 19:28:42 +0000 (12:28 -0700)]
advertising: Fix build warning

This fixes the following warning:

src/advertising.c:942:2: warning: Null pointer passed to 2nd parameter
expecting 'nonnull' [core.NonNullParamChecker]
        memcpy(cp->data + adv_data_len, scan_rsp, scan_rsp_len);
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

6 months agoclient/advetising: Allow use of EA data length
Luiz Augusto von Dentz [Fri, 7 Jul 2023 21:59:24 +0000 (14:59 -0700)]
client/advetising: Allow use of EA data length

The code was supporting a maximum of 25 bytes (31 - 6) to be entered as
advertising data, but in case of EA is used that allows up to 245 bytes
(251 - 6) to be entered.

6 months agoadvertising: Use bt_ad_set_max_len
Luiz Augusto von Dentz [Fri, 7 Jul 2023 21:57:46 +0000 (14:57 -0700)]
advertising: Use bt_ad_set_max_len

This uses bt_ad_set_max_len to properly set the maximum data length of
the bt_ad instances based on what the kernel returns.

6 months agoshared/ad: Fix hardcoding maximum data length
Luiz Augusto von Dentz [Fri, 7 Jul 2023 21:54:56 +0000 (14:54 -0700)]
shared/ad: Fix hardcoding maximum data length

Instances shall not assume BT_AD_MAX_DATA_LEN is always the maximum
length as they could be used with EA which supports bigger length.

6 months agomgmt-tester: Fix tests that consider 31 bytes the max adv lenght
Luiz Augusto von Dentz [Thu, 6 Jul 2023 19:45:17 +0000 (12:45 -0700)]
mgmt-tester: Fix tests that consider 31 bytes the max adv lenght

This fixes a couple of tests that consider 31 bytes the max advertising
length since in case of extended advertising that number is actually
251.

6 months agotest-runner: Add documentation
Luiz Augusto von Dentz [Thu, 6 Jul 2023 23:04:55 +0000 (16:04 -0700)]
test-runner: Add documentation

This adds test-runner.rst documentation with a few examples of how it
can be used to run kernel testers like mgmt-tester and also bluetoothd,
audio and Bluetooth controller plugged in the host system which is quite
useful when trying experimental features such LE Audio, etc.

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.