platform/upstream/bluez.git
3 years agoavdtp: Fix possible unbalance ref count
Luiz Augusto von Dentz [Mon, 22 Jun 2020 16:21:27 +0000 (09:21 -0700)]
avdtp: Fix possible unbalance ref count

It has been reported that under some unknown circuntances the reference
number of AVDTP sessions can go bellow 0 (loop around) causing a crash:

bluetoothd[5633]: profiles/audio/avdtp.c:avdtp_ref() 0x56a882b8a500: ref=-2101995743
bluetoothd[5633]: profiles/audio/a2dp.c:discover_cb() err (nil)
WARNING crash_reporter[10707]: [user] Received crash notification for bluetoothd[5633]

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agoshared/gatt-client: Fix freeing instance while processing notification
Luiz Augusto von Dentz [Thu, 25 Jun 2020 20:52:55 +0000 (13:52 -0700)]
shared/gatt-client: Fix freeing instance while processing notification

If CCC fails to be programmed the callback would be run without taking
a reference which may lead to freeing the client instance while there
are still notification to be processed.

To fix this handling of both success and failure to program the CCC will
now take a reference to the client, also in case of failure instead of
attempting to program the CCC once again the code now notify all the
queued requests which is consistent with how the success case is
handled.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agosrc/shared: update uuid16_table to latest
Noah Pendleton [Sun, 21 Jun 2020 18:56:18 +0000 (14:56 -0400)]
src/shared: update uuid16_table to latest

Update the table of 16-bit UUID to manufacturer name string to the
latest from this url:

https://www.bluetooth.com/specifications/assigned-numbers/16-bit-uuids-for-members/

I used this script to convert to the bluez format:

https://github.com/noahp/bt-sig-16-bit-uuids
Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agocheckpatch: Add configuration for checkpatch
Tedd Ho-Jeong An [Mon, 22 Jun 2020 17:18:17 +0000 (10:18 -0700)]
checkpatch: Add configuration for checkpatch

This patch adds a configuration with basic rules for checkpatch.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agomidi: Fix random empty timestamp_high value
Tedd Ho-Jeong An [Fri, 19 Jun 2020 18:34:56 +0000 (11:34 -0700)]
midi: Fix random empty timestamp_high value

The timestamp_high value is assigned from the monotonic time but there
is a chance that the value becomes zero because it reads the value
between bit8 and bit13.

This patch makes sure the timestamp_high value get a non-zero value.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agomidi: Fix SysEx parser in MIDI plugin
Tedd Ho-Jeong An [Fri, 19 Jun 2020 18:34:55 +0000 (11:34 -0700)]
midi: Fix SysEx parser in MIDI plugin

The SysEx end of message parser didn't consider the fact that
timestampsLow are in the stream and it might have the EOX (F7)
byte as well.

Fix that by always assuming the first system message byte is
the timestampLow.

Future work would involve support other type of system message
bytes, such as real-time.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agobtmgmt: Add command "add" into "monitor" btmgmt submenu
Michael Sun [Fri, 19 Jun 2020 22:56:23 +0000 (15:56 -0700)]
btmgmt: Add command "add" into "monitor" btmgmt submenu

This patch introduces a new command ‘add’ within "monitor" submenu to
allow users to add advertisement monitor filters and get back monitor
handlers. An event handler is also added to handle kernel issued
MGMT_EV_ADV_MONITOR_ADDED events. The command will work with the new
MGMT opcode MGMT_OP_ADD_ADV_MONITOR. This patch only adds support for
adding pattern based filters.

Tested on Atlas Chromebook with a sample stdout below:
[mgmt]# add -p 0:1:c504 1:a:9a55beef
Advertisement monitor with handle:0x0005 added
[mgmt]# add -p 0:1:xxxx
Failed to parse monitor patterns.
Usage: add <-p|-h> [options...]
Monitor Types:
        -p <ad_type:offset:pattern>...  Pattern Monitor
e.g.:
        add -p 0:1:c504 1:a:9a55beef

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agobtmgmt: Add command "remove" into "monitor" btmgmt submenu
Michael Sun [Fri, 19 Jun 2020 22:56:22 +0000 (15:56 -0700)]
btmgmt: Add command "remove" into "monitor" btmgmt submenu

This patch introduces a new btmgmt command ‘remove’ wihtin "monitor"
submenu to allow users to remove previously added filters along with a
event handler to handle kernel issued MGMT_EV_ADV_MONITOR_REMOVED
event. The command will work with the new
MGMT opcode MGMT_OP_REMOVE_ADV_MONITOR.

Tested on Atlas Chromebook with a sample stdout below:
[mgmt]# remove 1
Advertisement monitor with handle: 0x0001 removed
[mgmt]# remove 1234
Could not remove advertisement monitor with status 0x11 (Invalid Index)

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agobtmgmt: Add "monitor" btmgmt submenu and command "features"
Michael Sun [Fri, 19 Jun 2020 22:56:21 +0000 (15:56 -0700)]
btmgmt: Add "monitor" btmgmt submenu and command "features"

This patch introduces a new submenu "monitor" along with command
‘features’ to help user query for supported advertisement features. The
command will work with the new MGMT opcode
MGMT_OP_READ_ADV_MONITOR_FEATURES.

Tested on Atlas Chromebook with a sample stdout below:
[mgmt]# features
Supported features:
        None
Enabled features:
        None
Max number of handles: 32
Max number of patterns: 16
Handles list with 2 items:
        0x0001
        0x0002

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agomain: adding missing connection parameter entries
Alain Michaud [Mon, 15 Jun 2020 14:52:21 +0000 (14:52 +0000)]
main: adding missing connection parameter entries

This patch adds the missing connection parameter entries for loading
connection parameters from main.conf

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agolib: Correct the string for a mgmt op
Miao-chen Chou [Tue, 16 Jun 2020 22:56:50 +0000 (15:56 -0700)]
lib: Correct the string for a mgmt op

This corrects the string of MGMT_OP_ADD_ADV_PATTERNS_MONITOR to match
mgmt-api.txt.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agomain: Add configurable le autoconnect timeout value
Alain Michaud [Mon, 15 Jun 2020 14:52:52 +0000 (14:52 +0000)]
main: Add configurable le autoconnect timeout value

This patch adds support for a configurable le autoconnect timer.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agomain: Fix logical error when loading controller params
Alain Michaud [Thu, 18 Jun 2020 01:48:12 +0000 (01:48 +0000)]
main: Fix logical error when loading controller params

Fix logical error when loading configuration parameters from the
config file.  Without this patch, the maximum allowable value is always
used.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agolib: Correct the name command definition
Miao-chen Chou [Tue, 16 Jun 2020 04:28:34 +0000 (21:28 -0700)]
lib: Correct the name command definition

This renames MGMT_OP_ADD_ADV_MONITOR to
MGMT_OP_ADD_ADV_PATTERNS_MONITOR as this command is only used for
patterns.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agolib: Move HOG UUID definition
Manish Mandlik [Wed, 10 Jun 2020 16:22:04 +0000 (09:22 -0700)]
lib: Move HOG UUID definition

HOG UUID is defined at multiple places in the code. Move that
definition to lib/uuid.h where all other UUIDs are defined.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agodoc: Fix minor typo
Marcel Holtmann [Fri, 12 Jun 2020 19:49:12 +0000 (21:49 +0200)]
doc: Fix minor typo

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agomgmt: syncing configuration commands to the documentation.
Alain Michaud [Fri, 12 Jun 2020 19:48:36 +0000 (21:48 +0200)]
mgmt: syncing configuration commands to the documentation.

This patch simply fixes the definition names (and corresponding
implemenation) to the adopted documentation.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agoadapter: Fix not checking status of stop discovery command
Luiz Augusto von Dentz [Fri, 12 Jun 2020 17:11:04 +0000 (10:11 -0700)]
adapter: Fix not checking status of stop discovery command

Status needs to be checked in order to properly synchronize the states
with the controller.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agolib: Add definitions for advertisement monitor features
Miao-chen Chou [Tue, 19 May 2020 03:10:00 +0000 (20:10 -0700)]
lib: Add definitions for advertisement monitor features

This adds the following command opcodes, event codes and the corresponding
structures.
- MGMT_OP_READ_ADV_MONITOR_FEATURES
- MGMT_OP_ADD_ADV_PATTERNS_MONITOR
- MGMT_OP_REMOVE_ADV_MONITOR
- MGMT_EV_ADV_MONITOR_ADDED
- MGMT_EV_ADV_MONITOR_REMOVED

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agoadapter: Rename watch_client to discovery_client
Luiz Augusto von Dentz [Thu, 11 Jun 2020 20:23:06 +0000 (13:23 -0700)]
adapter: Rename watch_client to discovery_client

watch term is quite vague so this replace it with discovery which is
what is used for the filter as well.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agoadapter: Fix leaking filter pattern
Luiz Augusto von Dentz [Thu, 11 Jun 2020 20:16:29 +0000 (13:16 -0700)]
adapter: Fix leaking filter pattern

When a discovery client has set a pattern as filter the code allocates
the string so it needs to be freed with the filter otherwise it leads to
the following leak:

10 bytes in 2 blocks are definitely lost in loss record 19 of 265
   at 0x483980B: malloc (vg_replace_malloc.c:309)
   by 0x4D9FF7E: strdup (in /usr/lib64/libc-2.30.so)
   by 0x1FC8E7: parse_pattern (adapter.c:2454)
   by 0x1FF37B: parse_discovery_filter_entry (adapter.c:2480)
   by 0x1FF37B: parse_discovery_filter_dict (adapter.c:2538)
   by 0x2020AF: set_discovery_filter (adapter.c:2589)
   by 0x24AD63: process_message.isra.0 (object.c:259)
   by 0x24B40F: generic_message (object.c:1079)
   by 0x4A670B7: ??? (in /usr/lib64/libdbus-1.so.3.19.11)
   by 0x4A57763: dbus_connection_dispatch (in /usr/lib64/libdbus-1.so.3.19.11)
   by 0x2459CF: message_dispatch (mainloop.c:72)
   by 0x4963E8A: ??? (in /usr/lib64/libglib-2.0.so.0.6200.6)
   by 0x496756F: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.6200.6)

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agoadapter: Track discovery client which initiate an action
Luiz Augusto von Dentz [Thu, 11 Jun 2020 20:14:07 +0000 (13:14 -0700)]
adapter: Track discovery client which initiate an action

This adds tracking for active clients so it can be properly
removed/freed on the callbacks.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agoadapter: Fix passing wrong pointer to stop discovery
Luiz Augusto von Dentz [Thu, 11 Jun 2020 17:26:57 +0000 (10:26 -0700)]
adapter: Fix passing wrong pointer to stop discovery

stop_discovery_complete now expects adapter to be passed instead of
client.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agoinput: Disconnect ctrl chan only if intr chan was disconnected by us
Archie Pusaka [Wed, 10 Jun 2020 15:04:46 +0000 (23:04 +0800)]
input: Disconnect ctrl chan only if intr chan was disconnected by us

If the intr channel was disconnected by the other party, then they
are also responsible to close the ctrl channel. Such disconnection
message would have the G_IO_ERR flag set, as opposed to it being
unset if the disconnection is initiated by us.

There doesn't seem to be an explicit rule in the specification
about this behavior, but this is enforced in the PTS qualification
tool.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agoinput: disconnect intr channel before ctrl channel
Archie Pusaka [Tue, 9 Jun 2020 14:58:25 +0000 (22:58 +0800)]
input: disconnect intr channel before ctrl channel

According to bluetooth HID Profile spec Ver 1.0, section 7.2.2, A
host or device shall always complete the disconnection of the
interrupt channel before disconnecting the control channel.
However, the current implementation disconnects them both
simultaneously.

This patch postpone the disconnection of control channel to the
callback of interrupt watch, which shall be called upon receiving
interrupt channel disconnection response.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agoadapter: Fix possible crash when stopping discovery
Luiz Augusto von Dentz [Mon, 8 Jun 2020 21:55:57 +0000 (14:55 -0700)]
adapter: Fix possible crash when stopping discovery

If the client disconnect/crash while MGMT_OP_STOP_DISCOVERY was pending
it would possibly cause a crash as the client pointer is passed to
mgmt_send and accessed in the callback after being freed.

To fix this the adapter itself is now passed to the callback so the
client is not accessed directly, instead the code now checks if
discovery_list has not been cleared in the meantime and only then
proceed to access the client pointer which is how
MGMT_OP_START_DISCOVERY is handled.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agoadapter: Consolitate code for discovery reply
Luiz Augusto von Dentz [Mon, 8 Jun 2020 21:52:53 +0000 (14:52 -0700)]
adapter: Consolitate code for discovery reply

This consolidate code that were used to reply discovery commands in a
single function so it easier to reuse and maintain.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agoadapter: Do not remove client watch directly if discovery fails
Luiz Augusto von Dentz [Mon, 8 Jun 2020 21:07:25 +0000 (14:07 -0700)]
adapter: Do not remove client watch directly if discovery fails

Client watch is used for both discovery and it filters so in case the
client has set the later the watch shall be perserved.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agoa2dp: Use streaming mode when MPS is enabled
Luiz Augusto von Dentz [Mon, 8 Jun 2020 20:24:40 +0000 (13:24 -0700)]
a2dp: Use streaming mode when MPS is enabled

If MPS is enabled use L2CAP streaming mode for AVDTP channels.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agodoc: Describe the new Advertisement Monitor support
Miao-chen Chou [Wed, 10 Jun 2020 17:54:54 +0000 (19:54 +0200)]
doc: Describe the new Advertisement Monitor support

This describes the following commands and event.
- Read Advertisement Monitor Features command
- Add Advertisement Patterns Monitor command
- Remove Advertisement Monitor command
- Advertisement Monitor Added event
- Advertisement Monitor Removed event
Note that the content of a monitor can differ based on its type. For now we
introduce only pattern-based monitor, so you may find that unlike the
command of removing monitor(s), the Add command is tied to a specific type.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agodoc: Fix typo for Set Device Class command description
Marcel Holtmann [Wed, 10 Jun 2020 17:21:57 +0000 (19:21 +0200)]
doc: Fix typo for Set Device Class command description

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agodoc: Add commands and event for handling device flags
Marcel Holtmann [Wed, 10 Jun 2020 17:20:16 +0000 (19:20 +0200)]
doc: Add commands and event for handling device flags

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agodoc: Add the event for default configuration changes
Marcel Holtmann [Wed, 10 Jun 2020 14:11:18 +0000 (16:11 +0200)]
doc: Add the event for default configuration changes

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agodoc: Mention mgmt version 1.18 changes
Marcel Holtmann [Wed, 10 Jun 2020 09:02:02 +0000 (11:02 +0200)]
doc: Mention mgmt version 1.18 changes

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agodoc: Add commands for reading and changing runtime parameters
Marcel Holtmann [Wed, 10 Jun 2020 08:59:39 +0000 (10:59 +0200)]
doc: Add commands for reading and changing runtime parameters

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agodoc: adding definitions for load default params mgmt op
Alain Michaud [Wed, 10 Jun 2020 08:47:58 +0000 (10:47 +0200)]
doc: adding definitions for load default params mgmt op

This change adds the definition for the read/set default parameter
commands.

In particular, these commands are used to read and set the system
default parameters.  The use of a TLV format also ensures that
parameters are expandable in the future.

This will allow bluetoothd to load parameters from a conf file that may
be customized for the specific requirements of each platforms.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agohealth: Fix use of L2CAP modes with bt_io
Luiz Augusto von Dentz [Mon, 8 Jun 2020 16:25:28 +0000 (09:25 -0700)]
health: Fix use of L2CAP modes with bt_io

bt_io modes are no longer compatible with L2CAP modes so the later
shall not used with bt_io APIs.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agoavctp: Fix using L2CAP modes with bt_io
Luiz Augusto von Dentz [Mon, 8 Jun 2020 16:18:50 +0000 (09:18 -0700)]
avctp: Fix using L2CAP modes with bt_io

bt_io modes are no longer compatible with L2CAP modes so the later
shall not used with bt_io APIs.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agobtio: Fix not translation mode to L2CAP mode
Luiz Augusto von Dentz [Fri, 5 Jun 2020 17:58:01 +0000 (10:58 -0700)]
btio: Fix not translation mode to L2CAP mode

When using L2CAP_OPTIONS legacy modes need to be used since they are
not compatible with BT_MODE.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agoadvertising: Fix resetting NO_BREDR flag
Luiz Augusto von Dentz [Fri, 5 Jun 2020 17:45:21 +0000 (10:45 -0700)]
advertising: Fix resetting NO_BREDR flag

When setting BT_AD_FLAG_LIMITED it was actually overwriting
BT_AD_FLAG_NO_BREDR as well so this moves the logic of detecting if the
instance needs to set BT_AD_FLAG_NO_BREDR to set_flags so it is always
updated when attempting to set any flags.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agoshared/ad: Add defines for possible flags
Luiz Augusto von Dentz [Fri, 5 Jun 2020 17:37:42 +0000 (10:37 -0700)]
shared/ad: Add defines for possible flags

This adds defines for limited disverable, general discoveral and BR/EDR
not supported.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agomain: Read default system configuration from the conf file
Alain Michaud [Fri, 29 May 2020 15:38:15 +0000 (15:38 +0000)]
main: Read default system configuration from the conf file

This change adds support for reading the configurations from the
main.conf file.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agoadapter: Set default system configuration if available
Alain Michaud [Fri, 29 May 2020 15:38:13 +0000 (15:38 +0000)]
adapter: Set default system configuration if available

This change loads any specified system configuration if provided and
supported by the kernel.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agomgmt: Add load default system configuration definitions
Alain Michaud [Fri, 29 May 2020 15:38:11 +0000 (15:38 +0000)]
mgmt: Add load default system configuration definitions

This change adds the load default system configuration definitions

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agotools/l2cap-tester: Add test for waiting disconnection response
Archie Pusaka [Tue, 5 May 2020 04:29:11 +0000 (12:29 +0800)]
tools/l2cap-tester: Add test for waiting disconnection response

This is to test the behaviour of L2CAP channel when closed with
shut_down(sock, SHUT_WR). In this case, we should wait until we
receive a disconnection response before raising G_IO_HUP.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agoaudio/avrcp: Fix media player passthrough bitmask
Archie Pusaka [Fri, 29 May 2020 05:31:04 +0000 (13:31 +0800)]
audio/avrcp: Fix media player passthrough bitmask

Adjust the values of the passthrough bitmask with the declared
keys in avctp.c:key_map, according to section 6.10.2.1 of the
AVRCP specification.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agoshared/hci: Fix crash when bt_hci_unref is used from callback
Luiz Augusto von Dentz [Thu, 4 Jun 2020 21:04:39 +0000 (14:04 -0700)]
shared/hci: Fix crash when bt_hci_unref is used from callback

If application unref its reference on the command callback it can lead
to crashes like the following:

 Invalid read of size 1
    at 0x254270: wakeup_writer (hci.c:187)
    by 0x254321: process_response (hci.c:229)
    by 0x254590: process_event (hci.c:263)
    by 0x254590: io_read_callback (hci.c:305)
    by 0x269258: watch_callback (io-glib.c:170)
    by 0x496756F: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.6200.6)
    by 0x49678FF: ??? (in /usr/lib64/libglib-2.0.so.0.6200.6)
    by 0x4967BF2: g_main_loop_run (in /usr/lib64/libglib-2.0.so.0.6200.6)
    by 0x269C6C: mainloop_run (mainloop-glib.c:79)
    by 0x26A219: mainloop_run_with_signal (mainloop-notify.c:201)
    by 0x171A35: main (main.c:770)
  Address 0x53b7e81 is 17 bytes inside a block of size 64 free'd
    at 0x483AA0C: free (vg_replace_malloc.c:540)
    by 0x254A70: bt_hci_unref (hci.c:461)

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agoshared/util: Fix undefined behavior of left shift
Sonny Sasaka [Wed, 3 Jun 2020 17:56:00 +0000 (10:56 -0700)]
shared/util: Fix undefined behavior of left shift

When left-shifting 1, we should be explicit that it is an unsigned 1.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agogatt: Fix possible crash when unable to generate hash
Luiz Augusto von Dentz [Wed, 3 Jun 2020 17:31:59 +0000 (10:31 -0700)]
gatt: Fix possible crash when unable to generate hash

gatt_db_get_hash actually depends on crypto so platforms that don't
have it enabled shall not register GATT_CHARAC_DB_HASH as otherwise it
would cause a crash due to hash being NULL.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agoa2dp: Fix crash on transport_cb
Luiz Augusto von Dentz [Mon, 1 Jun 2020 21:25:30 +0000 (14:25 -0700)]
a2dp: Fix crash on transport_cb

There have been reports of crashes on transport_cb where the setup
would most likely already have been freed but transport_cb would still
be called, so instead of assuming the setup pointer would be valid try
to lookup the list of active setups and log a warning when it happens.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agoa2dp: Fix double free in load_remote_sep
Alain Michaud [Mon, 1 Jun 2020 00:56:00 +0000 (00:56 +0000)]
a2dp: Fix double free in load_remote_sep

This patch fixes a double free condition in load_remote_sep. Value is
freed, then the inner loop is broken, but the rest of the outer loop
will attempt to free value again.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agoa2dp: Fix ref counting bug of setup_unref
Sonny Sasaka [Sat, 30 May 2020 08:51:18 +0000 (01:51 -0700)]
a2dp: Fix ref counting bug of setup_unref

In a2dp_reconfig, setup is ref-counted by cb_data. However, in the fail
label setup is unref-ed but cb_data is not cleared. This may cause
double unref in the future if cb_data gets executed. Instead, we should
do setup_cb_free to clear cb_data and unref setup.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agoadapter: Fix not removing client from discovery list
Luiz Augusto von Dentz [Thu, 28 May 2020 22:07:37 +0000 (15:07 -0700)]
adapter: Fix not removing client from discovery list

If command MGMT_OP_START_DISCOVERY fails we reply with btd_error_busy
but we don't remove the client from the list which would prevent the
client to start it once again.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agoavrcp: Don't attempt to load settings if on volume changed is supported
Luiz Augusto von Dentz [Thu, 28 May 2020 17:18:17 +0000 (10:18 -0700)]
avrcp: Don't attempt to load settings if on volume changed is supported

If only volume changed is supported that means the player cannot really
indicate track/metadata changes so don't attempt to read them.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agoavrcp: Fix always requesting player settings for category 1
Luiz Augusto von Dentz [Wed, 27 May 2020 22:39:56 +0000 (15:39 -0700)]
avrcp: Fix always requesting player settings for category 1

Player Application settings is not mandatory for category 1 so instead
of always listing the settings the code now checks if
AVRCP_FEATURE_PLAYER_SETTINGS is enabled.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agoshared/shell: don't hook io_hup on non-interactive
Stimim Chen [Wed, 27 May 2020 05:02:28 +0000 (13:02 +0800)]
shared/shell: don't hook io_hup on non-interactive

When we are in non-interactive mode (data.mode == 1), we should not
terminate the mainloop when stdin is disconnected.

For example, in bash, the following command would terminate immediately
without any output.

  : | btmgmt info

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agoadvertising: Fix advertising flags
Luiz Augusto von Dentz [Tue, 26 May 2020 18:07:48 +0000 (11:07 -0700)]
advertising: Fix advertising flags

When an instance wants to force being discoverable the code shall
actually check if the adapter is in general disverable mode already and
if not set BR/EDR as not supported so that devices scanning don't
assume BR/EDR PHY is connectable when in fact it isn't.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agoemulator: Use master settings for CIS params
Luiz Augusto von Dentz [Tue, 26 May 2020 16:41:00 +0000 (09:41 -0700)]
emulator: Use master settings for CIS params

The slave will be the first to respond with CIS Estabished but only the
master has the CIG params set so this switch to master so parameters are
proper.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agoemulator: Don't require ACL connection for Setup ISO Data Path
Luiz Augusto von Dentz [Thu, 21 May 2020 17:35:10 +0000 (10:35 -0700)]
emulator: Don't require ACL connection for Setup ISO Data Path

LE Setup ISO Data Path can be used even before the ACL handle exists
when master since Set CIG Parameters will respond with ISO handle it
can then be used to setup the data path in advance of ACL connection.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agotest/example-advertisement: Fix include_tx_power
Alvar Penning [Wed, 20 May 2020 20:44:44 +0000 (22:44 +0200)]
test/example-advertisement: Fix include_tx_power

Adding the Tx Power Level is no longer done via IncludeTxPower, but via
the tx-power value in the Includes array. The previous code did not
throw an error, but neither led to the insertion of the value. As a
result of this change, include_tx_power now adds the Tx Power Level
again.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agodoc/settings-storage: Update documentation of Endpoints
Luiz Augusto von Dentz [Mon, 18 May 2020 20:49:46 +0000 (13:49 -0700)]
doc/settings-storage: Update documentation of Endpoints

Add documentation of DelayReporting storage as that has been added to
the cache.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agodoc/media-api: Add documentation for DelayReporting
Luiz Augusto von Dentz [Mon, 18 May 2020 18:05:44 +0000 (11:05 -0700)]
doc/media-api: Add documentation for DelayReporting

The code was expecting the endpoint to expose
MediaEndpoint.DelayReporting property in order to expose
MediaTransport.Delay property.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agoa2dp: Fix caching endpoints for unknown version
Luiz Augusto von Dentz [Wed, 13 May 2020 23:20:52 +0000 (16:20 -0700)]
a2dp: Fix caching endpoints for unknown version

Don't cache the capabilities of endpoints which the version is unknown
since so capabilities may not be available in such case.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agolib: Update company identifiers
Marcel Holtmann [Wed, 20 May 2020 14:56:17 +0000 (16:56 +0200)]
lib: Update company identifiers

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agodoc: Add information about management version 1.17
Marcel Holtmann [Wed, 20 May 2020 14:43:00 +0000 (16:43 +0200)]
doc: Add information about management version 1.17

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agoHACKING: Mention disabling SELinux
Rafael Ávila de Espíndola [Tue, 12 May 2020 02:36:39 +0000 (02:36 +0000)]
HACKING: Mention disabling SELinux

Running bluetoothd from the build directory I noticed that as soon as
a bluetooth audio device was connect, bluetoothd would be disconnected
from dbus and print

Disconnected from D-Bus. Exiting.

Luiz Augusto von Dentz suggested trying with SELinux disabled and that
solved the problem.

This patch just documents how to disable SELinux before running
bluetoothd from the build directory. I would love to say more about
why that is needed, but could not find anything on the audit log.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agodoc/advertisement-monitor-api: Rename methods and shorten the preset strings
Miao-chen Chou [Wed, 6 May 2020 00:54:20 +0000 (17:54 -0700)]
doc/advertisement-monitor-api: Rename methods and shorten the preset strings

This renames RegisterApplication/UnregisterApplication to
RegisterMonitor/UnregisterMonitor and shortens the strings used in some
properties.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agohog: Set vendor, product and version for all instances
Haakon Drews [Sat, 16 May 2020 21:02:38 +0000 (23:02 +0200)]
hog: Set vendor, product and version for all instances

Set the the correct vendor and product ids for all UHID/HoG
devices when they are unknown at HoG creation time.

Before this change, when connecting a BT device with multiple HoG
services for the first time, only the first HoG instance's vendor,
product and version fields would be set by the DIS callback. This meant
that all HoG instances except the first would be left with unset values
and their UHID devices would then be created with '0000:0000' as their
vendor:product ids.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agoemulator: Fix not reporting LE Set Default PHY as supported
Luiz Augusto von Dentz [Mon, 18 May 2020 16:22:54 +0000 (09:22 -0700)]
emulator: Fix not reporting LE Set Default PHY as supported

LE Set Default PHY (Octet 35 - Bit 5) is in fact supported.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agobuild: Move --enable-hid2hci later in the list options
Marcel Holtmann [Mon, 18 May 2020 07:56:17 +0000 (09:56 +0200)]
build: Move --enable-hid2hci later in the list options

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agobuild: Enable the hid2hci tool for developers by default
Marcel Holtmann [Mon, 18 May 2020 07:54:18 +0000 (09:54 +0200)]
build: Enable the hid2hci tool for developers by default

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agobuild: Add an option to explicitly enable hid2hci
Sonny Sasaka [Wed, 13 May 2020 21:38:12 +0000 (14:38 -0700)]
build: Add an option to explicitly enable hid2hci

hid2hci is no longer a common use. This patch changes the default to not
build and install hid2hci and provide a configure flag --enable-hid2hci
to explicitly enable it.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agotest: Fix payload and model opcode packing in test-mesh
Inga Stotland [Thu, 14 May 2020 02:20:33 +0000 (19:20 -0700)]
test: Fix payload and model opcode packing in test-mesh

Use correct packing of multi-byte values in message payload bytearray.
For example, a 2-byte opcode 0x8204 is packed as 0x82 0x04, i.e. in
natural order.

Add transaction ID parameter to "set" commands of generic On/Off
model. Server will ignore the identical commands with the same
transaction ID, source and destination during a timeout period
of 6 seconds.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agoemulator: Fix response to LE Setup ISO Data Path
Luiz Augusto von Dentz [Wed, 13 May 2020 21:06:05 +0000 (14:06 -0700)]
emulator: Fix response to LE Setup ISO Data Path

LE Setup ISO Data Path expects the connection handle to be part of the
response.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agomonitor: Fix parsing of LE Setup ISO Data Path response
Luiz Augusto von Dentz [Wed, 13 May 2020 21:05:01 +0000 (14:05 -0700)]
monitor: Fix parsing of LE Setup ISO Data Path response

LE Setup ISO Data Path response actually contains the handle in addition
to the status:

> HCI Event: Command Complete (0x0e) plen 6
      LE Setup Isochronous Data Path (0x08|0x006e) ncmd 1
        Status: Success (0x00)
        Handle: 44

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agotools/btgatt-client: Add option to set BT_SECURITY_FIPS
Łukasz Rymanowski [Fri, 8 May 2020 13:23:49 +0000 (15:23 +0200)]
tools/btgatt-client: Add option to set BT_SECURITY_FIPS

Needed for GAP/SEC/SEM/BI-10-C.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agoshared/gatt-server: Fix read multiple charc values
Archie Pusaka [Thu, 7 May 2020 06:38:46 +0000 (14:38 +0800)]
shared/gatt-server: Fix read multiple charc values

According to bluetooth spec Ver 5.2, Vol 3, Part G, 4.8.4, An
ATT_ERROR_RSP PDU shall be sent by the server in response to the
ATT_READ_MULTIPLE_RSP PDU if insufficient authentication,
insufficient authorization, insufficient encryption key size, or
insufficient encryption is used by the client, or if a read operation
is not permitted on any of the Characteristic Values.

Currently if the size of the response grows larger than the MTU size,
BlueZ does an early return and not check the permission for the rest
of the characteristics. This patch forces BlueZ to check for possible
errors even though we already reach MTU size.

This patch also moves the read permission check for read multiple
characteristics so it is done before actually retrieving the
characteristics.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agoavrcp: Handle not implemented response to AVRCP_LIST_PLAYER_ATTRIBUTES
Luiz Augusto von Dentz [Thu, 7 May 2020 20:59:30 +0000 (13:59 -0700)]
avrcp: Handle not implemented response to AVRCP_LIST_PLAYER_ATTRIBUTES

If remote device respond with ctype set to not implement don't continue
parsing the packet.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agoclient: Update write callbacks with invalid offset error handlers
Mariusz Skamra [Tue, 5 May 2020 08:29:01 +0000 (10:29 +0200)]
client: Update write callbacks with invalid offset error handlers

This patch adds invalid offset handlers to write callbacks of attributes.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agoclient: Fix possible stack corruption
Łukasz Rymanowski [Thu, 7 May 2020 21:45:37 +0000 (23:45 +0200)]
client: Fix possible stack corruption

DBUS_TYPE_BOOLEAN is 'int', which does not have to be the same size as
'bool'.
On architecture where bool is smaller than in, getting prepare-authorize
will corrupt the stack

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agotools: Add support for handling experimental features
Marcel Holtmann [Tue, 5 May 2020 23:27:47 +0000 (01:27 +0200)]
tools: Add support for handling experimental features

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agomonitor: Set msft_opcode for Microsoft vendor extension
Marcel Holtmann [Tue, 5 May 2020 23:26:58 +0000 (01:26 +0200)]
monitor: Set msft_opcode for Microsoft vendor extension

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agomonitor: Decode mgmt commands and event for experimental features
Marcel Holtmann [Tue, 5 May 2020 23:26:27 +0000 (01:26 +0200)]
monitor: Decode mgmt commands and event for experimental features

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agolib: Add structures and constants for experimental feature support
Marcel Holtmann [Tue, 5 May 2020 23:25:34 +0000 (01:25 +0200)]
lib: Add structures and constants for experimental feature support

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agodoc: Add reading and setting experimental features commands
Marcel Holtmann [Tue, 5 May 2020 23:24:42 +0000 (01:24 +0200)]
doc: Add reading and setting experimental features commands

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agolib: Fixing opcode definition order
Alain Michaud [Mon, 4 May 2020 15:36:26 +0000 (15:36 +0000)]
lib: Fixing opcode definition order

Fixing what looks like a bad merge in the opcode order.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agodevice: Return error when ConnectProfile DBus method fails (second fix)
Pali Rohár [Sun, 3 May 2020 11:10:55 +0000 (13:10 +0200)]
device: Return error when ConnectProfile DBus method fails (second fix)

This is fixup of commit 3aa815a31017 ("device: Return error when
ConnectProfile DBus method fails"). There is another place which needs
to distinguish between Connect and ConnectProfile DBus method.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agoa2dp: Check for valid SEP in a2dp_reconfigure
Pali Rohár [Sun, 3 May 2020 11:06:29 +0000 (13:06 +0200)]
a2dp: Check for valid SEP in a2dp_reconfigure

a2dp_reconfigure() is called as callback when local and remote SEP does not
have to be valid anymore, sep->lsep can be NULL.

This change fixes bluetoothd daemon crash (dereferencing NULL sep->lsep)
when audio agent disconnect in the middle of the reconfigure call.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agodoc: Update assigned-numbers.txt
Pali Rohár [Sun, 3 May 2020 11:11:48 +0000 (13:11 +0200)]
doc: Update assigned-numbers.txt

Define missing rfcomm channels specified in src/profile.c

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agoshared/gatt-client: Ignore orphaned characteristics
Alain Michaud [Fri, 1 May 2020 19:22:17 +0000 (19:22 +0000)]
shared/gatt-client: Ignore orphaned characteristics

The gatt discovery proceedure simplification to discover all
characteristics at once has exposed a device side issue where some
device implementation reports orphaned characteristics.  While this
technically shouldn't be allowed, some instances of this were observed
(namely on some Android phones).

The fix is to simply skip over orphaned characteristics and continue
with everything else that is valid.

This has been tested as part of the Android CTS tests against an
affected platform and was confirmed to have worked around the issue.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agoshared/gatt-client: Fixing a few comment typos
Alain Michaud [Fri, 1 May 2020 19:24:47 +0000 (19:24 +0000)]
shared/gatt-client: Fixing a few comment typos

This change simply fixes a few comment typos.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agomonitor: Fix Set Host Feature
Luiz Augusto von Dentz [Thu, 30 Apr 2020 21:45:25 +0000 (14:45 -0700)]
monitor: Fix Set Host Feature

print_bitfield expects the actual value not the bit position:

< HCI Command: LE Set Host Feature (0x08|0x0074) plen 2
        Bit Number: 32
          Isochronous Channels (Host Support)
        Bit Value: 1

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agoa2dp: Simplify error messages
Luiz Augusto von Dentz [Thu, 30 Apr 2020 21:35:05 +0000 (14:35 -0700)]
a2dp: Simplify error messages

Printing things like Error string shall not be necessary since it is
already logging as error type.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agolog: Make error and warn log file and function information
Luiz Augusto von Dentz [Wed, 29 Apr 2020 21:01:12 +0000 (14:01 -0700)]
log: Make error and warn log file and function information

This makes it a lot simpler to find out where errors/warnings come from
and also remove the possibility of clashes when having multiple places
where the message would be exactly the same.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agodoc: Add missing empty line
Marcel Holtmann [Fri, 1 May 2020 17:52:39 +0000 (19:52 +0200)]
doc: Add missing empty line

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agomonitor: Use __attribute__ ((packed)) instead of __packed
Marcel Holtmann [Wed, 29 Apr 2020 17:46:36 +0000 (19:46 +0200)]
monitor: Use __attribute__ ((packed)) instead of __packed

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agodevice: Fix reply of DisconnectProfile
Pali Rohár [Sun, 26 Apr 2020 21:02:02 +0000 (23:02 +0200)]
device: Fix reply of DisconnectProfile

When DisconnectProfile is called with disconnected UUID, bluetooth daemon
often returned error "Operation already in progress". This change fixed it
and no error message is returned for this case.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agosrc/gatt-client: allow "command" even when property not set
David Lechner [Tue, 28 Apr 2020 17:51:49 +0000 (12:51 -0500)]
src/gatt-client: allow "command" even when property not set

This modifies the GATT client characteristic WriteValue D-Bus method to
not check that the characteristic supports the requested type of
write when the "type" option is set to "command".

Before this change, if the "type" option was used and it was set to
"reliable" or "request", then BlueZ would attempt the write even if the
characteristic does not support that write type. On the other hand, if
"type" was set to "command" or was not specified, the method would
return a org.bluez.Error.NotSupported error without attempting to write.

After this change, the WriteValue method will consistently always
ignore the characteristic properties and attempt to write when the
"type" option is used instead of having a different behavior for the
"command" type.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agogatt: Fix service_changed characteristic permission
Archie Pusaka [Tue, 21 Apr 2020 07:59:14 +0000 (15:59 +0800)]
gatt: Fix service_changed characteristic permission

According to bluetooth spec Ver 5.2, Vol 3, Part G, 7.1, the
service_changed characteristic is not readable. Therefore, this
patch marks it as such.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agodoc: Add Advertisement Monitoring API
Miao-chen Chou [Mon, 27 Apr 2020 20:12:19 +0000 (13:12 -0700)]
doc: Add Advertisement Monitoring API

This patch proposes an Advertisement Monitoring API for an application
to register a job of monitoring ADV reports with content filter and
RSSI thresholds.

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