platform/upstream/bluez.git
2 years agodevice: Include detailed error string in Connect() return
Miao-chen Chou [Thu, 30 Sep 2021 22:37:28 +0000 (15:37 -0700)]
device: Include detailed error string in Connect() return

This replaces generic strerror message with context detailed error
string to better indicate the detailed failure reason so that the D-Bus
clients can optimize their application to work better with BlueZ, e.g.
introducing retry mechanism or building metrics.

Reviewed-by: Alain Michaud <alainm@chromium.org>
Reviewed-by: Howard Chung <howardchung@google.com>
Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoerror: BR/EDR and LE connection failure reasons
Miao-chen Chou [Thu, 30 Sep 2021 22:37:26 +0000 (15:37 -0700)]
error: BR/EDR and LE connection failure reasons

The source of Connect() failures can be divided into the following
three.
- bluetoothd's device interface state transition and profile state
  transition
- Kernel's L2CAP layer state transition
- Potential HCI error codes returned by the remote device

Reviewed-by: Alain Michaud <alainm@chromium.org>
Reviewed-by: Howard Chung <howardchung@google.com>
Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agodoc: Add errors.txt to describe errors of D-Bus method returns
Miao-chen Chou [Thu, 30 Sep 2021 22:37:24 +0000 (15:37 -0700)]
doc: Add errors.txt to describe errors of D-Bus method returns

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoadv_monitor: Mark the device as lost on device_lost_timeout
Manish Mandlik [Wed, 22 Sep 2021 01:13:23 +0000 (18:13 -0700)]
adv_monitor: Mark the device as lost on device_lost_timeout

Mark the device as lost on device_lost_timeout so that it can be found
again next time.

Verified this by adding a monitor using bluetoothctl and confirming that
the DeviceLost event is getting triggered when bt peer stops advertising
and DeviceFound event gets triggered again when the bt peer restarts the
advertising.

Reviewed-by: Yun-Hao Chung <howardchung@google.com>
Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agogatt: Allow GATT server to dicate CCC permissions
Dagan Martinez [Fri, 1 Oct 2021 14:17:18 +0000 (10:17 -0400)]
gatt: Allow GATT server to dicate CCC permissions

Allow a GATT server to impose write permissions/restrictions on a CCC by
setting additional `X-notify` and `X-indicate` flags on its associated
characteristic.

This allows a developer to require encryption/authentication in order
for a GATT client to subscribe to server-initiated updates.

```
[bluetooth]# register-characteristic\
4b75f0f8-1f23-46b1-900c-5bbabcd5ca93 encrypt-read,encrypt-notify

[NEW] Characteristic (Handle 0x0000)
        /org/bluez/app/service0/chrc17
        4b75f0f8-1f23-46b1-900c-5bbabcd5ca93
        Vendor specific
[/org/bluez/app/service0/chrc17] Enter value: 42
```

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agodoc/gatt-api: Add 'X-notify`/`X-indicate`
Dagan Martinez [Fri, 1 Oct 2021 14:17:19 +0000 (10:17 -0400)]
doc/gatt-api: Add 'X-notify`/`X-indicate`

Update docs to reflect the addition of the `X-notify` and `X-indicate`
characteristic flags, which allow a GATT server to restrict CCC write
permissions.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agotools/mgmt-tester: Add suspend/resume test cases
Tedd Ho-Jeong An [Tue, 28 Sep 2021 01:38:20 +0000 (18:38 -0700)]
tools/mgmt-tester: Add suspend/resume test cases

This patch adds the suspend/resume test cases:

Suspend/Resume - Success 1 (Suspend)
Suspend/Resume - Success 2 (Resume)
Suspend/Resume - Success 3 (Device in WL)
Suspend/Resume - Success 4 (Advertising)
Suspend/Resume - Success 5 (Pairing - Legacy)
Suspend/Resume - Success 6 (Pairing - SSP)

Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agotools/mgmt-tester: Fix Read Experiemental Feature test case
Tedd Ho-Jeong An [Wed, 29 Sep 2021 21:00:49 +0000 (14:00 -0700)]
tools/mgmt-tester: Fix Read Experiemental Feature test case

The quality report feature is supported only if the device support it.
Current emulator/btdev doesn't support it yet.

This patch updates the supported experimental feature list to align with
the current btdev implementation.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agogatt: Fix not cleaning up when disconnected
Bernie Conrad [Tue, 28 Sep 2021 23:00:15 +0000 (16:00 -0700)]
gatt: Fix not cleaning up when disconnected

There is a current use after free possible on a gatt server if a client
disconnects while a WriteValue call is being processed with dbus.

This patch includes the addition of a pending disconnect callback to handle
cleanup better if a disconnect occurs during a write, an acquire write
or read operation using bt_att_register_disconnect with the cb.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoclient: Print MTU on attribute-info
Luiz Augusto von Dentz [Tue, 28 Sep 2021 23:53:08 +0000 (16:53 -0700)]
client: Print MTU on attribute-info

This prints the MTU of the characteristic when available.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agogatt: Emit PropertiesChanged("MTU") when MTU is exchanged
Luiz Augusto von Dentz [Tue, 28 Sep 2021 23:42:58 +0000 (16:42 -0700)]
gatt: Emit PropertiesChanged("MTU") when MTU is exchanged

This notifies client when the ATT MTU changes.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoshared/att: Add bt_att_register_exchange
Luiz Augusto von Dentz [Tue, 28 Sep 2021 23:07:10 +0000 (16:07 -0700)]
shared/att: Add bt_att_register_exchange

This adds bt_att_register_exchange which can be used to register
handlers that gets notified when the MTU gets changed via MTU exchange
procedure.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agogatt: Add implementation of GattCharacteristic1.MTU
Luiz Augusto von Dentz [Tue, 28 Sep 2021 22:45:05 +0000 (15:45 -0700)]
gatt: Add implementation of GattCharacteristic1.MTU

This implements MTU property in GattCharacteristic1 interface.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agogatt-api: Add MTU property to GattCharacteristic1
Luiz Augusto von Dentz [Tue, 28 Sep 2021 22:42:46 +0000 (15:42 -0700)]
gatt-api: Add MTU property to GattCharacteristic1

This adds MTU properyt to GattCharacteristic1 which can be used in
order to determine how much data can be read/write using non-long
procedures which sometimes is the only thing the remote device
supports.

Fixes: https://github.com/bluez/bluez/issues/199
Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agodoc/tester-config: Enable KASAN
Luiz Augusto von Dentz [Mon, 27 Sep 2021 22:20:36 +0000 (15:20 -0700)]
doc/tester-config: Enable KASAN

This patch adds CONFIG_KASAN=y in tester config.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agodoc/tester-config: Enable Android Extension
Luiz Augusto von Dentz [Mon, 27 Sep 2021 22:19:55 +0000 (15:19 -0700)]
doc/tester-config: Enable Android Extension

This patch adds Android Extension in tester config.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agodoc/tester-config: Enable Microsoft Extension
Tedd Ho-Jeong An [Mon, 27 Sep 2021 22:13:07 +0000 (15:13 -0700)]
doc/tester-config: Enable Microsoft Extension

This patch adds Microsoft Extension in tester config.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agotools/mesh-cfgclient: Export configuration database
Inga Stotland [Thu, 23 Sep 2021 03:26:03 +0000 (20:26 -0700)]
tools/mesh-cfgclient: Export configuration database

This adds main menu command "export-db".
When the command is invoked, JSON configuration object is
cloned and trimmed of extraneous properties.
Information about netkeys, appkeys and device keys are obtained
from bluetooth-meshd by calling ExportKeys() method.
The obtained key values are recorded in the export JSON object.

Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agotools/mesh-cfgclient: Excluded addresses property
Inga Stotland [Thu, 23 Sep 2021 03:26:02 +0000 (20:26 -0700)]
tools/mesh-cfgclient: Excluded addresses property

The correct name for a property that contains a list of addresses
not allowed in circulation is "networkExclusions"
The "excluded" property in "nodes" array entry is used to indicated that
this node has been removed from a mesh network and it's address should not
be re-used.

Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agotools/mesh-cfgclient: Store UUIDs in standard format
Inga Stotland [Thu, 23 Sep 2021 03:26:01 +0000 (20:26 -0700)]
tools/mesh-cfgclient: Store UUIDs in standard format

Use standard xxxx-xx-xx-xx-xxxxxxxx format for string
representation of mesh and node UUIDs in stored configuration.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agomesh: Implement ExportKeys() method
Inga Stotland [Thu, 23 Sep 2021 03:26:00 +0000 (20:26 -0700)]
mesh: Implement ExportKeys() method

Add implementation for new method ExportKeys() on
org.bluez.mesh.Management1 interface.
This method is used by the authorized application to export information
about network keys, application keys and device keys present in the
local key database.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agodoc/mesh-api: Add ExportKeys call
Inga Stotland [Thu, 23 Sep 2021 03:25:59 +0000 (20:25 -0700)]
doc/mesh-api: Add ExportKeys call

Add description for a new method:
ExportKeys() on org.bluez.mesh.Management1 interface.

This method is used by the authorized application to export information
about network keys, application keys and device keys present in the local
key database.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agotools/mesh-cfgclient: Add group parent address for DB compliance
Inga Stotland [Thu, 23 Sep 2021 03:25:58 +0000 (20:25 -0700)]
tools/mesh-cfgclient: Add group parent address for DB compliance

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agotools/mesh-cfgclient: Store remote's heartbeat sub/pub
Inga Stotland [Thu, 23 Sep 2021 03:25:57 +0000 (20:25 -0700)]
tools/mesh-cfgclient: Store remote's heartbeat sub/pub

Store remote node's heartbeat publication or subscription info upon
receiving CONFIG_HEARTBEAT_PUB_STATUS or CONFIG_HEARTBEAT_SUB_STATUS
messages when the messages' status code is set to Success.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agotools/mesh-cfgclient: Save remote node feature setting
Inga Stotland [Thu, 23 Sep 2021 03:25:56 +0000 (20:25 -0700)]
tools/mesh-cfgclient: Save remote node feature setting

Save the information for remote node's relay, friend, proxy and
secure network beacon settings.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agotools/mesh-cfgclient: Rename mesh-db APIs for consistency
Inga Stotland [Thu, 23 Sep 2021 03:25:55 +0000 (20:25 -0700)]
tools/mesh-cfgclient: Rename mesh-db APIs for consistency

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agotools/mesh-cfgclient: Check the result of config save
Inga Stotland [Thu, 23 Sep 2021 03:25:54 +0000 (20:25 -0700)]
tools/mesh-cfgclient: Check the result of config save

After successful completion of configuration commands that change
configuration state of network, the updates are expected to be
recorded in configuration file. If for the results are not saved,
print a warning message.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agotools/mesh-cfgclient: Store remote's model publication info
Inga Stotland [Thu, 23 Sep 2021 03:25:53 +0000 (20:25 -0700)]
tools/mesh-cfgclient: Store remote's model publication info

Update remote node's model publication after a successful completion
of "pub-set" or "pub-get" commands.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agotools/mesh-cfgclient: Disallow model commands w/o composition
Inga Stotland [Thu, 23 Sep 2021 03:25:52 +0000 (20:25 -0700)]
tools/mesh-cfgclient: Disallow model commands w/o composition

If remote node's composition hasn't been acquired, disallow commands
that change model state (that is, bindings, subscriptions, publications).
Prompt to run "get-composition" command first.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agotools/mesh-cfgclient: Store remote node's model subs
Inga Stotland [Thu, 23 Sep 2021 03:25:51 +0000 (20:25 -0700)]
tools/mesh-cfgclient: Store remote node's model subs

Update remote node's model subscriptions after a successful completion
of "sub-add", "sub-del", "sub-wrt" and "sub-del_all" commands.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agotools/mesh-cfgclient: Store remote node's model bindings
Inga Stotland [Thu, 23 Sep 2021 03:25:50 +0000 (20:25 -0700)]
tools/mesh-cfgclient: Store remote node's model bindings

Update remote node's model binding after a successful completion
of "bind" or "unbind" commands.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agotools/mesh-cfgclient: Overwrite config values when adding new ones
Inga Stotland [Thu, 23 Sep 2021 03:25:49 +0000 (20:25 -0700)]
tools/mesh-cfgclient: Overwrite config values when adding new ones

This changes common utilities used in mesh-db.c to replace old values
by default whenever a new value is written.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agotools/mesh: Add new info to stored remote nodes
Inga Stotland [Thu, 23 Sep 2021 03:25:48 +0000 (20:25 -0700)]
tools/mesh: Add new info to stored remote nodes

When adding a new remote node into configuration database,
initialize additional default properties:
"excluded": false
"security": "secure"
"configComplete": false

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agotools/mesh-cfgclient: Keep track of updated keys
Inga Stotland [Thu, 23 Sep 2021 03:25:47 +0000 (20:25 -0700)]
tools/mesh-cfgclient: Keep track of updated keys

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agotools/mesh-cfgclient: Update stored NetKey and AppKey
Inga Stotland [Thu, 23 Sep 2021 03:25:46 +0000 (20:25 -0700)]
tools/mesh-cfgclient: Update stored NetKey and AppKey

NetKeys:
- Record additional properties: "name", "minSecurity", "timestamp"

AppKeys:
- Record additional property: "name"

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agotools/mesh-cfgclient: Add timestamp to config database
Inga Stotland [Thu, 23 Sep 2021 03:25:45 +0000 (20:25 -0700)]
tools/mesh-cfgclient: Add timestamp to config database

This adds timestamp property to the configuration database.
The UTC timestamp format: YYYY-MM-DDThh:mm:ssZ

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agotools/mesh-cfgclient: Save provisioner info
Inga Stotland [Thu, 23 Sep 2021 03:25:44 +0000 (20:25 -0700)]
tools/mesh-cfgclient: Save provisioner info

This adds "provisioners" property to the config database.
The property includes the provisioner's name, UUID of the provisioner
device (corresponds to the local node), allocated unicast, group and
scene ranges.
The current implementation limitations:
- only one provisioner in the mesh network is supported,
- the unicast range is assumed to be contiguous,
- the group range is assumed to be contiguous,
- no support for scenes (empty array).

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agogatt: remove superfluous extended properties
Dagan Martinez [Sun, 26 Sep 2021 17:00:39 +0000 (13:00 -0400)]
gatt: remove superfluous extended properties

BlueZ contained superfluous properties that not only did nothing of
value, but needlessly created CEP descriptors for any characteristic
with a secure/encrypted/authenticated flag applied to it.

This actually deviated from the spec(Bluetooth core 5.3, 3.3.3.1) by
setting the reserved bits in the CEPD.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoavrcp: Fix browsing support in SDP record
Luiz Augusto von Dentz [Fri, 24 Sep 2021 21:11:35 +0000 (14:11 -0700)]
avrcp: Fix browsing support in SDP record

Browsing features shall only be marked as supported when ERTM is also
available.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoavctp: Fix not handling when kernel has ERTM disabled
Luiz Augusto von Dentz [Fri, 24 Sep 2021 20:20:38 +0000 (13:20 -0700)]
avctp: Fix not handling when kernel has ERTM disabled

If kernel module is loaded with disable_ertm ERTM won't be available
thus browsing channel won't be able to be created, but it shall be
possible to still use AVRCP without it.

Fixes: https://github.com/bluez/bluez/issues/209
Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agodevice: Check both bearers's paired status upon removal of connection
Archie Pusaka [Thu, 23 Sep 2021 08:18:23 +0000 (16:18 +0800)]
device: Check both bearers's paired status upon removal of connection

Because Link Key for BREDR can be transformed into LTK for LE (and
vice versa), there is a possibility of getting 'paired' on either of
BREDR/LE without actually connected using the aforementioned bearer.

When removing the connection, we should check both bearers's paired
and bonded status rather than just the one getting disconnected.

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 agoadapter: Truncate number of LTKs loaded if over MGMT MTU
Luiz Augusto von Dentz [Wed, 22 Sep 2021 21:29:51 +0000 (14:29 -0700)]
adapter: Truncate number of LTKs loaded if over MGMT MTU

If MGMT MTU cannot accomodate all the existing LTKs only send the ones
that fit in the MTU and leave the remaining as unpaired.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoshared/mgmt: Add mgmt_get_mtu
Luiz Augusto von Dentz [Wed, 22 Sep 2021 21:28:54 +0000 (14:28 -0700)]
shared/mgmt: Add mgmt_get_mtu

This adds mgmt_get_mtu function which can be used to query the
transport MTU.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agolib: Fix HCI_MAX_ACL_SIZE
Luiz Augusto von Dentz [Wed, 22 Sep 2021 20:48:43 +0000 (13:48 -0700)]
lib: Fix HCI_MAX_ACL_SIZE

HCI_MAX_ACL_SIZE actually includes the maximum frames in AMP controller
so this changes it to properly define the max ACL frames on non-AMP
controllers and introduces a dedicated define for AMP controller as
HCI_MAX_AMP_SIZE.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoshared/mgmt: Set MTU to UINT16_MAX
Luiz Augusto von Dentz [Wed, 15 Sep 2021 00:39:56 +0000 (17:39 -0700)]
shared/mgmt: Set MTU to UINT16_MAX

This sets MTU of MGMT socket to UINT16_MAX since some commands may
require more than the default size (e.g. Load LTKs).

Fixes: https://github.com/bluez/bluez/issues/201
Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agodoc: Inclusive language update
Archie Pusaka [Wed, 15 Sep 2021 08:32:09 +0000 (16:32 +0800)]
doc: Inclusive language update

Update the docs to reflect the changes for the other inclusive
language updates.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agounit/mesh: Inclusive language changes
Archie Pusaka [Wed, 15 Sep 2021 08:32:08 +0000 (16:32 +0800)]
unit/mesh: Inclusive language changes

According to
https://specificationrefs.bluetooth.com/language-mapping/Appropriate_Language_Mapping_Table.pdf
"flooding" is the preferred term.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agomesh: Inclusive language changes
Archie Pusaka [Wed, 15 Sep 2021 08:32:07 +0000 (16:32 +0800)]
mesh: Inclusive language changes

According to
https://specificationrefs.bluetooth.com/language-mapping/Appropriate_Language_Mapping_Table.pdf
"flooding", "accept list", and "reject list" are the preferred terms.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoclient: Inclusive language changes
Archie Pusaka [Wed, 15 Sep 2021 08:32:06 +0000 (16:32 +0800)]
client: Inclusive language changes

Use "parent" to describe dbus hierarchy.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agosrc: Inclusive language changes
Archie Pusaka [Wed, 15 Sep 2021 08:32:05 +0000 (16:32 +0800)]
src: Inclusive language changes

BT core spec 5.3 promotes the usage of inclusive languages.
This CL replaces some terms with the more appropriate counterparts,
such as "central", "peripheral", "accept list", and "reject list".
Note that some suggestions come from
https://specificationrefs.bluetooth.com/language-mapping/Appropriate_Language_Mapping_Table.pdf

Also use "primary" to refer the global mgmt struct.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoprofiles: Inclusive language changes
Archie Pusaka [Wed, 15 Sep 2021 08:32:04 +0000 (16:32 +0800)]
profiles: Inclusive language changes

BT core spec 5.3 promotes the usage of inclusive languages.
This CL replaces some terms with the more appropriate counterparts,
such as "central" and "peripheral".

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoplugins/sixaxis: Inclusive language changes
Archie Pusaka [Wed, 15 Sep 2021 08:32:03 +0000 (16:32 +0800)]
plugins/sixaxis: Inclusive language changes

BT core spec 5.3 promotes the usage of inclusive languages.
This CL uses "central" as it is deemed to be more appropriate.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agotools: Deprecate some input parameters to align with inclusive language
Archie Pusaka [Wed, 15 Sep 2021 08:32:01 +0000 (16:32 +0800)]
tools: Deprecate some input parameters to align with inclusive language

Some input parameter names are not appropriate and needs to be
updated. However, doing so might cause friction with the current
workflow and documents.

This patch deprecates the inappropriate names and replaces them with
the more appropriate substitutes, while still keeping the old terms
usable to not break the workflow of users.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agotools: Inclusive language changes
Archie Pusaka [Wed, 15 Sep 2021 08:31:59 +0000 (16:31 +0800)]
tools: Inclusive language changes

BT core spec 5.3 promotes the usage of inclusive languages.
This CL replaces some terms with the more appropriate counterparts,
such as "central", "peripheral", "accept list", "reject list", and
"temporary link key". Note that some suggestions come from
https://specificationrefs.bluetooth.com/language-mapping/Appropriate_Language_Mapping_Table.pdf

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoemulator: Inclusive language changes
Archie Pusaka [Wed, 15 Sep 2021 08:31:58 +0000 (16:31 +0800)]
emulator: Inclusive language changes

BT core spec 5.3 promotes the usage of inclusive languages.
This CL replaces some terms with the more appropriate counterparts,
such as "central", "peripheral", and "accept list".

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agomonitor: Inclusive language changes
Archie Pusaka [Wed, 15 Sep 2021 08:31:57 +0000 (16:31 +0800)]
monitor: Inclusive language changes

BT core spec 5.3 promotes the usage of inclusive languages.
This CL replaces some terms with the more appropriate counterparts,
such as "central", "peripheral", "link key", and "accept list"

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agobtio: Inclusive language changes
Archie Pusaka [Wed, 15 Sep 2021 08:31:56 +0000 (16:31 +0800)]
btio: Inclusive language changes

BT core spec 5.3 promotes the usage of inclusive languages.
This CL uses "central" as it is deemed to be more appropriate.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agolib: Inclusive language changes
Archie Pusaka [Wed, 15 Sep 2021 08:31:55 +0000 (16:31 +0800)]
lib: Inclusive language changes

BT core spec 5.3 promotes the usage of inclusive languages.
This CL replaces some terms with the more appropriate counterparts,
such as "central", "peripheral", and "accept list".

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agomedia: Add media_player prefix for callback
Luiz Augusto von Dentz [Fri, 17 Sep 2021 20:50:45 +0000 (13:50 -0700)]
media: Add media_player prefix for callback

This adds media_player prefix to callback so it is inline with pause
which now uses such callback due to possible clash with libc
definition.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agomedia: Fix build with glibc >= 2.34
Fabrice Fontaine [Sun, 12 Sep 2021 20:48:39 +0000 (22:48 +0200)]
media: Fix build with glibc >= 2.34

pause() is defined in glibc since the very early times; it appears in
upstream commit 28f540f45bba (initial import) in 1995 [0].

Bluez has been defining a function named pause() for ages too, since
commit caab74c97542 (media: Implement new callbacks for pass-through
operations) in 2013 [1]

With the recent bump to glibc 2.34.xxx, the build now fails because the
two pause() clash:

profiles/audio/media.c:1284:13: error: conflicting types for 'pause'
 1284 | static bool pause(void *user_data)
      |             ^~~~~
In file included from /tmp/instance-0/output-1/per-package/bluez5_utils/host/s390x-buildroot-linux-gnu/sysroot/usr/include/bits/sigstksz.h:24,
                 from /tmp/instance-0/output-1/per-package/bluez5_utils/host/s390x-buildroot-linux-gnu/sysroot/usr/include/signal.h:328,
                 from /tmp/instance-0/output-1/per-package/bluez5_utils/host/bin/../s390x-buildroot-linux-gnu/sysroot/usr/include/glib-2.0/glib/gbacktrace.h:36,
                 from /tmp/instance-0/output-1/per-package/bluez5_utils/host/bin/../s390x-buildroot-linux-gnu/sysroot/usr/include/glib-2.0/glib.h:34,
                 from profiles/audio/media.c:21:
/tmp/instance-0/output-1/per-package/bluez5_utils/host/s390x-buildroot-linux-gnu/sysroot/usr/include/unistd.h:489:12: note: previous declaration of 'pause' was here
  489 | extern int pause (void);
      |            ^~~~~

The culprit is indeed glibc 2.34, as can be seen in this result matrix:

         \   bluez5_utils
    glibc \  5.60  |  5.61
    -------\-------+--------
    2.33   |  OK   |   OK
    -------+-------+--------
    2.34   |  KO   |   KO

The underlying reason that pause() is now causing issues with glibc 2.34
is not obvious: glibc is a big beast, and finding such issues is not
easy. However, we can see that the pause() provided by NPTL has been
dropped in favour of the generic one, so maybe this is causing symbol
visibility or weakness to change or something...

We fix that by renaming the local pause() in bluez5_utils with a
namespace-prefix, like some other functions there already have.

Fixes:
  - http://autobuild.buildroot.org/results/c4fbface34be8815838fd7201621d7a8fddd32c5
  - http://autobuild.buildroot.org/results/62b88740f19fbe4a1ad7959dc141d539eb88c1f8

[0] https://sourceware.org/git/?p=glibc.git;a=commit;h=28f540f45bbacd939bfd07f213bcad2bf730b1bf
[1] https://github.com/bluez/bluez/commit/caab74c97542a56b591f0b16b44ab6ba4b40f0f5

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agotools: userchan-tester: Add test case for the closing channel
Tedd Ho-Jeong An [Fri, 20 Aug 2021 05:07:05 +0000 (22:07 -0700)]
tools: userchan-tester: Add test case for the closing channel

This patch adds a test casse for checking the controller power state
after closing the user channel.

When the user channel is closed, the controller should be powered down
state.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agolib: Fix variable-length array declarations in hci structures
Peter A. Bigot [Tue, 31 Aug 2021 16:35:45 +0000 (09:35 -0700)]
lib: Fix variable-length array declarations in hci structures

Use of zero as the size for arrays as the last element of a structure
is a GNU C extension, which as of GCC 10 produces diagnostics when
values in the extended array are referenced.  Switch to the C99
standard idiom for flexible array members, already in use in a few
other headers.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoadmin: Fix double free
Luiz Augusto von Dentz [Thu, 16 Sep 2021 22:36:00 +0000 (15:36 -0700)]
admin: Fix double free

Fixes the following double free which happen due to exit calling
btd_unregister_adapter_driver:

Invalid read of size 8
   at 0x1CDA97: queue_foreach (queue.c:198)
   by 0x1318B8: admin_policy_remove (admin.c:591)
   by 0x18982A: plugin_cleanup (plugin.c:217)
   by 0x12E3FD: main (main.c:1214)
 Address 0x547ffb8 is 8 bytes inside a block of size 32 free'd
   at 0x483A9F5: free (vg_replace_malloc.c:538)
   by 0x1318CB: admin_policy_remove (admin.c:592)
   by 0x18F416: unload_driver (adapter.c:7215)
   by 0x496F50F: g_slist_foreach (in /usr/lib64/libglib-2.0.so.0.6600.8)
   by 0x131988: admin_exit (admin.c:623)
   by 0x18982A: plugin_cleanup (plugin.c:217)
   by 0x12E3FD: main (main.c:1214)
 Block was alloc'd at
   at 0x4839809: malloc (vg_replace_malloc.c:307)
   by 0x1CDE1E: btd_malloc (util.c:33)
   by 0x1CD83D: queue_new (queue.c:47)
   by 0x13150D: admin_init (admin.c:614)
   by 0x18966B: plugin_init (plugin.c:187)
   by 0x12E358: main (main.c:1198)

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoadmin: Fix leaking uuids loads from storage
Luiz Augusto von Dentz [Thu, 16 Sep 2021 22:18:14 +0000 (15:18 -0700)]
admin: Fix leaking uuids loads from storage

This fixes the following trace:

8 bytes in 1 blocks are definitely lost in loss record 27 of 274
   at 0x4839809: malloc (vg_replace_malloc.c:307)
   by 0x495BBB8: g_malloc (in /usr/lib64/libglib-2.0.so.0.6600.8)
   by 0x494C024: g_key_file_get_string_list (in /usr/lib64/libglib-2.0.so.0.6600.8)
   by 0x131ECD: key_file_load_service_allowlist (admin.c:294)
   by 0x131ECD: load_policy_settings (admin.c:346)
   by 0x131ECD: admin_policy_adapter_probe (admin.c:497)
   by 0x18F554: probe_driver (adapter.c:4858)
   by 0x19DF5A: load_drivers (adapter.c:4873)
   by 0x19DF5A: adapter_register (adapter.c:8975)
   by 0x19DF5A: read_info_complete (adapter.c:9791)
   by 0x1CE831: request_complete (mgmt.c:264)
   by 0x1CF7D4: can_read_data (mgmt.c:356)
   by 0x1DE634: watch_callback (io-glib.c:157)
   by 0x4953A9E: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.6600.8)
   by 0x49A5A97: ??? (in /usr/lib64/libglib-2.0.so.0.6600.8)
   by 0x4953162: g_main_loop_run (in /usr/lib64/libglib-2.0.so.0.6600.8)

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agopolicy: Use btd_service_is_initiator
Luiz Augusto von Dentz [Thu, 16 Sep 2021 18:25:12 +0000 (11:25 -0700)]
policy: Use btd_service_is_initiator

Instead of using BTD_SERVICE_STATE_CONNECTING use
btd_service_is_initiator to determine if the service initiated the
connection and then proceed to connect other service immediately.

Fixes: https://github.com/bluez/bluez/issues/205
Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoservice: Add btd_service_is_initiator
Luiz Augusto von Dentz [Thu, 16 Sep 2021 18:16:08 +0000 (11:16 -0700)]
service: Add btd_service_is_initiator

Since BTD_SERVICE_STATE_CONNECTING is being used for both initiator and
responder case it is no longer possible to use the state distint when
the service connection was initiated locally or not, so to fix this a
new flag is introduce to track when btd_service_connect has been
called.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agosco-tester: Add tests for sending data
Luiz Augusto von Dentz [Wed, 15 Sep 2021 22:35:01 +0000 (15:35 -0700)]
sco-tester: Add tests for sending data

This adds tests for sending data over the socket.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoplugins/admin: create admin_policy_settings if not exists
Yun-Hao Chung [Mon, 6 Sep 2021 06:03:17 +0000 (14:03 +0800)]
plugins/admin: create admin_policy_settings if not exists

If admin_policy_settings is not found when loading, we should create one
instead of printing error.

Reviewed-by: Shyh-In Hwang <josephsih@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 agoplugins/admin: add adapter_remove handler
Yun-Hao Chung [Mon, 6 Sep 2021 06:03:16 +0000 (14:03 +0800)]
plugins/admin: add adapter_remove handler

Currently admin doesn't handle adapter removed callbacks, which causes
interfaces AdminPolicySet1 and AdminPolicyStatus1 not being
unregistered, which in turns causes these interfaces can not be
re-registered once adapter is back.

This adds handler for adapter_remove.

Reviewed-by: Shyh-In Hwang <josephsih@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 agotools/mgmt-tester: Update exp feature testcase
Tedd Ho-Jeong An [Tue, 14 Sep 2021 22:39:07 +0000 (15:39 -0700)]
tools/mgmt-tester: Update exp feature testcase

This patch updates the experimental feature test case with the recently
added "codec offload" feature.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoshared/util: Update UUID database with LE Audio services
Luiz Augusto von Dentz [Mon, 13 Sep 2021 18:04:05 +0000 (11:04 -0700)]
shared/util: Update UUID database with LE Audio services

This updates UUID database with the values from assigned numbers for LE
Audio services.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoshared/util: Add conversion function for 24 bits
Luiz Augusto von Dentz [Tue, 4 Aug 2020 23:42:31 +0000 (16:42 -0700)]
shared/util: Add conversion function for 24 bits

This adds get/put 24 bits variants.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoadv_monitor: Clear any running DeviceLost timers on power down
Manish Mandlik [Fri, 10 Sep 2021 02:05:36 +0000 (19:05 -0700)]
adv_monitor: Clear any running DeviceLost timers on power down

This patch clears any running Adv Monitor DeviceLost timers on bt power
down. It'll also invoke DeviceLost event if the device is already found
and is being tracked for the DeviceLost event.

Verified this by adding a monitor using bluetoothctl and confirming that
the DeviceLost event is getting triggered for already found device in
case of bt power down.

Reviewed-by: mcchou@google.com
Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoadapter: Enable codec offload when Experimental is set
Luiz Augusto von Dentz [Tue, 7 Sep 2021 22:27:10 +0000 (15:27 -0700)]
adapter: Enable codec offload when Experimental is set

This enables codec offload experimental feature if its UUIDs has been
enabled by main.conf:Experimental or -E has been passed in the command
line.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agomain.conf: Allow passing a list of UUIDs to Experimental
Luiz Augusto von Dentz [Tue, 7 Sep 2021 21:05:38 +0000 (14:05 -0700)]
main.conf: Allow passing a list of UUIDs to Experimental

This allows the user to enable a subset of the experimental features to
be enabled instead of all of them and also change -E to work in the same
way so a list of UUIDs can also be given at the command line.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoclient: Add support for printing ExperimentalFeatures property
Luiz Augusto von Dentz [Tue, 17 Aug 2021 00:56:34 +0000 (17:56 -0700)]
client: Add support for printing ExperimentalFeatures property

Thid adds support to show command to print ExperimentalFeatures property:

[bluetooth]# show
Controller ...
Experimental: BlueZ Experimental LL p.. (15c0a148-c273-11ea-b3de-0242ac130004)

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoadapter: Implement ExperimentalFeatures property
Luiz Augusto von Dentz [Tue, 17 Aug 2021 00:54:03 +0000 (17:54 -0700)]
adapter: Implement ExperimentalFeatures property

This implements ExperimentalFeatures property which indicates the list
of UUIDs that represents the experimental features currently enabled.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoadapter-api: Add ExperimentalFeatures property
Luiz Augusto von Dentz [Mon, 16 Aug 2021 23:20:10 +0000 (16:20 -0700)]
adapter-api: Add ExperimentalFeatures property

This adds ExperimentalFeatures property which indicates what
experimental features are currently enabled.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agotools/sco-tester: add a test case for offload SCO connect
Kiran K [Tue, 7 Sep 2021 11:25:56 +0000 (16:55 +0530)]
tools/sco-tester: add a test case for offload SCO connect

Add a test case for offload SCO connect with codec type set to mSBC

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agotools/sco-tester: Add a test case for setting offload codec
Kiran K [Tue, 7 Sep 2021 11:25:55 +0000 (16:55 +0530)]
tools/sco-tester: Add a test case for setting offload codec

Add a test case to set codec for HFP offload use case

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agotools/sco-tester: add test cases to get offload codecs
Kiran K [Tue, 7 Sep 2021 11:25:54 +0000 (16:55 +0530)]
tools/sco-tester: add test cases to get offload codecs

Add a test case to query offload codecs supported over sco

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoavdtp: use separate local SEID pool for each adapter
Pauli Virtanen [Sun, 5 Sep 2021 15:43:56 +0000 (18:43 +0300)]
avdtp: use separate local SEID pool for each adapter

Local SEIDs are currently allocated from a pool that is common for all
adapters. However, AVDTP spec v1.3, sec 4.10 states "To prevent
conflicts, the scope of the SEID shall be both device-local and
connection-local. The application is responsible for assigning a SEID,
which is not in use on the connection to the same peer device." In
practice, registering the same media application for multiple adapters
can result to running out of SEIDs, even though the spec does not
require SEIDs to be unique across adapters.

To fix this, have a2dp_server own the SEID pool and pass it to avdtp
functions. Currently, a2dp_server is the only one that registers local
SEPs, and its correspondence to adapters is unique, so it can own the
pool.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoshared/util: use 64-bit bitmap in util_get/clear_uid
Pauli Virtanen [Sun, 5 Sep 2021 15:43:55 +0000 (18:43 +0300)]
shared/util: use 64-bit bitmap in util_get/clear_uid

The util_get/clear_uid functions use int type for bitmap, and are used
e.g. for SEID allocation. However, valid SEIDs are in range 1 to 0x3E
(AVDTP spec v1.3, 8.20.1), and 8*sizeof(int) is often smaller than 0x3E.

The function is also used in src/advertising.c, but an explicit maximum
value is always provided, so growing the bitmap size is safe there.

Use 64-bit bitmap instead, to be able to cover the valid range.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoshared/shell: don't allow completion fallback
Alain Michaud [Fri, 3 Sep 2021 14:01:18 +0000 (14:01 +0000)]
shared/shell: don't allow completion fallback

When using bluetoothctl, if the user enters a quotation mark before
pressing tab, the completion handler falls back to the shell's handler
which ends up printing the current folder's file content.  This behavior
is never desired in bt_shell's menu.

This was verified by typing " then tab-tab before and after the change as
been made to confirm the desired behavior and verified that all other
argument completions (such as address completion) continues to function.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agomonitor: Fix calculation of RFCOMM length
Luiz Augusto von Dentz [Fri, 3 Sep 2021 00:01:24 +0000 (17:01 -0700)]
monitor: Fix calculation of RFCOMM length

Byte order is assumed to be big endian instead of little endian.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoplugin/admin: fix set empty allowlist no persistence issue
Yun-Hao Chung [Tue, 31 Aug 2021 05:39:00 +0000 (13:39 +0800)]
plugin/admin: fix set empty allowlist no persistence issue

This patch fixes a bug when setting empty service allowlist, the
allowlist sets successfully but it fails to be stored in the file.

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 agobtmgmt: add non-interactive quit on read-sysconfig
Yun-Hao Chung [Tue, 31 Aug 2021 05:44:36 +0000 (13:44 +0800)]
btmgmt: add non-interactive quit on read-sysconfig

This fixes the erros that read-sysconfig doesn't exit in non-interactive
mode.

Reviewed-by: Archie Pusaka <apusaka@chromium.org>
Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agotools/mgmt-tester: add a exp feature to Read Exp Feature - Success
Joseph Hwang [Fri, 20 Aug 2021 05:18:02 +0000 (13:18 +0800)]
tools/mgmt-tester: add a exp feature to Read Exp Feature - Success

This patch adds a new quality report feature to the
"Read Exp Feature - Success" test.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agotest-runner: Enable bluetoothd debug when running with -d
Luiz Augusto von Dentz [Thu, 26 Aug 2021 16:30:31 +0000 (09:30 -0700)]
test-runner: Enable bluetoothd debug when running with -d

This enable bluetoothd debug when running with -d.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agodevice: set le_state.svc_resolved = false in gatt_cache_cleanup()
David Lechner [Wed, 25 Aug 2021 16:51:25 +0000 (11:51 -0500)]
device: set le_state.svc_resolved = false in gatt_cache_cleanup()

When the GATT cache is cleared, there is no longer a list of GATT
services, so we need to set le_state.svc_resolved = false so that
the next time the device connects, it will enumerate the services
again.

This partially fixes an issue where the UUIDs D-Bus property was empty
after scanning, connecting, disconnecting and scanning again when
[GATT] Cache = yes is set in main.conf.

Issue: https://github.com/bluez/bluez/issues/192
Suggested-by: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agodevice: clear eir_uuids list on disconnect
David Lechner [Wed, 25 Aug 2021 16:51:24 +0000 (11:51 -0500)]
device: clear eir_uuids list on disconnect

The eir_uuids list contains GATT service UUIDs from advertising data.
The device may advertise different UUIDs each time it is scanned and
connected, so the list needs to be cleared when the device disconnects.

This partially fixes an issue where the UUIDs D-Bus property is empty
after scanning, connecting, disconnecting and scanning again when
[GATT] Cache = yes is set in main.conf.

Issue: https://github.com/bluez/bluez/issues/192
Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agogatt: Do not always attempt to connect EATT immediately
Luiz Augusto von Dentz [Wed, 25 Aug 2021 21:03:50 +0000 (14:03 -0700)]
gatt: Do not always attempt to connect EATT immediately

Wait the bt_gatt_client becomes ready (has performed service discovery)
before attempting to connect EATT when acting as peripheral/acceptor
since the central/initiator might actually attempt to connect EATT
channels in the same way which can potentially cause a collisions.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoshared/att: Fix attempting to send Exchange MTU on EATT bearer
Luiz Augusto von Dentz [Wed, 25 Aug 2021 16:07:18 +0000 (09:07 -0700)]
shared/att: Fix attempting to send Exchange MTU on EATT bearer

EATT bearer shall use the L2CAP signalling for negotiating the MTU
size.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoshared/att: Fix accepting Exchange MTU on EATT bearer
Luiz Augusto von Dentz [Wed, 25 Aug 2021 15:58:07 +0000 (08:58 -0700)]
shared/att: Fix accepting Exchange MTU on EATT bearer

If remote send Exchange MTU it shall fail as the MTU negotiation shall
happen over L2CAP signalling not ATT for those channels.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agodevice: Remove GATT Attribute when device is removed
Luiz Augusto von Dentz [Tue, 24 Aug 2021 22:48:38 +0000 (15:48 -0700)]
device: Remove GATT Attribute when device is removed

This makes the GATT Attribute cache to be removed when device is removed
just like SDP ServiceRecords.

Fixes: https://github.com/bluez/bluez/issues/191
Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoRelease 5.61
Marcel Holtmann [Sun, 22 Aug 2021 04:27:18 +0000 (06:27 +0200)]
Release 5.61

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agotools/mgmt-tester: Add Read OOB Ext Data test cases
Brian Gix [Wed, 18 Aug 2021 18:28:13 +0000 (11:28 -0700)]
tools/mgmt-tester: Add Read OOB Ext Data test cases

Read Local OOB Ext Data - Invalid index
Read Local OOB Ext Data - Legacy pairing
Read Local OOB Ext Data - Success SSP
Read Local OOB Ext Data - Success SC

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agobtdev: Fix removing advertising set if it was terminated
Luiz Augusto von Dentz [Wed, 18 Aug 2021 22:39:32 +0000 (15:39 -0700)]
btdev: Fix removing advertising set if it was terminated

Consider the advertising set disabled but don't remove it as the host
may still reuse it.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agobtdev: Fix order of BT_HCI_EVT_LE_ADV_SET_TERM
Luiz Augusto von Dentz [Wed, 18 Aug 2021 20:45:05 +0000 (13:45 -0700)]
btdev: Fix order of BT_HCI_EVT_LE_ADV_SET_TERM

BT_HCI_EVT_LE_ADV_SET_TERM shall come after
BT_HCI_EVT_LE_ENHANCED_CONN_COMPLETE otherwise the host doesn't know
the connection handle.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agobtdev: Fix sending terminate advertising event to the wrong device
Luiz Augusto von Dentz [Wed, 18 Aug 2021 18:42:53 +0000 (11:42 -0700)]
btdev: Fix sending terminate advertising event to the wrong device

The device where the event should be sent is the same that had created
not the connection one.

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