platform/upstream/bluez.git
14 months agolib: Add mgmt opcodes and events for Mesh
Brian Gix [Wed, 31 Aug 2022 23:59:31 +0000 (16:59 -0700)]
lib: Add mgmt opcodes and events for Mesh

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
14 months agoadapter: Fix typo in function name
Bastien Nocera [Thu, 1 Sep 2022 11:07:18 +0000 (13:07 +0200)]
adapter: Fix typo in function name

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
14 months agoadapter-api: Add PowerState property documentation
Bastien Nocera [Thu, 1 Sep 2022 11:07:17 +0000 (13:07 +0200)]
adapter-api: Add PowerState property documentation

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
14 months agoclient: Print the PowerState property
Bastien Nocera [Thu, 1 Sep 2022 11:07:16 +0000 (13:07 +0200)]
client: Print the PowerState property

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
14 months agoadapter: Implement PowerState property
Bastien Nocera [Thu, 1 Sep 2022 11:07:15 +0000 (13:07 +0200)]
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

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
14 months agoadapter: Keep track of whether the adapter is rfkill'ed
Bastien Nocera [Thu, 1 Sep 2022 11:07:14 +0000 (13:07 +0200)]
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.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
14 months agomedia: Fix scan-build warnings
Luiz Augusto von Dentz [Tue, 30 Aug 2022 23:55:32 +0000 (16:55 -0700)]
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);
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
14 months agomedia: Fix registering PAC endpoints if ISO socket are not supported
Luiz Augusto von Dentz [Tue, 30 Aug 2022 21:49:20 +0000 (14:49 -0700)]
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.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
14 months agoshared/shell: Fix scan-build error
Luiz Augusto von Dentz [Tue, 30 Aug 2022 21:37:27 +0000 (14:37 -0700)]
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);
                                       ^~~~~~~~~~~~

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
14 months agoclient/player: Fix checkpatch warning
Luiz Augusto von Dentz [Tue, 30 Aug 2022 21:24:08 +0000 (14:24 -0700)]
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);

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
14 months agoprofiles: Fix function definition style
Frédéric Danis [Tue, 30 Aug 2022 14:47:34 +0000 (16:47 +0200)]
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.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
14 months agodoc: Add remote endpoint path to SelectProperties
Frédéric Danis [Tue, 30 Aug 2022 14:47:33 +0000 (16:47 +0200)]
doc: Add remote endpoint path to SelectProperties

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
14 months agoprofiles: Add remote endpoint path to SelectProperties
Frédéric Danis [Tue, 30 Aug 2022 14:47:32 +0000 (16:47 +0200)]
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.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
14 months agoclient: Add -e/--endpoint option to auto register endpoints
Luiz Augusto von Dentz [Mon, 29 Aug 2022 21:36:06 +0000 (14:36 -0700)]
client: Add -e/--endpoint option to auto register endpoints

This adds -e/--endpoint option that can be used to auto register
supported endpoints.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
14 months agoshell: Set empty argument if optarg is NULL
Luiz Augusto von Dentz [Mon, 29 Aug 2022 21:33:04 +0000 (14:33 -0700)]
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.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
14 months agotools/btmgmt: add missing return statement
Christian Eggers [Thu, 25 Aug 2022 20:38:48 +0000 (22:38 +0200)]
tools/btmgmt: add missing return statement

Leave function on error instead of printing (possibly) invalid flags.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
14 months agoclient/advertising: Fix typos: *_exits --> *_exists
Christian Eggers [Thu, 25 Aug 2022 20:38:28 +0000 (22:38 +0200)]
client/advertising: Fix typos: *_exits --> *_exists

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
14 months agoclient: Add missing return statement in error path
Christian Eggers [Thu, 25 Aug 2022 20:39:03 +0000 (22:39 +0200)]
client: Add missing return statement in error path

Client will SEGFAULT if default_ctrl==NULL

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
14 months agoprofiles: Update transport Links property on state change to QoS
Frédéric Danis [Fri, 26 Aug 2022 10:00:34 +0000 (12:00 +0200)]
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.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
14 months agoprofiles: Allow linked transport to release the fd
Frédéric Danis [Wed, 24 Aug 2022 15:05:19 +0000 (17:05 +0200)]
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.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
14 months agoclient/player: Use QoS interval on transport.send
Luiz Augusto von Dentz [Wed, 16 Sep 2020 21:07:44 +0000 (14:07 -0700)]
client/player: Use QoS interval on transport.send

This makes use of QoS interval when sending a file.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
14 months agoclient/player: Add support for PACS endpoints
Luiz Augusto von Dentz [Wed, 5 Aug 2020 00:19:43 +0000 (17:19 -0700)]
client/player: Add support for PACS endpoints

This adds support for PAC_SINK and PAC_SOURCE endpoints as well as LC3
presets.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
14 months agotest/simple-endpoint: Add support for LC3 endpoints
Luiz Augusto von Dentz [Wed, 5 Aug 2020 00:18:27 +0000 (17:18 -0700)]
test/simple-endpoint: Add support for LC3 endpoints

This adds support for LC3 sink/source endpoints.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
14 months agomedia-api: Add SelectProperties
Luiz Augusto von Dentz [Wed, 11 May 2022 23:51:19 +0000 (16:51 -0700)]
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.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
14 months agoshared: Add definition for LC3 codec
Luiz Augusto von Dentz [Fri, 24 Jun 2022 23:30:43 +0000 (16:30 -0700)]
shared: Add definition for LC3 codec

This adds the definition for LC3 codec capabilities and configuration.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
14 months agoprofiles: Add initial code for bap plugin
Luiz Augusto von Dentz [Wed, 5 Aug 2020 00:09:27 +0000 (17:09 -0700)]
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.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
14 months agoshared/bap: Add initial code for handling BAP
Luiz Augusto von Dentz [Wed, 5 Aug 2020 00:04:21 +0000 (17:04 -0700)]
shared/bap: Add initial code for handling BAP

This adds initial code for Basic Audio Profile.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
14 months agolib/uuid: Add PACS/ASCS UUIDs
Luiz Augusto von Dentz [Wed, 5 Aug 2020 00:06:40 +0000 (17:06 -0700)]
lib/uuid: Add PACS/ASCS UUIDs

This adds PACS/ASCS UUIDs which will be used by Basic Audio Profile.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
14 months agoadapter: Add btd_adapter_find_device_by_fd
Luiz Augusto von Dentz [Thu, 14 Apr 2022 00:17:01 +0000 (17:17 -0700)]
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.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
14 months agogatt: Parse error message
Luiz Augusto von Dentz [Thu, 25 Aug 2022 20:05:23 +0000 (13:05 -0700)]
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
Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
14 months agogatt-api: Add error code ReadValue/WriteValue
Luiz Augusto von Dentz [Thu, 25 Aug 2022 19:46:38 +0000 (12:46 -0700)]
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.'

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
14 months agozsh: drop no more arguments message
Ronan Pigott [Mon, 22 Aug 2022 23:19:10 +0000 (16:19 -0700)]
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
Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
14 months agoadapter: Reset pending settings when receiving MGMT error
Archie Pusaka [Tue, 23 Aug 2022 04:15:56 +0000 (12:15 +0800)]
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>
Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
14 months agodevice: Fix not setting initiator
Luiz Augusto von Dentz [Wed, 24 Aug 2022 21:23:25 +0000 (14:23 -0700)]
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.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
14 months agoshared/util: Correct UUID for Microphone Control
darkhz [Sun, 21 Aug 2022 16:02:48 +0000 (21:32 +0530)]
shared/util: Correct UUID for Microphone Control

According to the Bluetooth product specification list, the allocated
UUID for "Microphone Control" is 0x184D, not 0x184C.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
14 months agoiso-tester: Make use of bthost_add_iso_hook destroy callback
Luiz Augusto von Dentz [Mon, 22 Aug 2022 21:55:14 +0000 (14:55 -0700)]
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).

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
14 months agobthost: Add destroy callback to bthost_add_iso_hook
Luiz Augusto von Dentz [Mon, 22 Aug 2022 21:54:41 +0000 (14:54 -0700)]
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.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
14 months agoiso-tester: Fix using shutdown(SHUT_RDWR)
Luiz Augusto von Dentz [Thu, 18 Aug 2022 21:46:14 +0000 (14:46 -0700)]
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.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
14 months agohog-lib: Fix scan-build error
Luiz Augusto von Dentz [Tue, 16 Aug 2022 22:04:12 +0000 (15:04 -0700)]
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;
                        ^~~~~~~~~~~~~~~~~

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
14 months agohog-lib: Don't restrict Report MAP size
Luiz Augusto von Dentz [Tue, 16 Aug 2022 18:56:32 +0000 (11:56 -0700)]
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
Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
14 months agobuild: Enable admin plugin
Luiz Augusto von Dentz [Mon, 15 Aug 2022 23:21:59 +0000 (16:21 -0700)]
build: Enable admin plugin

This enables admin plugin with bootstrap-configure so it is normally
build by the likes of CI.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
14 months agoclient: Move admin submenu
Luiz Augusto von Dentz [Mon, 15 Aug 2022 23:20:31 +0000 (16:20 -0700)]
client: Move admin submenu

This moves admin submenu to admin.c so it is not mixed up with other
submenus code.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
14 months agoadapter: Check flags are supported
Luiz Augusto von Dentz [Mon, 15 Aug 2022 22:32:42 +0000 (15:32 -0700)]
adapter: Check flags are supported

This makes sure the flags are supported before attempting to set it.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
14 months agoiso-tester: Introduce tests for Disconnect/Reconnect
Luiz Augusto von Dentz [Mon, 15 Aug 2022 19:01:56 +0000 (12:01 -0700)]
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.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
14 months agoiso-tester: Add ISO 48_2_1 Defer Receive - Success
Luiz Augusto von Dentz [Fri, 5 Aug 2022 21:49:31 +0000 (14:49 -0700)]
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.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
14 months agobthost: Add qos support to bthost_set_cig_params
Luiz Augusto von Dentz [Fri, 5 Aug 2022 21:48:37 +0000 (14:48 -0700)]
bthost: Add qos support to bthost_set_cig_params

This enables setting QoS other then the mandatory 16_2_1.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
14 months agotest-tester: This add tests for tester
Luiz Augusto von Dentz [Thu, 4 Aug 2022 22:24:14 +0000 (15:24 -0700)]
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

Change-Id: I272f4e8503b7f4e4355d251c50ac8493a16b4eb8
Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
14 months agoshared/tester: Add tester_setup_io
Luiz Augusto von Dentz [Thu, 4 Aug 2022 22:22:23 +0000 (15:22 -0700)]
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.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
14 months agobuild: Fix make check failing
Luiz Augusto von Dentz [Fri, 5 Aug 2022 01:07:17 +0000 (18:07 -0700)]
build: Fix make check failing

This fixes make check failing because lack of suppression for bind on
bt_log_open.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
14 months agoiso-tester: Test BT_DEFER_SETUP works with getsockopt
Luiz Augusto von Dentz [Wed, 3 Aug 2022 17:20:25 +0000 (10:20 -0700)]
iso-tester: Test BT_DEFER_SETUP works with getsockopt

This attempts to test BT_DEFER_SETUP is properly set when the test has
defer flag set.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
14 months agosixaxis: Fix fliping device.trusted automatically
Luiz Augusto von Dentz [Tue, 2 Aug 2022 00:05:36 +0000 (17:05 -0700)]
sixaxis: Fix fliping device.trusted automatically

device.trusted is a user preference which controls if the devices needs
to be authorized or not so the plugin shall not overwrite it and instead
just honor what user has set and skip authorizing if already trusted.

Fixes: https://github.com/bluez/bluez/issues/372
Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
14 months agodevice: Add btd_ prefix to device_is_trusted
Luiz Augusto von Dentz [Tue, 2 Aug 2022 16:31:04 +0000 (09:31 -0700)]
device: Add btd_ prefix to device_is_trusted

This adds btd_ prefix to device_is_trusted so it can be used by
plugins.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
14 months agodevice: Fix not auto-connecting profile
Luiz Augusto von Dentz [Mon, 1 Aug 2022 22:19:13 +0000 (15:19 -0700)]
device: Fix not auto-connecting profile

If the profile is registered and marked to auto-connect it shall
automatically be connected whenever a device is already connected.

Fixes: https://github.com/bluez/bluez/issues/370
Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
14 months agoiso-test: Add ISO 48_2_1 Defer Send
Luiz Augusto von Dentz [Thu, 28 Jul 2022 20:53:59 +0000 (13:53 -0700)]
iso-test: Add ISO 48_2_1 Defer Send

This adds ISO 48_2_1 Defer Send test which enables just output instead
of both.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
14 months agoRelease 5.65
Marcel Holtmann [Sun, 24 Jul 2022 20:59:52 +0000 (22:59 +0200)]
Release 5.65

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
14 months agobuild: Update library version
Marcel Holtmann [Sun, 24 Jul 2022 20:33:04 +0000 (22:33 +0200)]
build: Update library version

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
14 months agoisotest: Add documentation
Luiz Augusto von Dentz [Thu, 5 May 2022 01:17:50 +0000 (18:17 -0700)]
isotest: Add documentation

This adds isotest.rst which documents the modes and options of
isotest(1) and is then converted isotest.1 manpage.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
14 months agotools: Add isotest tool
Luiz Augusto von Dentz [Wed, 7 Aug 2019 07:50:32 +0000 (10:50 +0300)]
tools: Add isotest tool

This adds isotest tool which can be used to test ISO sockets.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
14 months agotools: Add iso-tester
Luiz Augusto von Dentz [Tue, 27 Oct 2020 18:23:10 +0000 (11:23 -0700)]
tools: Add iso-tester

This adds iso-tester which tests BTPROTO_ISO socket:

Basic Framework - Success
Basic ISO Socket - Success
Basic ISO Get Socket Option - Success
Basic ISO Set Socket Option - Success
ISO QoS 8_1_1 - Success
ISO QoS 8_2_1 - Success
ISO QoS 16_1_1 - Success
ISO QoS 16_2_1 - Success
ISO QoS 16_2_1 CIG 0x01 - Success
ISO QoS 16_2_1 CIG 0x01 CIS 0x01 - Success
ISO QoS 24_1_1 - Success
ISO QoS 24_2_1 - Success
ISO QoS 32_1_1 - Success
ISO QoS 32_2_1 - Success
ISO QoS 44_1_1 - Success
ISO QoS 44_2_1 - Success
ISO QoS 48_1_1 - Success
ISO QoS 48_2_1 - Success
ISO QoS 48_3_1 - Success
ISO QoS 48_4_1 - Success
ISO QoS 48_5_1 - Success
ISO QoS 48_6_1 - Success
ISO QoS 8_1_2 - Success
ISO QoS 8_2_2 - Success
ISO QoS 16_1_2 - Success
ISO QoS 16_2_2 - Success
ISO QoS 24_1_2 - Success
ISO QoS 24_2_2 - Success
ISO QoS 32_1_2 - Success
ISO QoS 32_2_2 - Success
ISO QoS 44_1_2 - Success
ISO QoS 44_2_2 - Success
ISO QoS 48_1_2 - Success
ISO QoS 48_2_2 - Success
ISO QoS 48_3_2 - Success
ISO QoS 48_4_2 - Success
ISO QoS 48_5_2 - Success
ISO QoS 48_6_2 - Success
ISO QoS - Invalid
ISO Connect2 CIG 0x01 - Success
ISO Send - Success
ISO Receive - Success
ISO Defer - Success
ISO Defer Send - Success
ISO Defer Receive - Success
ISO Defer Reject - Success
ISO Send and Receive - Success
ISO Broadcaster - Success
ISO Broadcaster BIG 0x01 - Success
ISO Broadcaster BIG 0x01 BIS 0x01 - Success
ISO Broadcaster Receiver - Success

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
14 months agobtio: Add support for ISO sockets
Luiz Augusto von Dentz [Mon, 28 Sep 2020 22:59:51 +0000 (15:59 -0700)]
btio: Add support for ISO sockets

This adds support to create objects that map to ISO sockets.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
14 months agoadapter: Add support for setting ISO Socket experimental feature
Luiz Augusto von Dentz [Wed, 15 Dec 2021 22:24:03 +0000 (14:24 -0800)]
adapter: Add support for setting ISO Socket experimental feature

This adds support for setting ISO Socket experimental UUID which
enables the use of BTPROTO_ISO on the system.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
14 months agomgmt-tester: Fix Read Exp Feature tests
Luiz Augusto von Dentz [Fri, 6 May 2022 22:27:49 +0000 (15:27 -0700)]
mgmt-tester: Fix Read Exp Feature tests

This adds ISO Socket UUID as response to Read Exp Feature.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
14 months agoshared/util: Decode BlueZ Experimental ISO Socket UUID
Luiz Augusto von Dentz [Thu, 16 Dec 2021 00:49:08 +0000 (16:49 -0800)]
shared/util: Decode BlueZ Experimental ISO Socket UUID

This adds BlueZ experimental ISO Socket UUID to uuid128_table so it is
decoded by the likes of btmon.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
14 months agolib: Add definitions for ISO socket
Luiz Augusto von Dentz [Mon, 29 Jul 2019 10:09:24 +0000 (13:09 +0300)]
lib: Add definitions for ISO socket

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
14 months agomain: Default device_privacy to true
Luiz Augusto von Dentz [Wed, 13 Jul 2022 23:40:03 +0000 (16:40 -0700)]
main: Default device_privacy to true

If privacy mode is not strictly set to network set it to device
otherwise network mode would prevent reconnections if the the identity
address is used:

BLUETOOTH CORE SPECIFICATION Version 5.3 | Vol 6, Part B page 2837-2838

 'The Host specifies the privacy mode to be used with each peer
 identity on the resolving list. If it specifies that device privacy
 mode is to be used, then the Controller shall accept both the peer's
 device Identity Address and a resolvable private address generated by
 the peer device using its distributed IRK. Otherwise, network privacy
 mode is used: the Controller shall only accept resolvable private
 addresses generated by the peer device using its distributed IRK.'

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
14 months agoadapter: Fix advertising monitor on Linux 5.12-5.17
Andrew Drake [Thu, 30 Jun 2022 07:39:58 +0000 (00:39 -0700)]
adapter: Fix advertising monitor on Linux 5.12-5.17

The existing code assumes that, if a device supports advertising monitor
offload, DEVICE_FOUND events can be ignored since the kernel will send
ADV_MONITOR_DEVICE_FOUND events instead. Unfortunately, these new events
were added in 5.18, but offload was added in 5.12. This patch adds a
check on the MGMT API version so we can process the older DEVICE_FOUND
events when the new events are not supported.

Fixes: https://github.com/bluez/bluez/issues/357
Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
14 months agobtdev: Fix not checking if a CIG has any active CIS
Luiz Augusto von Dentz [Fri, 8 Jul 2022 00:23:53 +0000 (17:23 -0700)]
btdev: Fix not checking if a CIG has any active CIS

Bluetooth Core specification says the CIG must be in configurable state
in order to accept the SetCIGParameters:

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

 'If the Host issues this command when the CIG is not in the
  configurable state, the Controller shall return the error
  code Command Disallowed (0x0C).'

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
14 months agomonitor: Fix build error in some targets
Luiz Augusto von Dentz [Tue, 5 Jul 2022 17:43:46 +0000 (10:43 -0700)]
monitor: Fix build error in some targets

This fixes the following error:

monitor/att.c: In function 'print_attribute':
monitor/att.c:1850:35: error: lvalue required as unary '&' operand
                 print_uuid(label, &cpu_to_le16(uuid->value.u16), 2);

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
14 months agoclient: Fix build warning
Luiz Augusto von Dentz [Tue, 5 Jul 2022 17:31:39 +0000 (10:31 -0700)]
client: Fix build warning

This fixes the following build warning:

      warning: ‘g_memdup’ is deprecated: Use 'g_memdup2' instead
      [-Wdeprecated-declarations]

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
14 months agoobexd: Fix the code style
Youwan Wang [Tue, 5 Jul 2022 09:29:52 +0000 (17:29 +0800)]
obexd: Fix the code style

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
14 months agotools/test-runner: Fix errors reported by scan-build
Tedd Ho-Jeong An [Fri, 1 Jul 2022 00:43:52 +0000 (17:43 -0700)]
tools/test-runner: Fix errors reported by scan-build

This patch fixes the errors reported by the scan-build.

tools/test-runner.c:315:2: warning: Null pointer passed to 1st parameter
expecting 'nonnull' [core.NonNullParamChecker]
        execve(argv[0], argv, qemu_envp);
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tools/test-runner.c:554:6: warning: Null pointer passed to 1st parameter
expecting 'nonnull' [core.NonNullParamChecker]
        if (chdir(home + 5) < 0) {
            ^~~~~~~~~~~~~~~

tools/test-runner.c:638:6: warning: Null pointer passed to 1st parameter
expecting 'nonnull' [core.NonNullParamChecker]
        if (chdir(home + 5) < 0) {
            ^~~~~~~~~~~~~~~

tools/test-runner.c:695:6: warning: Null pointer passed to 1st parameter
expecting 'nonnull' [core.NonNullParamChecker]
        if (chdir(home + 5) < 0) {
            ^~~~~~~~~~~~~~~

tools/test-runner.c:984:3: warning: Value stored to 'serial_fd' is never
read [deadcode.DeadStores]
                serial_fd = -1;
                ^           ~~

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
14 months agotools/btmgmt: Fix errors reported by scan-build
Tedd Ho-Jeong An [Fri, 1 Jul 2022 00:43:51 +0000 (17:43 -0700)]
tools/btmgmt: Fix errors reported by scan-build

This patch fixes the errors reported by the scan-build.

tools/btmgmt.c:2699:2: warning: Value stored to 'argc' is never read
[deadcode.DeadStores]
        argc -= optind;
        ^       ~~~~~~

tools/btmgmt.c:2859:2: warning: Value stored to 'argc' is never read
[deadcode.DeadStores]
        argc -= optind;
        ^       ~~~~~~

tools/btmgmt.c:2860:2: warning: Value stored to 'argv' is never read
[deadcode.DeadStores]
        argv += optind;
        ^       ~~~~~~

tools/btmgmt.c:2934:2: warning: Value stored to 'argc' is never read
[deadcode.DeadStores]
        argc -= optind;
        ^       ~~~~~~

tools/btmgmt.c:2935:2: warning: Value stored to 'argv' is never read
[deadcode.DeadStores]
        argv += optind;
        ^       ~~~~~~

tools/btmgmt.c:3000:2: warning: Value stored to 'argc' is never read
[deadcode.DeadStores]
        argc -= optind;
        ^       ~~~~~~

tools/btmgmt.c:3001:2: warning: Value stored to 'argv' is never read
[deadcode.DeadStores]
        argv += optind;
        ^       ~~~~~~

tools/btmgmt.c:3261:11: warning: Value stored to 'index' during its
initialization is never read [deadcode.DeadStores]
        uint16_t index = mgmt_index;
                 ^~~~~   ~~~~~~~~~~

tools/btmgmt.c:3450:2: warning: Value stored to 'argc' is never read
[deadcode.DeadStores]
        argc -= optind;
        ^       ~~~~~~

tools/btmgmt.c:3451:2: warning: Value stored to 'argv' is never read
[deadcode.DeadStores]
        argv += optind;
        ^       ~~~~~~

tools/btmgmt.c:4822:2: warning: Null pointer passed to 2nd parameter
expecting 'nonnull' [core.NonNullParamChecker]
        memcpy(cp->data + uuid_bytes, adv_data, adv_len);
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tools/btmgmt.c:4823:2: warning: Null pointer passed to 2nd parameter
expecting 'nonnull' [core.NonNullParamChecker]
        memcpy(cp->data + uuid_bytes + adv_len, scan_rsp, scan_rsp_len);
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tools/btmgmt.c:5244:2: warning: Null pointer passed to 2nd parameter
expecting 'nonnull' [core.NonNullParamChecker]
        memcpy(cp->data + uuid_bytes, adv_data, adv_len);
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tools/btmgmt.c:5245:2: warning: Null pointer passed to 2nd parameter
expecting 'nonnull' [core.NonNullParamChecker]
        memcpy(cp->data + uuid_bytes + adv_len, scan_rsp, scan_rsp_len);
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
14 months agomonitor: Fix usage of %z formater for uint64_t
Brian Gix [Wed, 29 Jun 2022 19:19:43 +0000 (12:19 -0700)]
monitor: Fix usage of %z formater for uint64_t

%z expect a size_t as argument not uint64_t, so passing
an argument of type uint64_t shall use PRIx64 instead.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
14 months agomesh: Fix snprintf return values not being checked
Brian Gix [Wed, 29 Jun 2022 21:02:37 +0000 (14:02 -0700)]
mesh: Fix snprintf return values not being checked

Some versions of the GCC compiler complain when the return value of
snprintf is not checked. This patch cleans up the Mesh JSON parser.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
14 months agocore: Fix signed vs unsigned compare
Brian Gix [Wed, 29 Jun 2022 21:16:40 +0000 (14:16 -0700)]
core: Fix signed vs unsigned compare

__time_t is not a portable data type, and can cause sign mismatch on
some compares.

Fixes:
  CC       src/bluetoothd-device.o
src/device.c: In function ‘device_is_name_resolve_allowed’:
src/device.c:4092:17: error: comparison of integer expressions of
different signedness: ‘__time_t’ {aka ‘long int’} and
‘long unsigned int’ [-Werror=sign-compare]
  if (now.tv_sec >= device->name_resolve_failed_time +
                 ^~
cc1: all warnings being treated as errors

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
14 months agocore: make bt_uuid_hash() portable across archs
Brian Gix [Wed, 29 Jun 2022 21:16:39 +0000 (14:16 -0700)]
core: make bt_uuid_hash() portable across archs

bt_uuid_t is defined as a byte array, so it can cause alignment errors
on some architectures, when the two 64 bit halves are treated as u64s.
This patch ensures proper alignment across all architectures.

Fixes:
src/adapter.c: In function ‘bt_uuid_hash’:
src/adapter.c:3617:8: error: cast increases required alignment of
target type [-Werror=cast-align]
  val = (uint64_t *)&uuid_128.value.u128;
        ^
cc1: all warnings being treated as errors

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
14 months agoavdtp: fix possible minor problems
lishengyu [Wed, 29 Jun 2022 12:46:56 +0000 (20:46 +0800)]
avdtp: fix possible minor problems

It should always be considered that if send_request fails, sep
should be removed from the list and the requested memory freed;

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
14 months agomesh: Use correct net_id for received CTL messages
Isak Westin [Thu, 30 Jun 2022 07:29:19 +0000 (09:29 +0200)]
mesh: Use correct net_id for received CTL messages

For received CTL mesh messages, the wrong network ID variable was
passed to ctl_received. This patch changes to the correct variable.

Also, changed type of net_key_id argument in ctl_received function
to be consistent wich the whole call chain.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
14 months agomonitor: Fix crash when using RTT backend
Szymon Janc [Fri, 24 Jun 2022 08:25:41 +0000 (10:25 +0200)]
monitor: Fix crash when using RTT backend

This fix regression introduced by "monitor: Fix memory leaks".
J-Link shared library is in use if jlink_init() returns 0 and thus
handle shall not be closed.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
14 months agodevice: Fix not removing connected device
Youwan Wang [Thu, 23 Jun 2022 06:29:53 +0000 (14:29 +0800)]
device: Fix not removing connected device

[bluetooth]# connect 40:EF:4C:0C:11:F0
Attempting to connect to 40:EF:4C:0C:11:F0
[CHG] Device 40:EF:4C:0C:11:F0 Connected: yes
Connection successful
[CHG] Device 40:EF:4C:0C:11:F0 ServicesResolved: yes
[UFO]# remove 40:EF:4C:0C:11:F0
[CHG] Device 40:EF:4C:0C:11:F0 ServicesResolved: no
Device has been removed
[CHG] Device 40:EF:4C:0C:11:F0 Connected: no
[bluetooth]# info 40:EF:4C:0C:11:F0
Device 40:EF:4C:0C:11:F0 (public)
        Name: UFO
        Alias: UFO
        Class: 0x00240418
        Icon: audio-headphones
        Paired: yes
        Trusted: no
        Blocked: no
        Connected: no
        LegacyPairing: no
        UUID: Headset
        UUID: Audio Sink
        UUID: A/V Remote Control Target
        UUID: A/V Remote Control
        UUID: Handsfree
        UUID: Phonebook Access Server

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
14 months agomgmt-tester: Fix null dereference issue reported by scan-build
Tedd Ho-Jeong An [Thu, 23 Jun 2022 04:45:20 +0000 (21:45 -0700)]
mgmt-tester: Fix null dereference issue reported by scan-build

This patch fixes the null dereference reported by the scan-build.

tools/mgmt-tester.c:12025:28: warning: Access to field 'cap_len' results
in a dereference of a null pointer (loaded from variable 'rp')
[core.NullDereference]

        if (sizeof(rp->cap_len) + rp->cap_len != length) {
                                  ^~~~~~~~~~~

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
14 months agoclient/advertising: Fixes errors found by scan-build
Luiz Augusto von Dentz [Wed, 22 Jun 2022 18:16:18 +0000 (11:16 -0700)]
client/advertising: Fixes errors found by scan-build

This fixes the following errors:

client/advertising.c:129:4: warning: Value stored to 'n' is never read
[deadcode.DeadStores]
                        n = sizeof(str) - 1;
                        ^   ~~~~~~~~~~~~~~~
client/advertising.c:1012:25: warning: Dereference of null pointer
(loaded from variable 'min') [core.NullDereference]
        if (ad.min_interval != *min) {
                               ^~~~

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
14 months agoclient/player: Fixes errors found by scan-build
Luiz Augusto von Dentz [Wed, 22 Jun 2022 18:09:04 +0000 (11:09 -0700)]
client/player: Fixes errors found by scan-build

This fixes the following errors:

client/player.c:1406:44: warning: Dereference of null pointer
[core.NullDereference]
        reply = endpoint_select_config_reply(msg, p->data.iov_base,
                                                  ^~~~~~~~~~~~~~~~
client/player.c:1866:2: warning: 3rd function call argument is an
uninitialized value [core.CallAndMessage]
        iov_append(&cfg->caps, data, len);
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
14 months agoclient/player: Enable acquiring multiple transports
Luiz Augusto von Dentz [Mon, 20 Jun 2022 22:22:52 +0000 (15:22 -0700)]
client/player: Enable acquiring multiple transports

This enables acquiring multiple transports simultaneously.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
14 months agotools/mgmt-tester: Add test case for scan response data is not updating
Tedd Ho-Jeong An [Tue, 21 Jun 2022 20:10:54 +0000 (13:10 -0700)]
tools/mgmt-tester: Add test case for scan response data is not updating

This patch adds a test case to test if the scan response data is updated
when the following scenarios are performed.

1. Add Extended Advertising Parameters Command
2. Add Extended Advertising Data Command w/ Scan Resp Data
3. Remove Advertising Command
4. Add Extended Advertising Parameters Command
5. Add Extended Advertising Data Command w/ Scan Resp Data
6. Host should set Scan Resp Data

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
14 months agomesh: Fix bug where bluetooth-meshd stops sending
Jonas Maes [Fri, 10 Jun 2022 15:29:02 +0000 (17:29 +0200)]
mesh: Fix bug where bluetooth-meshd stops sending

When there is a backlog of mesh packets to be sent, the packet sender
Fix bug where bluetooth-meshd stops sending

When there is a backlog of mesh packets to be sent, the packet sender
incorrectly infers that the tx worker thread is already running
and therefore needn't be invoked. As a result, the mesh daemon will
sometimes stop broadcasting while there are still packets in the queue.
It will not resume broadcasting.

This patch will invoke the tx worker thread correctly in that case.

The logic to send packets at least twice when the transmitter is idle
was slightly modified accordingly, and should behave the same way as
before.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
14 months agoavdtp: Free discover when send_request returns error
Chengyi [Tue, 21 Jun 2022 04:31:33 +0000 (12:31 +0800)]
avdtp: Free discover when send_request returns error

When send_request returns an error, session->discover should
be released here, so that the next time the program enters
avdtp_discover, the -EBUSY error will not be returned.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
14 months agotest-runner: Fix issues found by coverity
Frédéric Danis [Fri, 17 Jun 2022 19:49:29 +0000 (21:49 +0200)]
test-runner: Fix issues found by coverity

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
14 months agotools/btmgmt: Add support Add Ext Adv command
Tedd Ho-Jeong An [Thu, 16 Jun 2022 19:58:03 +0000 (12:58 -0700)]
tools/btmgmt: Add support Add Ext Adv command

This patch adds new command to support the following MGMT API:
 Add Extended Advertising Parameters Command
 Add Extended Advertising Data Command

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
14 months agomonitor: Update flag information for Extended Advertismement
Tedd Ho-Jeong An [Thu, 16 Jun 2022 19:58:02 +0000 (12:58 -0700)]
monitor: Update flag information for Extended Advertismement

This patch updates the missing flag details for Advertisement flags

@ MGMT Event: Command Complete (0x0001) plen 11
      Read Advertising Features (0x003d) plen 8
        Status: Success (0x00)
        Flags: 0x0001ffff
...
          Unknown advertising flag (0x00010c00)
...

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
14 months agodoc/mgmt-api: Update for Add Extended Advertisement Command
Tedd Ho-Jeong An [Thu, 16 Jun 2022 19:58:01 +0000 (12:58 -0700)]
doc/mgmt-api: Update for Add Extended Advertisement Command

This patch aligns the input parameter for Add Extended Advertisement
command with actual data struct and add missing flag descriptions.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
14 months agomonitor/att: Add LTV deconding support for PAC/ASE
Luiz Augusto von Dentz [Thu, 16 Jun 2022 22:59:12 +0000 (15:59 -0700)]
monitor/att: Add LTV deconding support for PAC/ASE

This adds decoding support for PAC/ASE attributes:

> ACL Data RX: Handle 42 flags 0x02 dlen 31
      Channel: 65 len 27 sdu 25 [PSM 39 mode Enhanced Credit (0x81)] {chan 1}
      ATT: Read Response (0x0b) len 24
        Value: 010600000000100301ff0002020302030305041e00f00000
          Number of PAC(s): 1
          PAC #0:
            Codec: LC3 (0x06)
            Codec Specific Capabilities #0: len 0x03 type 0x01
              Sampling Frequencies: 0x00ff
                8 Khz (0x0001)
                11.25 Khz (0x0002)
                16 Khz (0x0004)
                22.05 Khz (0x0008)
                24 Khz (0x0010)
                32 Khz (0x0020)
                44.1 Khz (0x0040)
                48 Khz (0x0080)
            Codec Specific Capabilities #1: len 0x02 type 0x02
              Frame Duration: 0x0003
                7.5 ms (0x01)
                10 ms (0x02)
            Codec Specific Capabilities #2: len 0x02 type 0x03
              Audio Channel Count: 0x03
                1 channel (0x01)
                2 channels (0x02)
            Codec Specific Capabilities #3: len 0x05 type 0x04
              Frame Length: 30 (0x001e) - 240 (0x00f0)
> ACL Data RX: Handle 42 flags 0x02 dlen 30
      Channel: 64 len 26 sdu 24 [PSM 39 mode Enhanced Credit (0x81)] {chan 0}
      ATT: Write Command (0x52) len 23
        Handle: 0x0036 Type: ASE Control Point (0x2bc6)
          Data: 010101020206000000000a02010302020103042800
            Opcode: Codec Configuration (0x01)
            Number of ASE(s): 1
            ASE: #0
            ASE ID: 0x01
            Target Latency: Balance Latency/Reliability (0x02)
            PHY: 0x02
            LE 2M PHY (0x02)
            Codec: LC3 (0x06)
            Codec Specific Configuration #0: len 0x02 type 0x01
            Sampling Frequency: 16 Khz (0x03)
            Codec Specific Configuration #1: len 0x02 type 0x02
            Frame Duration: 10 ms (0x01)
            Codec Specific Configuration #2: len 0x03 type 0x04
            Frame Length: 40 (0x0028)

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
14 months agomonitor/att: Add decoding support for PAC Audio Context
Luiz Augusto von Dentz [Thu, 16 Jun 2022 19:31:02 +0000 (12:31 -0700)]
monitor/att: Add decoding support for PAC Audio Context

This adds decoding support for PAC Audio Context attributes:

> ACL Data RX: Handle 42 flags 0x02 dlen 9
      Channel: 65 len 5 sdu 3 [PSM 39 mode Enhanced Credit (0x81)] {chan 1}
      ATT: Read Request (0x0a) len 2
        Handle: 0x0026 Type: Supported Audio Contexts (0x2bce)
< ACL Data TX: Handle 42 flags 0x00 dlen 11
      Channel: 64 len 7 sdu 5 [PSM 39 mode Enhanced Credit (0x81)] {chan 1}
      ATT: Read Response (0x0b) len 4
        Value: ff0f0e00
        Handle: 0x0026 Type: Supported Audio Contexts (0x2bce)
            Sink Context: 0x0fff
              Unspecified (0x0001)
              Conversational (0x0002)
              Media (0x0004)
              Game (0x0008)
              Instructional (0x0010)
              Voice Assistants (0x0020)
              Live (0x0040)
              Sound Effects (0x0080)
              Notifications (0x0100)
              Ringtone (0x0200)
              Alerts (0x0400)
              Emergency alarm (0x0800)
            Source Context: 0x000e
              Conversational (0x0002)
              Media (0x0004)
              Game (0x0008)

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
14 months agomonitor/att: Add decoding support for PAC Sink/Source Location
Luiz Augusto von Dentz [Wed, 15 Jun 2022 23:56:37 +0000 (16:56 -0700)]
monitor/att: Add decoding support for PAC Sink/Source Location

This adds decoding support for PAC Sink/Source Location attributes:

> ACL Data RX: Handle 42 flags 0x02 dlen 9
      Channel: 65 len 5 sdu 3 [PSM 39 mode Enhanced Credit (0x81)] {chan 1}
      ATT: Read Request (0x0a) len 2
        Handle: 0x001a Type: Sink Audio Locations (0x2bca)
< ACL Data TX: Handle 42 flags 0x00 dlen 11
      Channel: 64 len 7 sdu 5 [PSM 39 mode Enhanced Credit (0x81)] {chan 1}
      ATT: Read Response (0x0b) len 4
        Value: 03000000
        Handle: 0x001a Type: Sink Audio Locations (0x2bca)
           Location: 0x00000003
              Front Left (0x00000001)
              Front Right (0x00000002)

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
14 months agomonitor/att: Print attribute information on ATT_REQ_RSP
Luiz Augusto von Dentz [Fri, 17 Jun 2022 00:30:31 +0000 (17:30 -0700)]
monitor/att: Print attribute information on ATT_REQ_RSP

This prints the attribute information on ATT_REQ_RSP to make it easier
to identify to which handle the response is for:

> ACL Data RX: Handle 42 flags 0x02 dlen 9
      Channel: 65 len 5 sdu 3 [PSM 39 mode Enhanced Credit (0x81)] {chan 1}
      ATT: Read Response (0x0b) len 2
        Value: 0300
        Handle: 0x0030 Type: Source ASE (0x2bc5)
            ASE ID: 3
            State: Idle (0x00)

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
14 months agobluetoothd.rst: Document -K/--kernel option
Luiz Augusto von Dentz [Tue, 14 Jun 2022 21:55:00 +0000 (14:55 -0700)]
bluetoothd.rst: Document -K/--kernel option

This documents -K/--kernel experimental features options.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
14 months agomain.conf: Split Kernel Experimental UUIDs from Experimental
Luiz Augusto von Dentz [Tue, 14 Jun 2022 21:45:44 +0000 (14:45 -0700)]
main.conf: Split Kernel Experimental UUIDs from Experimental

This splits kernel experimental UUIDs from D-Bus Experimental interface
so they can be controlled indenpendetly.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
14 months agomesh: Fix keyring snprintf usage range checking
Brian Gix [Tue, 14 Jun 2022 17:13:38 +0000 (10:13 -0700)]
mesh: Fix keyring snprintf usage range checking

snprintf performs it's own range checking and returns a negative value
if string construction fails. Not checking the return value throws a
warning at compile time on GCC 12 and later. This patch removes
redundent range chacking and checks all snprintf return values.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
14 months agoadvertising: Fix attempting to set scan_rsp
Luiz Augusto von Dentz [Tue, 14 Jun 2022 18:38:56 +0000 (11:38 -0700)]
advertising: Fix attempting to set scan_rsp

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

  • If extended advertising PDU types are being used (bit 4 = 0) then:
  The advertisement shall not be both connectable and scannable.

So instead this attempts to set name as part of Advertising Data rather
then setting it as Scan Response:

bluetoothctl> advertise.secondary 2M
bluetoothctl> advertise.name Intel-3
bluetoothctl> advertise on

< HCI Command: LE Set Extended Advertising Parameters (0x08|0x0036) plen 25
        Handle: 0x01
        Properties: 0x0001
          Connectable
        Min advertising interval: 1280.000 msec (0x0800)
        Max advertising interval: 1280.000 msec (0x0800)
        Channel map: 37, 38, 39 (0x07)
        Own address type: Public (0x00)
        Peer address type: Public (0x00)
        Peer address: 00:00:00:00:00:00 (OUI 00-00-00)
        Filter policy: Allow Scan Request from Any, Allow Connect Request from Any (0x00)
        TX power: Host has no preference (0x7f)
        Primary PHY: LE 1M (0x01)
        Secondary max skip: 0x00
        Secondary PHY: LE 2M (0x02)
        SID: 0x00
        Scan request notifications: Disabled (0x00)
> HCI Event: Command Complete (0x0e) plen 5
      LE Set Extended Advertising Parameters (0x08|0x0036) ncmd 1
        Status: Success (0x00)
        TX power (selected): 7 dbm (0x07)
< HCI Command: LE Set Extended Advertising Data (0x08|0x0037) plen 4
        Handle: 0x01
        Operation: Complete extended advertising data (0x03)
        Fragment preference: Minimize fragmentation (0x01)
        Data length: 0x00
@ MGMT Event: Command Complete (0x0001) plen 7
      Add Extended Advertising Parameters (0x0054) plen 4
        Status: Success (0x00)
        Instance: 1
        TX power: 7 dbm (0x07)
        Available adv data len: 31
        Available scan rsp data len: 31
> HCI Event: Command Complete (0x0e) plen 4
      LE Set Extended Advertising Data (0x08|0x0037) ncmd 1
        Status: Success (0x00)
@ MGMT Command: Add Extended Advertising Data (0x0055) plen 23
        Instance: 1
        Advertising data length: 12
        Name (complete): Intel-3
        Flags: 0x06
          LE General Discoverable Mode
          BR/EDR Not Supported
        Scan response length: 0
< HCI Command: LE Set Extended Advertising Data (0x08|0x0037) plen 16
        Handle: 0x01
        Operation: Complete extended advertising data (0x03)
        Fragment preference: Minimize fragmentation (0x01)
        Data length: 0x0c
        Name (complete): Intel-3
        Flags: 0x06
          LE General Discoverable Mode
          BR/EDR Not Supported
> HCI Event: Command Complete (0x0e) plen 4
      LE Set Extended Advertising Data (0x08|0x0037) ncmd 1
        Status: Success (0x00)
< HCI Command: LE Set Extended Scan Response Data (0x08|0x0038) plen 4
        Handle: 0x01
        Operation: Complete scan response data (0x03)
        Fragment preference: Minimize fragmentation (0x01)
        Data length: 0x00
> HCI Event: Command Complete (0x0e) plen 4
      LE Set Extended Scan Response Data (0x08|0x0038) ncmd 1
        Status: Success (0x00)
< HCI Command: LE Set Extended Advertising Enable (0x08|0x0039) plen 6
        Extended advertising: Enabled (0x01)
        Number of sets: 1 (0x01)
        Entry 0
          Handle: 0x01
          Duration: 0 ms (0x00)
          Max ext adv events: 0
> HCI Event: Command Complete (0x0e) plen 4
      LE Set Extended Advertising Enable (0x08|0x0039) ncmd 2
        Status: Success (0x00)
@ MGMT Event: Command Complete (0x0001) plen 4
      Add Extended Advertising Data (0x0055) plen 1
        Status: Success (0x00)
        Instance: 1

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
14 months agomonitor/att: Fix decoding for notifications
Luiz Augusto von Dentz [Tue, 7 Jun 2022 22:24:31 +0000 (15:24 -0700)]
monitor/att: Fix decoding for notifications

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>