platform/upstream/bluez.git
2 years agomesh: Fix segmented msg RX with friendship
Brian Gix [Wed, 24 Mar 2021 19:34:12 +0000 (12:34 -0700)]
mesh: Fix segmented msg RX with friendship

This fixes an uninitialized memory issue where a message received for
a local node is silently discarded if an uninitialized boolean is
mistakenly set to TRUE, when friendships exist.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agodoc/mgmt-api: Update documentation for scan_rsp param flag
Daniel Winkler [Tue, 16 Mar 2021 22:49:57 +0000 (15:49 -0700)]
doc/mgmt-api: Update documentation for scan_rsp param flag

This patch adds the new scannable flag to the Add Extended Advertising
Parameters MGMT API documentation.

Reviewed-by: Alain Michaud <alainm@chromium.org>
Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org>
Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoadvertising: Create and use scannable adv param flag
Daniel Winkler [Tue, 16 Mar 2021 22:49:56 +0000 (15:49 -0700)]
advertising: Create and use scannable adv param flag

In order for the advertising parameters hci request to indicate that an
advertising set uses a scannable PDU, we pass a scannable flag along
with the initial parameters MGMT request. This flag is populated based
on the existence of any scan response data requested by the client.

Without this patch, a broadcast advertisement with a scan response will
either be rejected by the controller, or will ignore the requested scan
response. The patch is tested by performing the above and confirming
that the scan response is retrievable from a peer as expected.

Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org>
Reviewed-by: Miao-chen Chou <mcchou@chromium.org>
Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agomonitor: Add basic decoding for MSFT extension
Marcel Holtmann [Fri, 19 Mar 2021 19:29:51 +0000 (20:29 +0100)]
monitor: Add basic decoding for MSFT extension

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agomonitor: Add skeleton for Microsoft HCI extension
Marcel Holtmann [Fri, 19 Mar 2021 17:43:02 +0000 (18:43 +0100)]
monitor: Add skeleton for Microsoft HCI extension

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agotools: Add command for enabling/disabling LL privacy feature
Marcel Holtmann [Fri, 19 Mar 2021 16:59:47 +0000 (17:59 +0100)]
tools: Add command for enabling/disabling LL privacy feature

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agotools/mgmt-tester: Fix for scan response in read adv feature command
Tedd Ho-Jeong An [Thu, 18 Mar 2021 20:46:40 +0000 (13:46 -0700)]
tools/mgmt-tester: Fix for scan response in read adv feature command

This patch fixes the test failure with the read advertising feature
API which is changed to include the scan response flag.

 Read Advertising Features - Success 1 (No instance)  Failed
 Read Advertising Features - Success 2 (One instance) Failed
 Read Ext Advertising Features - Success 3 (PHY flags) Failed

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agomonitor: Add option to force output color
Sonny Sasaka [Tue, 16 Mar 2021 22:16:48 +0000 (15:16 -0700)]
monitor: Add option to force output color

Sometimes we want to force output color even when stdout is not a
terminal, for example when piping the output to a filter script and then
piping it further to a pager which can display colors.

This patch provides a general option to force whether color is on or off
(always and never), or leave btmon to decide (auto).

Reviewed-by: Daniel Winkler <danielwinkler@google.com>
Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agodoc/advertising-api: Add adv SupportedFeatures to doc
Daniel Winkler [Tue, 16 Mar 2021 23:22:17 +0000 (16:22 -0700)]
doc/advertising-api: Add adv SupportedFeatures to doc

Add supported features to advertising dbus api.

Reviewed-by: Miao-chen Chou <mcchou@chromium.org>
Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoclient: Add adv SupportedFeatures to bluetoothctl
Daniel Winkler [Tue, 16 Mar 2021 23:22:16 +0000 (16:22 -0700)]
client: Add adv SupportedFeatures to bluetoothctl

This change adds SupportedFeatures to be shown in "show" option of
bluetoothctl. It was tested with and without kernel support for features
to verify that they are shown or not shown correctly.

Change was tested by verifying SupportedFeatures were populated
correctly in bluetoothctl on hatch and kukui chromebooks

Reviewed-by: Miao-chen Chou <mcchou@chromium.org>
Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoadvertising: Add SupportedFeatures to LEAdvertisingManager1
Daniel Winkler [Tue, 16 Mar 2021 23:22:15 +0000 (16:22 -0700)]
advertising: Add SupportedFeatures to LEAdvertisingManager1

The new SupportedFeatures member tells advertising clients whether the
platform has hardware support for advertising or capability to set tx
power of advertisements.

Additionally, fix small typo in "secondary_exists" function name.

Change is tested on hatch and kukui chromebooks by using dbus-send to
verify that SupportedFeatures always exists, and is only populated when
extended advertising is available.

Reviewed-by: Miao-chen Chou <mcchou@chromium.org>
Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agobuild: Fix build with latest ELL tree
Luiz Augusto von Dentz [Tue, 16 Mar 2021 20:56:49 +0000 (13:56 -0700)]
build: Fix build with latest ELL tree

Latest ELL tree has introduced useful.h and main-private.h which are
required to build:

ell/cert-crypto.c:35:10: fatal error: useful.h: No such file or
directory
   35 | #include "useful.h"
         |          ^~~~~~~~~~
...

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agobtmgmt: Fix printing Set PHY Configuration command error
Ayush Garg [Tue, 16 Mar 2021 10:57:38 +0000 (16:27 +0530)]
btmgmt: Fix printing Set PHY Configuration command error

Error was printed as MGMT_OP_GET_PHY_CONFIGURATION instead of
MGMT_OP_SET_PHY_CONFIGURATION.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoshared/gatt-client: fix BT_ATT_OP_HANDLE_NFY_MULT parsing
Archie Pusaka [Tue, 16 Mar 2021 04:12:37 +0000 (12:12 +0800)]
shared/gatt-client: fix BT_ATT_OP_HANDLE_NFY_MULT parsing

We need to advance the pdu pointer after parsing each block of
notification data.

Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org>
Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoprofiles: Use timeout_add_seconds
Frédéric Danis [Tue, 16 Mar 2021 17:18:36 +0000 (18:18 +0100)]
profiles: Use timeout_add_seconds

Replace calls to g_timeout_add_seconds() by the timeout_add_seconds()
wrapper which takes care of 0 delay.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoplugins: Use timeout_add_seconds
Frédéric Danis [Tue, 16 Mar 2021 17:18:35 +0000 (18:18 +0100)]
plugins: Use timeout_add_seconds

Replace calls to g_timeout_add_seconds() by the timeout_add_seconds()
wrapper which takes care of 0 delay.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agocore: Use timeout_add_seconds
Frédéric Danis [Tue, 16 Mar 2021 17:18:34 +0000 (18:18 +0100)]
core: Use timeout_add_seconds

Replace calls to g_timeout_add_seconds() by the timeout_add_seconds()
wrapper which takes care of 0 delay.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoshared/timeout: Add timeout_add_seconds abstraction
Frédéric Danis [Tue, 16 Mar 2021 17:18:33 +0000 (18:18 +0100)]
shared/timeout: Add timeout_add_seconds abstraction

g_timeout_add_seconds() call doesn't ensure the time for the first call of
the timer if the delay is less or equal to 1 second.
In case of a 0 delay call g_idle_add() instead of g_timeout_add_seconds().

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoemulator: Periodic Advertising Command
Keyur Parekh [Thu, 11 Mar 2021 18:35:50 +0000 (10:35 -0800)]
emulator: Periodic Advertising Command

This adds support for Periodic Advertising HCI
command in the emulator. These changes are the
first step in making the emulator useful for
testing the LE Audio Broadcast feature

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agomonitor: Fix decoding Read Local Supported Codec Capabilities
Kiran K [Sun, 7 Mar 2021 09:18:45 +0000 (14:48 +0530)]
monitor: Fix decoding Read Local Supported Codec Capabilities

Codec capabilities wern't properly decoded due to wrong offset

< HCI Command: Read Local Supported Codec Capabilities (0x04|0x000e) plen 7
        Codec: A-law log (0x01)
        Logical Transport Type: 0x01
          Codec supported over BR/EDR ACL
        Direction: Input (Host to Controller) (0x00)
> HCI Event: Command Complete (0x0e) plen 18
      Read Local Supported Codec Capabilities (0x04|0x000e) ncmd 1
        Status: Success (0x00)
        Number of codec capabilities: 3
         Capabilities #0:
        aa bb cc dd                                      ....
         Capabilities #1:
        11 22 33 44 55                                   ."3DU
         Capabilities #2:
        ff                                               .

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoavdtp: Fix removing all remote SEPs when loading from cache
Luiz Augusto von Dentz [Thu, 11 Mar 2021 15:36:07 +0000 (07:36 -0800)]
avdtp: Fix removing all remote SEPs when loading from cache

If avdtp_discover is called after cache has been loaded it end up
removing all remote SEPs as they have not been discovered yet.

Fixes: https://github.com/bluez/bluez/issues/102
Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agomesh: Validate OTA provision security material
Brian Gix [Mon, 8 Mar 2021 23:36:53 +0000 (15:36 -0800)]
mesh: Validate OTA provision security material

When validating incoming security material, ensure that the data is
unique to the provisioning session.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agomonitor: Fix invalid access
Luiz Augusto von Dentz [Mon, 8 Mar 2021 22:08:16 +0000 (14:08 -0800)]
monitor: Fix invalid access

ident can be NULL when printing user logs which may lead ot invalid
access.

Fixes: https://github.com/bluez/bluez/issues/92
Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agomonitor: Decode Broadcom LM Diag vendor events
Marcel Holtmann [Sun, 7 Mar 2021 17:50:39 +0000 (18:50 +0100)]
monitor: Decode Broadcom LM Diag vendor events

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agomonitor: Fix random address decoding for extending advertising
Marcel Holtmann [Sun, 7 Mar 2021 17:27:14 +0000 (18:27 +0100)]
monitor: Fix random address decoding for extending advertising

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agomonitor: Add missing strings for management command codes
Marcel Holtmann [Sun, 7 Mar 2021 13:39:45 +0000 (14:39 +0100)]
monitor: Add missing strings for management command codes

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agogatt: Fix registering DIS without a valid source
Luiz Augusto von Dentz [Fri, 5 Mar 2021 22:23:44 +0000 (14:23 -0800)]
gatt: Fix registering DIS without a valid source

If source has not been set don't register DIS as it would not contain
any useful information and by doing this it actually allows systems to
register their own DIS instance.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agomain.conf: Enable passing false to DeviceID
Luiz Augusto von Dentz [Fri, 5 Mar 2021 22:56:47 +0000 (14:56 -0800)]
main.conf: Enable passing false to DeviceID

This adds support for setting DeviceID to false so plaforms can disable
DeviceID.

Fixes: https://github.com/bluez/bluez/issues/101
Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoadapter: Return Busy error when setting is pending
Luiz Augusto von Dentz [Thu, 4 Mar 2021 22:20:31 +0000 (14:20 -0800)]
adapter: Return Busy error when setting is pending

This returns an error if application attempts to change a property that
is pending.

Fixes: https://github.com/bluez/bluez/issues/99
Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoadapter: Fix not using the correct setting
Luiz Augusto von Dentz [Thu, 4 Mar 2021 22:17:40 +0000 (14:17 -0800)]
adapter: Fix not using the correct setting

set_mode shall use opcode to identify what setting are being changed
rather then the mode.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agocore: fix a typo in dev_connect
Howard Chung [Tue, 2 Mar 2021 02:25:51 +0000 (10:25 +0800)]
core: fix a typo in dev_connect

Based on the context, it should be 'at least' instead of 'at list'.

Reviewed-by: Alain Michaud <alainm@chromium.org>
Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoshared/gatt-server: Fix not properly checking for secure flags
Luiz Augusto von Dentz [Tue, 2 Mar 2021 19:38:33 +0000 (11:38 -0800)]
shared/gatt-server: Fix not properly checking for secure flags

When passing the mask to check_permissions all valid permissions for
the operation must be set including BT_ATT_PERM_SECURE flags.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agomonitor: Add option to set fallback width
Sonny Sasaka [Tue, 2 Mar 2021 00:40:19 +0000 (16:40 -0800)]
monitor: Add option to set fallback width

Sometimes we want to be able to pipe the output of btmon to a
non-terminal device. The current fallback width is usually not long
enough so this patch adds an option to specify the column width. This is
especially needed for text logs from bluetoothd.

Reviewed-by: Daniel Winkler <danielwinkler@google.com>
Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agobtdev: Add support for Configure Data Path
Luiz Augusto von Dentz [Tue, 2 Mar 2021 23:09:13 +0000 (15:09 -0800)]
btdev: Add support for Configure Data Path

> HCI Event: Command Complete (0x0e) plen 68
      Read Local Supported Commands (0x04|0x0002) ncmd 1
        Status: Success (0x00)
        Commands: 169 entries
...
          Configure Data Path (Octet 45 - Bit 5)

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agomonitor: Add support for decoding Configure Data Path
Luiz Augusto von Dentz [Tue, 2 Mar 2021 22:49:57 +0000 (14:49 -0800)]
monitor: Add support for decoding Configure Data Path

< HCI Command: Configure Data Path (0x03|0x0083) plen 3
        Direction: Input (Host to Controller) (0x00)
        ID: 0
        Vendor Specific Config Length: 0
        Vendor Specific Config:
> HCI Event: Command Complete (0x0e) plen 4
      Configure Data Path (0x03|0x0083) ncmd 1
        Status: Success (0x00)

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agobtdev: Add support Read Local Supported Controller Delay
Luiz Augusto von Dentz [Sat, 27 Feb 2021 01:00:49 +0000 (17:00 -0800)]
btdev: Add support Read Local Supported Controller Delay

> HCI Event: Command Complete (0x0e) plen 68
      Read Local Supported Commands (0x04|0x0002) ncmd 1
        Status: Success (0x00)
        Commands: 168 entries
...
          Read Local Supported Controller Delay (Octet 45 - Bit 4)

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agomonitor: Add support for decoding Read Local Controller Delay
Luiz Augusto von Dentz [Sat, 27 Feb 2021 00:55:44 +0000 (16:55 -0800)]
monitor: Add support for decoding Read Local Controller Delay

< HCI Command: Read Local Supported Controller Delay (0x04|0x000f) plen 8
        Codec: mSBC (0x05)
        Logical Transport Type: 0x02
          Codec supported over BR/EDR SCO and eSCO
        Direction: Input (Host to Controller) (0x00)
        Length Codec Configuration: 0
> HCI Event: Command Complete (0x0e) plen 10
      Read Local Supported Controller Delay (0x04|0x000f) ncmd 1
        Status: Success (0x00)
        Minimum Controller delay: 0 us (0x000000)
        Maximum Controller delay: 0 us (0x000000)

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agobtdev: Add support Read Local Supported Codec Capabilities
Luiz Augusto von Dentz [Fri, 26 Feb 2021 22:34:09 +0000 (14:34 -0800)]
btdev: Add support Read Local Supported Codec Capabilities

> HCI Event: Command Complete (0x0e) plen 68
      Read Local Supported Commands (0x04|0x0002) ncmd 1
        Status: Success (0x00)
        Commands: 167 entries
...
          Read Local Supported Codec Capabilities (Octet 45 - Bit 3)

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agomonitor: Add support for decoding Read Local Supported Codec Capabilities
Luiz Augusto von Dentz [Thu, 25 Feb 2021 23:20:28 +0000 (15:20 -0800)]
monitor: Add support for decoding Read Local Supported Codec Capabilities

< HCI Command: Read Local Supported Codec Capabilities (0x04|0x000e) plen 7
        Codec ID: mSBC (0x05)
        Logical Transport Type: 0x02
          Codec supported over BR/EDR SCO and eSCO
        Direction: Input (Host to Controller) (0x00)
> HCI Event: Command Complete (0x0e) plen 5
      Read Local Supported Codec Capabilities (0x04|0x000e) ncmd 1
        Status: Success (0x00)
        Number of codec capabilities: 0

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agobtdev: Add support Read Local Supported Codecs V2
Luiz Augusto von Dentz [Thu, 25 Feb 2021 01:40:20 +0000 (17:40 -0800)]
btdev: Add support Read Local Supported Codecs V2

> HCI Event: Command Complete (0x0e) plen 68
      Read Local Supported Commands (0x04|0x0002) ncmd 1
        Status: Success (0x00)
        Commands: 167 entries
...
          Read Local Supported Codecs V2 (Octet 45 - Bit 2)

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agomonitor: Add support for decoding Read Local Supported Codecs V2
Luiz Augusto von Dentz [Thu, 25 Feb 2021 00:50:01 +0000 (16:50 -0800)]
monitor: Add support for decoding Read Local Supported Codecs V2

< HCI Command: Read Local Supported Codecs V2 (0x04|0x000d) plen 0
> HCI Event: Command Complete (0x0e) plen 18
      Read Local Supported Codecs V2 (0x04|0x000d) ncmd 1
        Status: Success (0x00)
        Number of supported codecs: 6
          Codec: u-law log (0x00)
          Logical Transport Type: 0x02
            Codec supported over BR/EDR SCO and eSCO
          Codec: A-law log (0x01)
          Logical Transport Type: 0x02
            Codec supported over BR/EDR SCO and eSCO
          Codec: CVSD (0x02)
          Logical Transport Type: 0x02
            Codec supported over BR/EDR SCO and eSCO
          Codec: Transparent (0x03)
          Logical Transport Type: 0x02
            Codec supported over BR/EDR SCO and eSCO
          Codec: Linear PCM (0x04)
          Logical Transport Type: 0x02
            Codec supported over BR/EDR SCO and eSCO
          Codec: mSBC (0x05)
          Logical Transport Type: 0x02
            Codec supported over BR/EDR SCO and eSCO
        Number of vendor codecs: 0

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agomonitor: Rename big_id fields to handle
Luiz Augusto von Dentz [Mon, 1 Mar 2021 22:33:35 +0000 (14:33 -0800)]
monitor: Rename big_id fields to handle

This makes it aligned to the terminology used by the spec.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agomonitor: Fix BIG Create Sync decoding
Luiz Augusto von Dentz [Mon, 1 Mar 2021 22:15:25 +0000 (14:15 -0800)]
monitor: Fix BIG Create Sync decoding

Number of Bis is actually at the end of the PDU, also avoid prefixing with
big when it is implied by the struct name.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agomonitor: Rename big_id field to handle
Luiz Augusto von Dentz [Wed, 24 Feb 2021 23:26:15 +0000 (15:26 -0800)]
monitor: Rename big_id field to handle

This avoids prefixing with big when it is implied by the struct name.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agomesh: Fix infinite loop on IVIndex update
Przemysław Fierek [Fri, 26 Feb 2021 13:27:40 +0000 (14:27 +0100)]
mesh: Fix infinite loop on IVIndex update

This patch fixes inifinite loop problem caused by recurring call
of the `net_key_beacon_refresh` function.

Problem occurs when at least two nodes are connected to the same
BlueZ instance and they are connected to the same network
(use same network key). Issue is triggered when IVIndex update
process stabilize and one of the nodes receives network beacon
with IVUpdate flag set to 0. Then it processes the "local" beacon
and compose new `snb` (with IVUpdate flag set to 0) attached to
`net_key` instance. After that it calls `net_local_beacon` and
another node processes the new beacon (this node has IVUpdate
flag still set to 1). Note that the `net->ivupdate` has set value 1.
The `update_iv_ivu_state` says that "IVU clear attempted too soon".
The node composes new `snb` with IVUpdate flag set to 1 and writes
it to the `net_key` instance in the `net_key_beacon_refresh`
function. After that it calls `net_local_beacon` which causes
repeat of all process. We are rotating in this loop until end-of-memory.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agotools: Cleanup deprecated symbolic file permissions
Brian Gix [Tue, 23 Feb 2021 18:51:20 +0000 (10:51 -0800)]
tools: Cleanup deprecated symbolic file permissions

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agosrc: Cleanup deprecated symbolic file permissions
Brian Gix [Tue, 23 Feb 2021 18:46:15 +0000 (10:46 -0800)]
src: Cleanup deprecated symbolic file permissions

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoprofiles: Cleanup deprecated symbolic file permissions
Brian Gix [Tue, 23 Feb 2021 18:45:02 +0000 (10:45 -0800)]
profiles: Cleanup deprecated symbolic file permissions

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoperipheral: Cleanup deprecated symbolic file permissions
Brian Gix [Tue, 23 Feb 2021 18:43:42 +0000 (10:43 -0800)]
peripheral: Cleanup deprecated symbolic file permissions

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoobexd: Cleanup deprecated symbolic file permissions
Brian Gix [Tue, 23 Feb 2021 18:36:38 +0000 (10:36 -0800)]
obexd: Cleanup deprecated symbolic file permissions

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agomesh: Cleanup deprecated symbolic file permissions
Brian Gix [Tue, 23 Feb 2021 18:39:57 +0000 (10:39 -0800)]
mesh: Cleanup deprecated symbolic file permissions

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agomonitor: Fix handling of BT_HCI_EVT_LE_BIG_SYNC_ESTABILISHED
Luiz Augusto von Dentz [Tue, 23 Feb 2021 19:07:16 +0000 (11:07 -0800)]
monitor: Fix handling of BT_HCI_EVT_LE_BIG_SYNC_ESTABILISHED

This adds the missing fields for BT_HCI_EVT_LE_BIG_SYNC_ESTABILISHED
event.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agomonitor: Fix handling of BT_HCI_EVT_LE_BIG_COMPLETE
Luiz Augusto von Dentz [Tue, 23 Feb 2021 19:02:53 +0000 (11:02 -0800)]
monitor: Fix handling of BT_HCI_EVT_LE_BIG_COMPLETE

This adds the missing fields for BT_HCI_EVT_LE_BIG_COMPLETE event.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoRelease 5.56
Marcel Holtmann [Mon, 22 Feb 2021 20:12:40 +0000 (21:12 +0100)]
Release 5.56

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agobuild: Update library version
Marcel Holtmann [Mon, 22 Feb 2021 20:00:05 +0000 (21:00 +0100)]
build: Update library version

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoadapter: fix set_mode MGMT_OP_SET_BONDABLE
Archie Pusaka [Mon, 22 Feb 2021 06:07:43 +0000 (14:07 +0800)]
adapter: fix set_mode MGMT_OP_SET_BONDABLE

Currently pending_settings is assigned MGMT_SETTING_DISCOVERABLE,
but it should have been MGMT_SETTING_BONDABLE instead.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoadapter: Check whether adapter is pending powered
Archie Pusaka [Mon, 22 Feb 2021 05:18:45 +0000 (13:18 +0800)]
adapter: Check whether adapter is pending powered

The powered setting of adapter is frequently being checked, but the
check only accounts for whether it currently is powered. When powering
off the adapter, there is a brief moment when the adapter is already
off kernel-wise, but powered property is still true.

If powered property is accessed at this time, some problems might
occur. For example, if RemoveDevice DBus API is called, we would still
carry out the request and remove the device from the user space, but
we would fail to remove it from the kernel, therefore resulting an
error when we want to re-pair the device.

This patch addresses this issue by also checking whether adapter is
being powered off when checking for powered.

Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org>
Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agogatt-database: Fix notifying on indicatable attr
Curtis [Fri, 19 Feb 2021 17:49:46 +0000 (12:49 -0500)]
gatt-database: Fix notifying on indicatable attr

When a local GATT characteristic has both the indicate and notify
properties, notifications will not be send to clients requesting them.
This change fixes this, allowing for notifications to be sent.

Also simplifies logic about when notifications/indications should
be sent.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agosixaxis: Fix Bluetooth PS3 clone joypad being named like the original
Szymon Janc [Thu, 11 Feb 2021 15:39:13 +0000 (16:39 +0100)]
sixaxis: Fix Bluetooth PS3 clone joypad being named like the original

When cable pairing a PS3 clone device, we should try and keep the USB device
name to create a new btd_device so that the joypad is named after its USB name
when connecting through Bluetooth.

If that isn't done, "Shanwan" clone joypads are named like the genuine joypads, and
kernel Bluetooth quirks aren't applied.

gh-issue: https://github.com/bluez/bluez/issues/46
Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agobtdev: Fix not sending ISO packets
Luiz Augusto von Dentz [Fri, 19 Feb 2021 23:19:25 +0000 (15:19 -0800)]
btdev: Fix not sending ISO packets

ISO packets were not correctly parsed causing them to not be sent
properly.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoemulator: Add option for enabling debug with btvirt
Luiz Augusto von Dentz [Fri, 19 Feb 2021 23:18:24 +0000 (15:18 -0800)]
emulator: Add option for enabling debug with btvirt

This adds -d/--debug options which enables debug of vhci instance on
btvirt.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agovhci: Add vhci_set_debug
Luiz Augusto von Dentz [Fri, 19 Feb 2021 23:17:02 +0000 (15:17 -0800)]
vhci: Add vhci_set_debug

This enables debug with btdev_set_debug.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agomesh: Combine common functions for NetKeys and AppKeys
Inga Stotland [Thu, 18 Feb 2021 00:39:56 +0000 (16:39 -0800)]
mesh: Combine common functions for NetKeys and AppKeys

No change in functionality, code tightening.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoavdtp: Remove use of G_PRIORITY_LOW
Luiz Augusto von Dentz [Tue, 16 Feb 2021 22:55:45 +0000 (14:55 -0800)]
avdtp: Remove use of G_PRIORITY_LOW

G_PRIORITY_LOW was used in order to prioritize the AVDTP media transport
channel over the signalling channel but this has the side effect of
delaying the dispatching of other conditions such as HUP/NVAL, so now
that BtIO use G_PRIORITY_HIGH for its watches we no longer need to
deprioritize session_cb.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agobtio: Use G_PRIORITY_HIGH for watches
Luiz Augusto von Dentz [Tue, 16 Feb 2021 22:51:04 +0000 (14:51 -0800)]
btio: Use G_PRIORITY_HIGH for watches

This makes btio watches default to G_PRIORITY_HIGH instead of
G_PRIORITY_DEFAULT so it takes priority over regular traffic or
timeout handling.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoavdtp: Fix setting disconnect timer when there is no local endpoints
Luiz Augusto von Dentz [Tue, 16 Feb 2021 22:02:10 +0000 (14:02 -0800)]
avdtp: Fix setting disconnect timer when there is no local endpoints

If there are not local endpoints left there is no point in starting
the disconnect timer as without any endpoint it is not possible to
configure streams anymore so the code should proceed to disconnect
immediately.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agotools/mesh-cfg-client:
Inga Stotland [Fri, 12 Feb 2021 21:42:44 +0000 (13:42 -0800)]
tools/mesh-cfg-client:

Make sure that the values of Device UUID supplied in
CreateNetwork and AddRemoteNode methods are compliant with
RFC 4122.
Also, use a compliant value for Mesh UUID.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agotest/test-mesh: Generate correct value for Device UUID
Inga Stotland [Fri, 12 Feb 2021 21:42:43 +0000 (13:42 -0800)]
test/test-mesh: Generate correct value for Device UUID

This ensures that the value of Device UUID when invoking
Join method is compliant with RFC 4122.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agomesh: Add validation of Device UUID value
Inga Stotland [Fri, 12 Feb 2021 21:42:42 +0000 (13:42 -0800)]
mesh: Add validation of Device UUID value

Validate that the value of Device UUID supplied in
CreateNetwork/Join/Import methods is compliant with RFC 4122.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agodoc/mesh-api: Add notion of Device UUID compliance
Inga Stotland [Fri, 12 Feb 2021 21:42:41 +0000 (13:42 -0800)]
doc/mesh-api: Add notion of Device UUID compliance

Add requirement that the value of Device UUID supplied in
CreateNetwork/Join/Import methods should be compliant with
RFC 4122.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agomesh: Clear node's agent pointer after agent removal
Inga Stotland [Thu, 11 Feb 2021 02:55:58 +0000 (18:55 -0800)]
mesh: Clear node's agent pointer after agent removal

When a node is created/provisioned/imported, the new node's agent
is removed. The corresponding pointer in the node structure needs
to be set to NULL to avoid pointing to freed memory.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoa2dp: set session to NULL when freeing channel
Archie Pusaka [Fri, 5 Feb 2021 03:47:46 +0000 (11:47 +0800)]
a2dp: set session to NULL when freeing channel

There is a possibility that avdtp_channel is freed when avdtp_setup
is not yet freed. This could cause crashes because setup->chan will
then point to an invalid address.

Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agotools/bluemoon: Add support for checking other firmware file types
Tedd Ho-Jeong An [Tue, 2 Feb 2021 03:40:05 +0000 (19:40 -0800)]
tools/bluemoon: Add support for checking other firmware file types

There are more firmware files for Intel devices like .ddc, and .bseq.
This patch checks the file extension and analyze the firmware file.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agotools/bluemoon: Display FW version of firmware file
Tedd Ho-Jeong An [Tue, 2 Feb 2021 03:40:04 +0000 (19:40 -0800)]
tools/bluemoon: Display FW version of firmware file

This patch displays a FW version after parsing the WRITE_BOOT_PARAMS
command in the firmeare file. It also change the display type for
Module vendor and Date in the CSS header to hex for easy read.

Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agobuild: Fix build error with missing ell/pkcs5.h
Luiz Augusto von Dentz [Tue, 26 Jan 2021 23:45:53 +0000 (15:45 -0800)]
build: Fix build error with missing ell/pkcs5.h

./ell/ell.h:24:10: fatal error: ell/pkcs5.h: No such file or directory
   24 | #include <ell/pkcs5.h>
      |          ^~~~~~~~~~~~~

Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agobuild: Fix undefined references when using slibtool
Luiz Augusto von Dentz [Tue, 26 Jan 2021 19:20:05 +0000 (11:20 -0800)]
build: Fix undefined references when using slibtool

gh issue: https://github.com/bluez/bluez/issues/86

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoELL: Up-rev the ELL file list to version Rel 0.37
Brian Gix [Thu, 14 Jan 2021 21:09:24 +0000 (13:09 -0800)]
ELL: Up-rev the ELL file list to version Rel 0.37

This has no functional change.  It simply changes the ELL file list used
for the statically linked version of ELL into BlueZ executables.

Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agotools: Fix static analysis warnings
Brian Gix [Fri, 22 Jan 2021 19:40:14 +0000 (11:40 -0800)]
tools: Fix static analysis warnings

Usage of potentially NULL pointers

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoinput/hog: Fix double registering report value callbacks
Sonny Sasaka [Mon, 25 Jan 2021 19:33:54 +0000 (11:33 -0800)]
input/hog: Fix double registering report value callbacks

In commit 23b69ab3e484 ("input/hog: Cache the HID report map"), we
optimized HOG reconnection by registering report value callbacks early,
but there was a bug where we also re-register the same report value
callbacks after at CCC write callback. We should handle this case by
avoiding the second callback register if we know we have done it
earlier.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agobtdev: Fix auto-disable Extended Adv Set
Luiz Augusto von Dentz [Fri, 22 Jan 2021 22:46:30 +0000 (14:46 -0800)]
btdev: Fix auto-disable Extended Adv Set

For a Set to be disable there is a dedicated event that terminates the
set otherwise it should be considered enabled even when connected.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agobtdev: Fix using CIG settings from the peripheral not the central
Luiz Augusto von Dentz [Tue, 19 Jan 2021 21:51:12 +0000 (13:51 -0800)]
btdev: Fix using CIG settings from the peripheral not the central

SetCIGParameters is only used by the central while accept/reject CIS is
performed on in the peripheral so le_cis_estabilished shall use the
parameters set in the conn->link->dev.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agogatt: Fix crash when a device is removed
Luiz Augusto von Dentz [Tue, 19 Jan 2021 19:29:51 +0000 (11:29 -0800)]
gatt: Fix crash when a device is removed

If a device is removed with notifications enabled that would lead to
device_state being freed while att_disconnected has not been called
yet.

gh-issue: https://github.com/bluez/bluez/issues/82
Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agomonitor: Decode add advmon with RSSI parameter
Archie Pusaka [Fri, 15 Jan 2021 11:50:45 +0000 (19:50 +0800)]
monitor: Decode add advmon with RSSI parameter

Add support for MGMT command of add advertisement monitor with RSSI
parameter (0x0056).

@ MGMT Command: Add Advertisement.. (0x0056) plen 76  {0x0003}
        RSSI data:
          high threshold: 1 dBm
          high timeout: 0 seconds
          low threshold: -2 dBm
          low timeout: 3 seconds
          sampling: just once (0xFF)
        Number of patterns: 2
          Pattern 1:
            AD type: 0
            Offset: 1
            Length: 2
            Value : c504
          Pattern 2:
            AD type: 255
            Offset: 10
            Length: 4
            Value : 9a55beef

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agobluetoothctl: advmon rssi support for mgmt
Archie Pusaka [Fri, 15 Jan 2021 11:50:43 +0000 (19:50 +0800)]
bluetoothctl: advmon rssi support for mgmt

Using the new opcode MGMT_OP_ADD_ADV_PATTERNS_MONITOR_RSSI to
monitor advertisement according to some RSSI criteria.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agobtmgmt: advmon add rssi support
Archie Pusaka [Fri, 15 Jan 2021 11:50:41 +0000 (19:50 +0800)]
btmgmt: advmon add rssi support

Using the new opcode MGMT_OP_ADD_ADV_PATTERNS_MONITOR_RSSI to
monitor advertisement according to some RSSI criteria.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agosrc/adv_monitor: add monitor with rssi support for mgmt
Archie Pusaka [Fri, 15 Jan 2021 11:50:39 +0000 (19:50 +0800)]
src/adv_monitor: add monitor with rssi support for mgmt

Using the new opcode MGMT_OP_ADD_ADV_PATTERNS_MONITOR_RSSI to
monitor advertisement according to some RSSI criteria.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agodoc/advmon-api: Introduce sampling period property
Archie Pusaka [Fri, 15 Jan 2021 11:50:37 +0000 (19:50 +0800)]
doc/advmon-api: Introduce sampling period property

The sampling period is used to align with the new MGMT opcode which
also have sampling period.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agolib/mgmt: Adding Add Adv Patterns Monitor RSSI opcode
Archie Pusaka [Fri, 15 Jan 2021 11:50:34 +0000 (19:50 +0800)]
lib/mgmt: Adding Add Adv Patterns Monitor RSSI opcode

The new op is to utilize RSSI in advertisement monitor

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoshared/crypto: Transform bt_cryto in a singleton
Luiz Augusto von Dentz [Fri, 15 Jan 2021 18:52:42 +0000 (10:52 -0800)]
shared/crypto: Transform bt_cryto in a singleton

This makes bt_crypto always return the same instance thus avoiding the
problem of having multiple PF sockets opened which may hit the file
descriptor limit.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoemulator: Fix sending CIS Requested to Create CIS device
Luiz Augusto von Dentz [Thu, 14 Jan 2021 20:54:13 +0000 (12:54 -0800)]
emulator: Fix sending CIS Requested to Create CIS device

CIS Requested shall be send to the remote peer not the originating one.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agogatt: Fix assuming service changed has been subscribed
Luiz Augusto von Dentz [Fri, 8 Jan 2021 21:08:25 +0000 (13:08 -0800)]
gatt: Fix assuming service changed has been subscribed

Unfortunately assuming service changed has been subscribed may cause
indication to time out in some peripherals (Logitech M720 Triathlon, Mx
Anywhere 2, Lenovo Mice N700, RAPOO BleMouse and Microsoft Designer
Mouse) even though the expect actually mandates that the client responds
with confirmation these peripherals just ignores it completely which
leads them to be disconnected whenever bluetoothd is restarted or the
system reboots.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agodevice: Enable ATT layer debugging
Luiz Augusto von Dentz [Fri, 8 Jan 2021 18:57:04 +0000 (10:57 -0800)]
device: Enable ATT layer debugging

This uses bt_att_set_debug to enable ATT debugging which is useful for
detecting error such as an ATT transaction timing out.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoshared/att: Add debug level to bt_att_set_debug
Luiz Augusto von Dentz [Fri, 8 Jan 2021 18:54:24 +0000 (10:54 -0800)]
shared/att: Add debug level to bt_att_set_debug

This creates different levels of debugging which can be passed to
bt_att_set_debug as depending on the application it may not need to
print everything which can pollute the logs quite a bit.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoutil: Introduce util_debug_va
Luiz Augusto von Dentz [Fri, 8 Jan 2021 18:51:58 +0000 (10:51 -0800)]
util: Introduce util_debug_va

This introduces util_debug_va which can take a va_list that enables
callers to create wrapper functions if they need to.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoshared/gatt-server: Fix not accepting multiple requests
Luiz Augusto von Dentz [Wed, 6 Jan 2021 23:22:41 +0000 (15:22 -0800)]
shared/gatt-server: Fix not accepting multiple requests

With introduction of EATT it is possible to send multiple requests using
different channels therefore bt_gatt_server shall not attempt to check
if there is already an outstanding request.

gh issue: https://github.com/bluez/bluez/issues/75

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoadapter: Remove temporary devices before power off
Archie Pusaka [Wed, 6 Jan 2021 09:26:58 +0000 (17:26 +0800)]
adapter: Remove temporary devices before power off

If adapter is powered off when a currently connected device is
being removed, there is a possibility that we haven't finish waiting
for the disconnection but the adapter is already powered down.

When this happens, the kernel would fail to clean the device's
information, for example the pairing information. This causes
disagreement between the user space and the kernel about whether the
device is already paired, because the device is successfully removed
from the user space's perspective.

This patch enforces the removal of such devices before allowing the
adapter to power off.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agogatt: Make use of gatt_db_attribute_set_fixed_length
Luiz Augusto von Dentz [Wed, 6 Jan 2021 00:45:37 +0000 (16:45 -0800)]
gatt: Make use of gatt_db_attribute_set_fixed_length

This makes use of gatt_db_attribute_set_fixed_length so the database is
aware of the length of the values and perform bounds checking.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoshared/gatt-db: Introduce gatt_db_attribute_set_fixed_length
Luiz Augusto von Dentz [Wed, 6 Jan 2021 00:38:03 +0000 (16:38 -0800)]
shared/gatt-db: Introduce gatt_db_attribute_set_fixed_length

This enables user to inform if an attribute has a fixed length so it can
automatically perform bounds checking.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoshared/mgmt: Fix memory leak in mgmt_tlv_list
Howard Chung [Tue, 5 Jan 2021 03:12:57 +0000 (11:12 +0800)]
shared/mgmt: Fix memory leak in mgmt_tlv_list

This patch freed the mgmt_tlv properly in mgmt_tlv_list_free.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agobtmgmt: Add command set-sysconfig
Howard Chung [Tue, 5 Jan 2021 03:12:56 +0000 (11:12 +0800)]
btmgmt: Add command set-sysconfig

Add command set-sysconfig in btmgmt

Example usage:
[mgmt]# set-sysconfig -h
Parameters:
        -v <type:length:value>...
e.g.:
        set-sysconfig -v 001a:2:1234 001f:1:00
[mgmt]# set-sysconfig -v 8:2:abcd 1:02:0100 0016:2:0600

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>