Claudia Draghicescu [Tue, 8 Aug 2023 11:50:34 +0000 (14:50 +0300)]
client/player: Add broadcast sink endpoint
Added support for broadcast sink registration using the 0x1851 UUID.
Added support for remote endpoint creation when a broadcast source
is discovered.
Added support for creating a local endpoint when the broadcast sink
endpoint was registered from an external application (Pipewire).
To test this feature use the following commands:
[bluetooth]# endpoint.register
00001851-0000-1000-8000-
00805f9b34fb 0x06
[bluetooth]# scan on
[NEW] Endpoint /org/bluez/hci0/dev_XX_XX_XX_XX_XX_XX/pac_bcast0
[bluetooth]# endpoint.config
/org/bluez/hci0/dev_XX_XX_XX_XX_XX_XX/pac_bcast0
/local/endpoint/ep0 16_2_1
Pauli Virtanen [Sat, 5 Aug 2023 12:29:07 +0000 (15:29 +0300)]
iso-tester: test busy CIG error does not drop existing connections
A second connection made with same CIG while the CIG is busy, shall not
disconnect the first already existing connection.
Add test for this:
ISO Connect2 Busy CIG 0x01 - Success/Invalid
This was the original intent of "ISO Connect2 CIG 0x01 -
Success/Invalid", but the busy check should not be made synchronously in
connect() (to maintain ordering with Remove CIG etc), but must be done
in hci_sync. So the test needs to check the error async and explictly
that the first conn is not dropped.
Pauli Virtanen [Sat, 5 Aug 2023 12:29:06 +0000 (15:29 +0300)]
btdev: fix CIG ID on Set CIG Parameters error response
Set CIG Parameters shall return correct CIG ID in Command_Complete also
when it errors.
Simon Mikuda [Sun, 6 Aug 2023 08:01:09 +0000 (10:01 +0200)]
a2dp: Expose "Key missing" error
This error is not expected and retries will likely end up with same error.
Simon Mikuda [Sun, 6 Aug 2023 08:01:08 +0000 (10:01 +0200)]
error: Add "Invalid exchange" mapping
This error is returned on this event:
> HCI Event: Auth Complete (0x06) plen 3
Status: PIN or Key Missing (0x06)
Handle: 11 Address: 00:00:00:00:00:00 (OUI 00-00-00)
Luiz Augusto von Dentz [Mon, 7 Aug 2023 21:45:34 +0000 (14:45 -0700)]
monitor: Plot RX information with -a/--analyze
This attempts to plot the RX information just as TX:
Found BR-ACL connection with handle 256
Address: XX:XX:XX:XX:XX:XX
RX packets: 60/60
RX Latency: 0-39040 msec (~20294 msec)
RX size: 6-344 octets (~34 octets)
RX speed: ~0 Kb/s
100 +-+------------------------------------------------------------------+
+| |
+| RX +-----+ |
+| |
+| |
+| |
| |
| |
10 +-| |
+| |
+| |
+| |
+| |
+| |
| |
| |
1 +-| + + + |
+| | | | |
++------------------------------------------------------------------+
+ + + + + + + + +
0 5000 10000 15000 20000 25000 30000 35000 40000
Latency (ms)
TX packets: 22548/22547
TX Latency: 3-73 msec (~11 msec)
TX size: 6-850 octets (~847 octets)
TX speed: ~568 Kb/s
Luiz Augusto von Dentz [Fri, 4 Aug 2023 21:51:54 +0000 (14:51 -0700)]
iso-tester: Fix test ISO Connect2 CIG 0x01 - Success/Invalid
This test shall succeed rather than fail as this appears to be a bug in
the kernel code preventing Set CIG Parameters to work properly when
there are concurrent tasks only one CIS is being programmed.
Pauli Virtanen [Tue, 1 Aug 2023 16:38:42 +0000 (19:38 +0300)]
iso-tester: add tests checking Remove CIG is emitted
Kernel should send LE Remove CIG after all CIS are shut down. Add tests
checking this, closing either immediately or after waiting connection to
complete.
ISO Defer Close - Success
ISO Connect Close - Success
ISO Defer Wait Close - Success
ISO Connect Wait Close - Success
Pauli Virtanen [Tue, 1 Aug 2023 16:38:41 +0000 (19:38 +0300)]
iso-tester: test with large CIS_ID and invalid CIG_ID/CIS_ID
Add test with a large CIS_ID and multiple CIS so it hits an error
condition in current kernels (which is why the AC configuration is
used).
Add tests for invalid configurations with bad or duplicate IDs, and for
trying to connect two CIS in same CIG without BT_DEFER_SETUP.
ISO QoS CIG 0xF0 - Invalid
ISO QoS CIS 0xF0 - Invalid
ISO Connect2 CIG 0x01 - Success/Invalid
ISO AC 6(ii) CIS 0xEF/auto - Success
ISO AC 6(ii) CIS 0xEF/0xEF - Invalid
Pauli Virtanen [Tue, 1 Aug 2023 16:38:40 +0000 (19:38 +0300)]
sco-tester: test local and remote disconnecting simultaneously
Demonstrate a kernel race condition when remote side disconnects at the
same time as local side tries to cancel the connection. I.e.
[controller] > HCI Synchronous Connect Complete
[controller] > HCI Disconnection Complete (from remote)
[user] shutdown(sco_socket)
[kernel] hci_conn_abort(SCO handle)
[kernel] > HCI Create Connection Cancel
[kernel] < HCI Synchronous Connect Complete
[kernel] < HCI Disconnect Complete
[controller] < HCI Create Connection Cancel
[controller] > HCI Command Status (Create Connection Cancel)
[kernel] < HCI Command Status (Create Connection Cancel)
and then we get BUG: KASAN: slab-use-after-free in hci_conn_failed when
hci_conn_abort tries to delete the same connection a second time.
This type of crash is probably not limited to the sequence here, but for
this one it was possible to get the timing right in the emulator.
Add a test that hits this in the emulator environment (pretty narrow
window to hit on real hardware):
eSCO Simultaneous Disconnect - Failure
Pauli Virtanen [Tue, 1 Aug 2023 16:38:39 +0000 (19:38 +0300)]
btdev: fix Command Status command opcodes for Setup Sync Conn
The command opcode should be the CMD, not EVT.
Pauli Virtanen [Tue, 1 Aug 2023 16:38:38 +0000 (19:38 +0300)]
btdev: check error conditions for HCI_Create_Connection_Cancel
Create Connection Cancel shall return Command Complete with error status
when there is no Create Connection that can be canceled. In these
cases, we should not send a (spurious) Connection Complete event.
Fix by keeping a list of pending Create Connection commands, and
returning command errors if there is none pending at the moment.
Luiz Augusto von Dentz [Tue, 1 Aug 2023 23:18:10 +0000 (16:18 -0700)]
monitor/analyze: Inline data to gnuplot
Instead of creating a separate file just to write the x:y axis inline
the data via gnuplot $data variable then use it to plot.
Luiz Augusto von Dentz [Tue, 1 Aug 2023 21:32:48 +0000 (14:32 -0700)]
monitor: Add connection tracking for SCO/ISO with -a/--analyze
This adds proper connection tracking to SCO/ISO connection by handling
the events that establishes them.
Luiz Augusto von Dentz [Mon, 31 Jul 2023 22:13:38 +0000 (15:13 -0700)]
monitor: Print channel latency information with -a/--analyze
This prints channel latency information and use gnuplot when using
-a/--analyze to plot a graph of channels:
Found TX L2CAP channel with CID 68
PSM 25
22490 packets
7-50 msec (~11 msec) TX Latency
850-850 octets TX packet size
~569 Kb/s TX transfer speed
10000 +-+----------------------------------------------------------------+
+| ++ |
+| || + Packets +-----+ |
+| + || | |
1000 +-| | || |+ ++ |
+| | || || || + |
+| | || || ||+ +| |
+| | || || ||| || ++ ++ |
100 +-| | || || ||| || || || + |
+| | || || ||| || || || ++| + + |
+| | || || ||| || || || ||| | | |
+| | || || ||| || || || ||| |+ +| + |
| | || || ||| || || || ||| || || |+ + |
10 +-| | || || ||| || || || ||| || || || |+ |
+| | || || ||| || || || ||| || || || || + |
+| +| || || ||| || || || ||| || || || ||+ ++ |+ ++ + |
| || || || ||| || || || ||| || || || ||| || || || | |
1 +-| || || || ||| || || || ||| || || || ||| || || || | + + |
++----------------------------------------------------------------+
+ + + + + + + + + +
5 10 15 20 25 30 35 40 45 50
Latency (ms)
Luiz Augusto von Dentz [Mon, 31 Jul 2023 21:01:09 +0000 (14:01 -0700)]
monitor/analyze: Use conn_pkt_tx on acl_pkt
This makes use of conn_pkt_tx also on acl_pkt like other connections.
Luiz Augusto von Dentz [Mon, 31 Jul 2023 18:26:19 +0000 (11:26 -0700)]
monitor: Add TX frame number and speed estimation
This adds the frame information while decoding:
> HCI Event: Number of Completed Packets (0x13) plen 5
Num handles: 1
Handle: 256 Address: XX:XX:XX:XX:XX:XX
Count: 1
#188: len 850 (755 Kb/s)
Latency: 9 msec (3-21 msec ~6 msec)
Channel: 68 [PSM 25 mode Basic (0x00)] {chan 4}
Channel Latency: 9 msec (7-21 msec ~9 msec)
Or the speed estimation while analyzing:
Found BR-ACL connection with handle 256
Address: XX:XX:XX:XX:XX:XX
60 RX packets
22548 TX packets
22547 TX completed packets
3-73 msec (~11 msec) TX Latency
6-850 octets (~847 octets) TX packet size
~568 Kb/s TX transfer speed
Luiz Augusto von Dentz [Mon, 24 Jul 2023 20:57:34 +0000 (13:57 -0700)]
gatt: Fix not establishing a socket for each device
AcquireWrite and AcquireNotify shall establish a socket pair for each
device connected otherwise the application cannot distinct the
operations of each client.
Fixes: https://github.com/bluez/bluez/issues/460
Łukasz Rymanowski [Sat, 29 Jul 2023 00:45:52 +0000 (02:45 +0200)]
monitor: Add parsing Service Data of UUID 128
In the advertising report, instead of deciding EIR 0x21 into this:
Unknown EIR field 0x21:
3a048f2ba97ea6ae1b49c619e973a4a701480d130d
We can do bit better
Service Data UUID 128: Vendor specific
Data:
01480d130d
Reviewed-by: Paul Menzel <pmenzel@molgen.mpg.de>
Łukasz Rymanowski [Sat, 29 Jul 2023 00:45:51 +0000 (02:45 +0200)]
monitor: Add support to decode le read ISO link quality
btmon: Add parsing LE Read ISO link quality
> HCI Event: Command Complete (0x0e) plen 34
LE Read ISO link quality (0x08|0x0075) ncmd 1
Status: Success (0x00)
Handle: 98
TX unacked packets 0
TX flushed packets 257602
TX last subevent packets 0
TX retrnansmitted packets 0
TX crc error packets 2594
RX unreceived packets 0
Duplicated packets 0
Szymon Czapracki [Sat, 29 Jul 2023 00:45:50 +0000 (02:45 +0200)]
monitor/ll: Add support for connection parameter command.
LL_CONNECTION_PARAM_REQ (0x0f)
Interval min: 7.50 msec (0x0006)
Interval max: 7.50 msec (0x0006)
Latency: 0 (0x0000)
Timeout: 5000 msec (0x01f4)
Preffered periodicity: 0.00 (0x00)
Reference connection event count: 4 (0x04)
Offset 0: 0.00 msec (0x00)
Offset 1: 0.00 msec (0x00)
Offset 2: 1.25 msec (0x01)
Offset 3: 0.00 msec (0x00)
Offset 4: 2.50 msec (0x02)
Offset 5: 0.00 msec (0x00)
LL_CONNECTION_PARAM_RSP (0x10)
Interval min: 7.50 msec (0x0006)
Interval max: 7.50 msec (0x0006)
Latency: 0 (0x0000)
Timeout: 5000 msec (0x01f4)
Preffered periodicity: 0.00 (0x00)
Reference connection event count: 4 (0x04)
Offset 0: 318.75 msec (0xff)
Offset 1: 318.75 msec (0xff)
Offset 2: 318.75 msec (0xff)
Offset 3: 318.75 msec (0xff)
Offset 4: 318.75 msec (0xff)
Offset 5: 318.75 msec (0xff)
Łukasz Rymanowski [Sat, 29 Jul 2023 00:45:49 +0000 (02:45 +0200)]
monitor: Update le event mask with bits 20-23
Łukasz Rymanowski [Sat, 29 Jul 2023 00:45:48 +0000 (02:45 +0200)]
monitor: Fix decoding Command Complete for Remove ISO Data path
Before
< HCI Command: LE Remove Isochronous Data Path (0x08|0x006f) plen 3
Connection Handle: 96
Data Path Direction: Output (Controller to Host) (0x01)
> HCI Event: Command Complete (0x0e) plen 6
LE Remove Isochronous Data Path (0x08|0x006f) ncmd 1
invalid packet size
00 60 00
After patch
< HCI Command: LE Remove Isochronous Data Path (0x08|0x006f) plen 3
Connection Handle: 96
Data Path Direction: 0x01
Input (Host to Controller)
> HCI Event: Command Complete (0x0e) plen 6
LE Remove Isochronous Data Path (0x08|0x006f) ncmd 1
Status: Success (0x00)
Connection handle: 96
Silviu Florian Barbulescu [Mon, 31 Jul 2023 09:16:42 +0000 (12:16 +0300)]
Rename BAA_SERVICE to BCAA_SERVICE add BAA_SERVICE(0x1851)
Rename BAA_SERVICE to BCAA_SERVICE and added BAA_SERVICE(0x1851)
as UUID for the broadcast sink.
Zijun Hu [Mon, 31 Jul 2023 09:28:42 +0000 (17:28 +0800)]
main: Fix integer configuration option parse failures
parse_config_int() has a obvious logical error, so causes many
parse failures of integer configuration options, fixed by this
change.
Simon Mikuda [Mon, 31 Jul 2023 04:12:29 +0000 (06:12 +0200)]
adapter: Update ConnectDevice documentation
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).
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.
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.
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.
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.
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
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.
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)
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.
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.
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)
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)
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
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
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>
Ł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
Łukasz Rymanowski [Fri, 21 Jul 2023 12:03:19 +0000 (14:03 +0200)]
btmon: Fix obvious typo
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
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.
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.
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.
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.
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);
^
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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.
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.
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.
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.
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.
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.
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.
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
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.
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.
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
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.
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.
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.
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
===============================================================
Marcel Holtmann [Fri, 30 Jun 2023 19:39:03 +0000 (21:39 +0200)]
Release 5.68
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
Marcel Holtmann [Fri, 30 Jun 2023 08:09:06 +0000 (10:09 +0200)]
Release 5.67
Marcel Holtmann [Fri, 30 Jun 2023 07:35:21 +0000 (09:35 +0200)]
build: Use LT_INIT instead of AC_PROG_LIBTOOL
Marcel Holtmann [Fri, 30 Jun 2023 07:30:40 +0000 (09:30 +0200)]
build: Update library version
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.
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.
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(¬ification->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(¬ification->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.
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.
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.
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.
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
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.
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.
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
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.
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.
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.
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.
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.
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.
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.
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.
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