Commit Graph

26597 Commits

Author SHA1 Message Date
Brian Gix
c96629bedb mgmt-tester: Adds turning on Mesh Experimental feature
Turns on experimental Mesh feature, and expects it in report when
querying which experimental features are supported and have been
enabled.
2022-09-01 14:34:34 -07:00
Brian Gix
da4b654834 tools: Add mesh-tester to test Kernel mesh support
Ever growing set of tests for Mesh kernel support
2022-09-01 11:52:08 -07:00
Brian Gix
4f452c7753 lib: Add mgmt opcodes and events for Mesh 2022-09-01 11:52:06 -07:00
Bastien Nocera
61f4f28958 adapter: Fix typo in function name 2022-09-01 11:43:49 -07:00
Bastien Nocera
6e49216ad4 adapter-api: Add PowerState property documentation 2022-09-01 11:43:44 -07:00
Bastien Nocera
48992da64f client: Print the PowerState property 2022-09-01 11:43:41 -07:00
Bastien Nocera
58021a665b adapter: Implement PowerState property
This property should allow any program to show whether an adapter is in
the process of being turned on.

As turning on an adapter isn't instantaneous, it's important that the UI
reflects the transitional state of the adapter's power, and doesn't
assume the device is already turned on but not yet working, or still off
despite having requested for it to be turned on, in both cases making
the UI feel unresponsive.

This can also not be implemented in front-ends directly as, then,
the status of an adapter wouldn't be reflected correctly in the Settings
window if it's turned on in the system menu. Implementing it in the
front-ends would also preclude from having feedback about the state of
the adapter when bluetoothd is the one powering up the adapter after the
rfkill was unblocked.

See https://gitlab.gnome.org/GNOME/gnome-bluetooth/-/issues/121
and the original https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/5773
2022-09-01 11:43:35 -07:00
Bastien Nocera
abf5ba6b80 adapter: Keep track of whether the adapter is rfkill'ed
Instead of only replying to D-Bus requests with an error saying the
adapter is blocked, keep track of the rfkill being enabled or disabled
so we know the rfkill state of the adapter at all times.
2022-09-01 11:43:35 -07:00
Luiz Augusto von Dentz
49b8c59015 media: Fix scan-build warnings
This fixes the following warnings:

profiles/audio/media.c:1465:6: warning: 8th function call argument
is an uninitialized value
        if (media_endpoint_create(adapter, sender, path, uuid, delay_reporting,
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
profiles/audio/media.c:3012:3: warning: Use of memory after it is freed
                release_endpoint(adapter->endpoints->data);
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
profiles/audio/media.c:3015:3: warning: Use of memory after it is freed
                media_player_destroy(adapter->players->data);
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2022-08-31 15:24:39 -07:00
Luiz Augusto von Dentz
a84aa0e6e5 media: Fix registering PAC endpoints if ISO socket are not supported
If adapter don't support ISO sockets the PAC UUIDs shall not be allowed
to be registered as they depend on ISO sockets to work properly.
2022-08-30 17:03:34 -07:00
Luiz Augusto von Dentz
f8c3a38e4f shared/shell: Fix scan-build error
This fixes the following error:

src/shared/shell.c:1135:19: warning: Null pointer passed to 1st
parameter expecting 'nonnull'
                        data.timeout = atoi(optarg);
                                       ^~~~~~~~~~~~
2022-08-30 17:03:31 -07:00
Luiz Augusto von Dentz
d8febc76a4 client/player: Fix checkpatch warning
This fixes the following checkpatch warning:

WARNING:LINE_SPACING: Missing a blank line after declarations
216: FILE: client/player.c:625:
+               GDBusProxy *proxy = l->data;
+               print_player(proxy, NULL);
2022-08-30 14:24:08 -07:00
Frédéric Danis
d04b64003d profiles: Fix function definition style
This was found by checkpatch in previous commit:
WARNING:SPACING: Unnecessary space before function pointer arguments
124: FILE: src/shared/bap.h:123:
+	int (*select) (struct bt_bap_pac *lpac, struct bt_bap_pac *rpac,

Do the same for (*config) and (*clear) for consistence.
2022-08-30 13:31:05 -07:00
Frédéric Danis
fdff0e3ce3 doc: Add remote endpoint path to SelectProperties 2022-08-30 13:31:03 -07:00
Frédéric Danis
eb62d17e26 profiles: Add remote endpoint path to SelectProperties
This adds the remote endpoint path to the dictionary sent in
SelectProperties.
It allows audio application to know for which remote endpoint the call is
done and so for which it should act as an initiator.
2022-08-30 13:31:01 -07:00
Luiz Augusto von Dentz
d297a5873d client: Add -e/--endpoint option to auto register endpoints
This adds -e/--endpoint option that can be used to auto register
supported endpoints.
2022-08-29 14:36:06 -07:00
Luiz Augusto von Dentz
75f73f6d62 shell: Set empty argument if optarg is NULL
This sets enmpty string ("") when argument don't set any optarg so the
application can tell when an option was set or not.
2022-08-29 14:33:04 -07:00
Christian Eggers
150bbff449 tools/btmgmt: add missing return statement
Leave function on error instead of printing (possibly) invalid flags.
2022-08-29 13:06:35 -07:00
Christian Eggers
147cc4cf99 client/advertising: Fix typos: *_exits --> *_exists 2022-08-29 13:06:23 -07:00
Christian Eggers
9b93d95884 client: Add missing return statement in error path
Client will SEGFAULT if default_ctrl==NULL
2022-08-29 13:06:14 -07:00
Frédéric Danis
b843a5c5b4 profiles: Update transport Links property on state change to QoS
Currently, the Links property is only sent after the first call to the
Acquire method, this cmay result in a rejection if a linked transport tries
to call the Acquire method before receiving the Links update.
2022-08-29 12:44:49 -07:00
Frédéric Danis
34e8c20d48 profiles: Allow linked transport to release the fd
Multiple transports can be linked when using LE Audio BAP.
In this case only one transport is used to Acquire the file descriptor
which will be shared by all linked transports.
In the same way, any transport can Release the file descriptor.
2022-08-29 12:44:47 -07:00
Luiz Augusto von Dentz
9e298f8402 client/player: Use QoS interval on transport.send
This makes use of QoS interval when sending a file.
2022-08-29 12:43:05 -07:00
Luiz Augusto von Dentz
dc61ec4419 client/player: Add support for PACS endpoints
This adds support for PAC_SINK and PAC_SOURCE endpoints as well as LC3
presets.
2022-08-29 12:43:05 -07:00
Luiz Augusto von Dentz
f081ac8845 test/simple-endpoint: Add support for LC3 endpoints
This adds support for LC3 sink/source endpoints.
2022-08-29 12:43:04 -07:00
Luiz Augusto von Dentz
3579cf8bf6 media-api: Add SelectProperties
This adds SelectProperties which is a more extensible version of
SelectCapability since it takes a dictionary rather than a byte array
and define new Properties for LE Audio.
2022-08-29 12:43:04 -07:00
Luiz Augusto von Dentz
fcc16be905 shared: Add definition for LC3 codec
This adds the definition for LC3 codec capabilities and configuration.
2022-08-29 12:43:04 -07:00
Luiz Augusto von Dentz
47ba235f5a profiles: Add initial code for bap plugin
This adds initial code for bap plugin which handles Basic Audio
Profile, Publish Audio Capabilities Service and Audio Stream Control
Service.
2022-08-29 12:43:03 -07:00
Luiz Augusto von Dentz
b798cec4ca shared/bap: Add initial code for handling BAP
This adds initial code for Basic Audio Profile.
2022-08-29 12:42:58 -07:00
Luiz Augusto von Dentz
d7b78586af lib/uuid: Add PACS/ASCS UUIDs
This adds PACS/ASCS UUIDs which will be used by Basic Audio Profile.
2022-08-29 12:41:50 -07:00
Luiz Augusto von Dentz
67dfe38b66 adapter: Add btd_adapter_find_device_by_fd
This adds btd_adapter_find_device_by_fd that lookup a device by a fd
socket destination address.
2022-08-29 12:41:50 -07:00
Luiz Augusto von Dentz
6b8f9fbd5b gatt: Parse error message
Application can now encode an error code into the D-Bus reply error
message (0x80-0x9f).

Fixes: https://github.com/bluez/bluez/issues/380
2022-08-25 13:05:23 -07:00
Luiz Augusto von Dentz
ea903d1206 gatt-api: Add error code ReadValue/WriteValue
This allows application to return error codes in the range allowed by
the spec:

 'GATT - Section 4.9.5:

  Application Error 0x80 – 0x9F Application error code defined by a
  higher layer specification.'
2022-08-25 13:04:24 -07:00
Ronan Pigott
7c2f0c037e zsh: drop no more arguments message
This usage of the _message as a completion function is invalid, and
will result in an error if invoked by _arguments when the user has a
format style set for completion messages.

We can just drop this message, since it is not necessary.

Before:
  $ zstyle ':completion:*:messages' format '%d'
  $ bluetoothctl connect <TAB>
  _message:zformat:42: invalid argument: -J

After:
  $ zstyle ':completion:*:messages' format '%d'
  $ bluetoothctl connect <TAB>
  31:41:59:26:53:59  -- Bose QuietComfort 35
  11:22:33:44:55:66  -- Pixel 5
2022-08-24 14:32:04 -07:00
Archie Pusaka
ede7b91598 adapter: Reset pending settings when receiving MGMT error
We set the pending settings flag when sending MGMT_SETTING_*
commands to the MGMT layer and clear them when receiving a
successful reply, but we don't clear them when receiving an error
reply. This might cause a setting to be stuck in pending state.

Therefore, also clear the pending flag when receiving error.
Furthermore, this patch also postpones setting the pending flag
until we queue the MGMT command in order to avoid setting it too
soon but we return early.

This was caught during power off test, where MGMT_OP_SET_POWERED
returns Authentication Failed because disconnection takes too long.
Future attempts to switch power will then be ignored.

< HCI Command: Disconnect (0x01|0x0006) plen 3   #17916 [hci0] 12.502908
        Handle: 512
        Reason: Remote Device Terminated due to Power Off (0x15)
> HCI Event: Command Status (0x0f) plen 4        #17917 [hci0] 12.503185
      Disconnect (0x01|0x0006) ncmd 1
        Status: Success (0x00)
@ MGMT Event: Command Status (0x0002) plen 3   {0x0001} [hci0] 14.519491
      Set Powered (0x0005)
        Status: Authentication Failed (0x05)
= bluetoothd: Failed to set mode: Authentication Failed (0x05) 14.520042
= bluetoothd: adapter /org/bluez/hci0 set power to 0           14.813533
> HCI Event: Disconnect Complete (0x05) plen 4   #17918 [hci0] 16.509043
        Status: Success (0x00)
        Handle: 512
        Reason: Connection Timeout (0x08)

Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org>
2022-08-24 14:32:04 -07:00
Luiz Augusto von Dentz
73b301372b device: Fix not setting initiator
This fixes not setting initiator flag properly when MGMT connect event
has not been processed yet but ATT is already connected or is in
progress.
2022-08-24 14:30:27 -07:00
darkhz
4760ada065 shared/util: Correct UUID for Microphone Control
According to the Bluetooth product specification list, the allocated
UUID for "Microphone Control" is 0x184D, not 0x184C.
2022-08-22 15:39:43 -07:00
Luiz Augusto von Dentz
081897da74 iso-tester: Make use of bthost_add_iso_hook destroy callback
This makes use of bthost_add_iso_hook to track when an ISO connection
has been disconnected and then set its handle to 0x0000 which is then
checked when the socket HUP to confirm the remote has properly
disconnected (e.g. received Disconnected Complete).
2022-08-22 15:00:02 -07:00
Luiz Augusto von Dentz
5bf220eb3b bthost: Add destroy callback to bthost_add_iso_hook
This adds a destroy callback to bthost_add_iso_hook so its user can
detect when the hook is freed when the connection is disconnected.
2022-08-22 14:59:26 -07:00
Luiz Augusto von Dentz
4999f80c1f iso-tester: Fix using shutdown(SHUT_RDWR)
shutdown(SHUT_RDWR) results in socket being HUP immeditaly instead of
waiting for Disconnect Complete event so instead just use SHUT_WR to
start the disconnect procedure without causing the socket to HUP.
2022-08-19 11:44:33 -07:00
Luiz Augusto von Dentz
60663d4af3 hog-lib: Fix scan-build error
This fixes the following errors:
profiles/input/hog-lib.c:600:19: warning: Access to field 'handle'
results in a dereference of a null pointer (loaded from variable 'chr')
        report->handle = chr->handle;
                         ^~~~~~~~~~~
profiles/input/hog-lib.c:637:11: warning: Access to field 'value_handle'
results in a dereference of a null pointer (loaded from variable 'chr')
                start = chr->value_handle + 1;
                        ^~~~~~~~~~~~~~~~~
profiles/input/hog-lib.c:1240:11: warning: Access to field 'value_handle'
results in a dereference of a null pointer (loaded from variable 'chr')
                start = chr->value_handle + 1;
                        ^~~~~~~~~~~~~~~~~
2022-08-16 15:04:12 -07:00
Luiz Augusto von Dentz
952c08ff50 hog-lib: Don't restrict Report MAP size
Although HIDS spec is quite clear the Report MAP shall be limited to
512 bytes it doesn't seem OS do enforce that on the profile/client side
and since there isn't any qualification test enforcing it either there
are quite many devices which uses Report MAP bigger that 512 bytes
(e.g.: Brydge W-Touch and Lenovo Duet 3 BT Folio).

https://github.com/bluez/bluez/issues/377
2022-08-16 14:16:19 -07:00
Luiz Augusto von Dentz
fdc788f576 build: Enable admin plugin
This enables admin plugin with bootstrap-configure so it is normally
build by the likes of CI.
2022-08-15 16:28:14 -07:00
Luiz Augusto von Dentz
64abbf7cee client: Move admin submenu
This moves admin submenu to admin.c so it is not mixed up with other
submenus code.
2022-08-15 16:28:14 -07:00
Luiz Augusto von Dentz
c47730b2d5 adapter: Check flags are supported
This makes sure the flags are supported before attempting to set it.
2022-08-15 16:28:13 -07:00
Luiz Augusto von Dentz
9c3f35d6fd iso-tester: Introduce tests for Disconnect/Reconnect
This introduces a test that do use shutdown to disconnect an ISO socket
and then another one that attempts to reconnect it again to emulate
upper profile transitions.
2022-08-15 16:28:13 -07:00
Luiz Augusto von Dentz
06f6460cd1 iso-tester: Add ISO 48_2_1 Defer Receive - Success
This adds a test to check if different QoS are properly handled when
acting as peripheral.
2022-08-05 15:51:09 -07:00
Luiz Augusto von Dentz
bbbd0512c9 bthost: Add qos support to bthost_set_cig_params
This enables setting QoS other then the mandatory 16_2_1.
2022-08-05 15:50:56 -07:00
Luiz Augusto von Dentz
f07b88abfb test-tester: This add tests for tester
This adds tests for the tester itself:

> unit/test-tester

Test Summary
------------
/tester/basic                           Passed       0.000 seconds
/tester/setup_io                        Passed       0.000 seconds
/tester/io_send                         Passed       0.000 seconds
Total: 3, Passed: 3 (100.0%), Failed: 0, Not Run: 0
Overall execution time: 0.000355 seconds
2022-08-05 15:50:54 -07:00
Luiz Augusto von Dentz
2dfe291974 shared/tester: Add tester_setup_io
This adds tester_setup_io which can be used to add a PDU list in the
form of iovec.
2022-08-05 15:50:44 -07:00