platform/upstream/bluez.git
4 years agodoc/settings-storage: Document LastUsed Endpoints entry
Luiz Augusto von Dentz [Wed, 24 Apr 2019 08:37:58 +0000 (11:37 +0300)]
doc/settings-storage: Document LastUsed Endpoints entry

Document the use of LastUsed entry inside Endpoints group.

Change-Id: I8f6dbc064b34a81914d13e6c820902c32da93368
Signed-off-by: himanshu <h.himanshu@samsung.com>
4 years agoa2dp: Fix not calling SelectConfiguration on other available endpoints
Luiz Augusto von Dentz [Mon, 29 Apr 2019 10:30:34 +0000 (13:30 +0300)]
a2dp: Fix not calling SelectConfiguration on other available endpoints

Endpoint may not be able to select a valid configuration but there could
be other endpoints available that could be used, so instead of just
using the first match this collects all the matching endpoints and put
them into a queue (ordered by priority) then proceed to next endpoint
only failing if none of the available endpoits can select a valid
configuration.

Change-Id: Iefceb3ee76f89cb66c2be99986ee81a42e8c9549
Signed-off-by: himanshu <h.himanshu@samsung.com>
4 years agoa2dp: Store last used endpoint
Luiz Augusto von Dentz [Tue, 23 Apr 2019 15:46:36 +0000 (18:46 +0300)]
a2dp: Store last used endpoint

This stores the last used endpoint whenever it is considered open and
then prefer to use it when attempting to reconnect.

Change-Id: Ic1c3b0876a1f73a882e6c301fdbd7d59c65045fa
Signed-off-by: himanshu <h.himanshu@samsung.com>
4 years agoshared/gatt-db: Simplify attribute lookup
Luiz Augusto von Dentz [Wed, 10 Apr 2019 10:14:47 +0000 (13:14 +0300)]
shared/gatt-db: Simplify attribute lookup

This consolidates attribute lookup into gatt_db_foreach_in_range and
instead of using custom code for each operation.

Change-Id: Ifb12affe6d7f3f7591d9cffa454ee2abf63fe5fa
Signed-off-by: himanshu <h.himanshu@samsung.com>
4 years agoa2dp: Fix UUID of remote Sinks
Luiz Augusto von Dentz [Mon, 8 Apr 2019 09:41:39 +0000 (12:41 +0300)]
a2dp: Fix UUID of remote Sinks

Sinks were being reported as Sources.

Change-Id: I79a0f4a95376b2d7560a55bcdb0714d4edd64c7d
Signed-off-by: himanshu <h.himanshu@samsung.com>
4 years agoshared/gatt-db: Skip ahead if handle range is not within service
Luiz Augusto von Dentz [Wed, 3 Apr 2019 10:57:13 +0000 (13:57 +0300)]
shared/gatt-db: Skip ahead if handle range is not within service

This checks if a range is within service handles skipping if it is not,
it also convert the direct search to use
gatt_db_foreach_service_in_range instead so all operation that do
lookups in a range can benefit from such optimization.

Change-Id: Iaabce05612bc8744159e1f5115eb27d9bbbec7d4
Signed-off-by: himanshu <h.himanshu@samsung.com>
4 years agobuild: Check if explicit_bzero is missing
Brian Gix [Mon, 1 Apr 2019 18:45:18 +0000 (11:45 -0700)]
build: Check if explicit_bzero is missing

This check gets around the redefinition of explicit_bzero in ELL

In file included from ell/random.c:34:0:
ell/missing.h:59:20: error: static declaration of ‘explicit_bzero’ follows non-static declaration
 static inline void explicit_bzero(void *s, size_t n)
                    ^~~~~~~~~~~~~~
In file included from ./ell/util.h:26:0,
                 from ell/private.h:26,
                 from ell/random.c:33:
/usr/include/string.h:435:13: note: previous declaration of ‘explicit_bzero’ was here
 extern void explicit_bzero (void *__s, size_t __n) __THROW __nonnull ((1));
             ^~~~~~~~~~~~~~

Change-Id: I9830f40242d42ffe2128487af0b731bc62ffaaf9
Signed-off-by: himanshu <h.himanshu@samsung.com>
4 years agoemulator: Fix handling of Set Event Mask Page 2 Command
Szymon Janc [Wed, 27 Mar 2019 10:00:31 +0000 (11:00 +0100)]
emulator: Fix handling of Set Event Mask Page 2 Command

This command is also valid for BR/EDR only (was introduced in 3.0)
and for LE only controllers (Authenticated Payload Timeout Expired
Event).

Change-Id: Ice65b4a355cfe042a89f455106d244a8012c5961
Signed-off-by: himanshu <h.himanshu@samsung.com>
4 years agoautopair: Add pin codes to try for gaming input devices
Bastien Nocera [Mon, 27 Nov 2017 15:26:51 +0000 (16:26 +0100)]
autopair: Add pin codes to try for gaming input devices

As well as remote controls.

Change-Id: Ifc86c9d6d71e770899a7be9141f4d1926e8b35a5
Signed-off-by: himanshu <h.himanshu@samsung.com>
4 years agoautopair: Add more common PIN codes for audio devices
Bastien Nocera [Mon, 27 Nov 2017 15:26:50 +0000 (16:26 +0100)]
autopair: Add more common PIN codes for audio devices

PIN codes "1111", and "1234" are fairly common PIN codes used for audio
devices such as speakers and headsets. This replaces similar quirks
already present in gnome-bluetooth's PIN database.

Change-Id: I6ca058cd15a3e7b4d58720dbb6e4011f78824653
Signed-off-by: himanshu <h.himanshu@samsung.com>
4 years agoadvertising: Fix typo
Luiz Augusto von Dentz [Thu, 21 Mar 2019 12:05:48 +0000 (14:05 +0200)]
advertising: Fix typo

Fix value 'Codec' instead of 'Coded' phy.

Change-Id: I3e36b5e8dfb79222e2e8effb9df140d2fd45392e
Signed-off-by: himanshu <h.himanshu@samsung.com>
4 years agoshared/gatt-db: Remove update_attribute
Luiz Augusto von Dentz [Mon, 18 Mar 2019 16:16:06 +0000 (18:16 +0200)]
shared/gatt-db: Remove update_attribute

It is not longer needed to access the last attribute handle to figure
out its attribute since the handle is either passed directly or the
db->last_handle is used.

Change-Id: I94706812f24868dc0da81a27cc2b1feb36f1f9f1
Signed-off-by: himanshu <h.himanshu@samsung.com>
4 years agoshared/gatt-client: Fix failing to discover included attributes
Luiz Augusto von Dentz [Mon, 18 Mar 2019 16:14:00 +0000 (18:14 +0200)]
shared/gatt-client: Fix failing to discover included attributes

When there exists a included service a descriptor may already exists in
the handle location so instead of failing check if the UUID matches and
then skip to the next descriptor.

Change-Id: I6cf99f2b4316ea2f82ba393c95db72b97ca89303
Signed-off-by: himanshu <h.himanshu@samsung.com>
4 years agoshared/shell: Highlight user prompt input
Luiz Augusto von Dentz [Thu, 14 Mar 2019 14:47:32 +0000 (16:47 +0200)]
shared/shell: Highlight user prompt input

This makes them more evident compared to regular output which is now
possible since coloring prompts should not produce artifacs anymore.

Change-Id: I9010085ac9c15d78730763ff60cc741de9dcad4d
Signed-off-by: himanshu <h.himanshu@samsung.com>
4 years agoshared/gatt-client: Add debug for error with included services
Luiz Augusto von Dentz [Mon, 18 Mar 2019 16:12:23 +0000 (18:12 +0200)]
shared/gatt-client: Add debug for error with included services

This logs errors with included service so it is easier to noticed when
they are malformed.

Change-Id: Ica823cf6d61ffdfbdd49b502fc37ccd951dc956f
Signed-off-by: himanshu <h.himanshu@samsung.com>
4 years agoshared/shell: Fix colors not using proper escape sequence
Luiz Augusto von Dentz [Thu, 14 Mar 2019 14:43:11 +0000 (16:43 +0200)]
shared/shell: Fix colors not using proper escape sequence

According to readline documentation \001 and \002 has to be used to
delimit characters which takes no space:

  'Applications may indicate that the prompt contains characters that
  take up no physical screen space when displayed by bracketing a
  sequence of such characters with the special markers
  `RL_PROMPT_START_IGNORE' and `RL_PROMPT_END_IGNORE'.'

Change-Id: I7b45341e67931cb201d5e98f6efe75613779bdfc
Signed-off-by: himanshu <h.himanshu@samsung.com>
4 years agomonitor: Fix LE Set Extended Advertising Parameters TX power decoding
Szymon Janc [Tue, 26 Feb 2019 12:55:07 +0000 (13:55 +0100)]
monitor: Fix LE Set Extended Advertising Parameters TX power decoding

TX power of 127 has special meaning for this command.

Change-Id: I4b8a5c742d84008f0306f700d93d18bad4b4a989
Signed-off-by: himanshu <h.himanshu@samsung.com>
4 years agoadapter: Fix length calculation of filter UUIDs on big endian
Luiz Augusto von Dentz [Wed, 6 Mar 2019 12:39:41 +0000 (14:39 +0200)]
adapter: Fix length calculation of filter UUIDs on big endian

The management interface expect all values to be in little endian
thus the length of uuids needs to be converted on big endian.

Change-Id: I0f9759f49fb8a91a9e7f2cdf8d7b50228ded85c9
Signed-off-by: himanshu <h.himanshu@samsung.com>
4 years agomonitor: Add decoding for HCI LE Transmitter Test command [v3]
Luiz Augusto von Dentz [Thu, 28 Feb 2019 08:47:49 +0000 (10:47 +0200)]
monitor: Add decoding for HCI LE Transmitter Test command [v3]

This decodes LE Transmitter Test command [v3] introduced in 5.1.

Change-Id: Icb918f6cfa05322437a99627b04746c73878fa69
Signed-off-by: himanshu <h.himanshu@samsung.com>
4 years agomonitor: Add decoding for HCI LE Receiver Test command [v3]
Luiz Augusto von Dentz [Wed, 27 Feb 2019 14:35:44 +0000 (16:35 +0200)]
monitor: Add decoding for HCI LE Receiver Test command [v3]

This decodes LE Receiver Test command [v3] introduced in 5.1.

Change-Id: I11ba98e6d7b529790cf8db876fb3cad28eaf793c
Signed-off-by: himanshu <h.himanshu@samsung.com>
4 years agomonitor: Decode LL_CLOCK_ACCURACY_*
Luiz Augusto von Dentz [Wed, 27 Feb 2019 11:19:11 +0000 (13:19 +0200)]
monitor: Decode LL_CLOCK_ACCURACY_*

This introduces the command passing for LL_CLOCK_ACCURACY_* PDUs added
in 5.1.

Change-Id: I1ea4b2c13c60ffc842ae50fbc5c55830a0603e35
Signed-off-by: himanshu <h.himanshu@samsung.com>
4 years agomonitor: Decode LL_PERIODIC_SYNC_IND
Luiz Augusto von Dentz [Wed, 27 Feb 2019 11:12:27 +0000 (13:12 +0200)]
monitor: Decode LL_PERIODIC_SYNC_IND

This introduces the command passing for LL_PERIODIC_SYNC_IND PDU added
in 5.1.

Change-Id: I6bbc4ef6107c3bf0045ef3427458bacfec95ea92
Signed-off-by: himanshu <h.himanshu@samsung.com>
4 years agomonitor: Decode LL_CTE_*
Luiz Augusto von Dentz [Tue, 26 Feb 2019 17:01:14 +0000 (19:01 +0200)]
monitor: Decode LL_CTE_*

This introduces the command passing for LL_CTE_* PDUs added in 5.1.

Change-Id: Ife9c82a0497872b29672ecbb4b6c2d5622a32eee
Signed-off-by: himanshu <h.himanshu@samsung.com>
4 years agomonitor: Add decoding support for LL_MIN_USED_CHANNELS
Luiz Augusto von Dentz [Tue, 26 Feb 2019 13:30:46 +0000 (15:30 +0200)]
monitor: Add decoding support for LL_MIN_USED_CHANNELS

This prints makes the fields to be printed instead of just decoding
the PDU name.

Change-Id: Ida4330e9418ed7be5a6d4118d1e9097d4901aea8
Signed-off-by: himanshu <h.himanshu@samsung.com>
4 years agomonitor: Add decoding support for LL_PHY_UPDATE_IND
Luiz Augusto von Dentz [Tue, 26 Feb 2019 13:17:05 +0000 (15:17 +0200)]
monitor: Add decoding support for LL_PHY_UPDATE_IND

This prints makes the fields to be printed instead of just decoding
the PDU name.

Change-Id: Ie073880a8ed77c59d84c2e585486b2222a16926a
Signed-off-by: himanshu <h.himanshu@samsung.com>
4 years agomonitor: Add decoding support for LL_PHY_*
Luiz Augusto von Dentz [Tue, 26 Feb 2019 12:51:25 +0000 (14:51 +0200)]
monitor: Add decoding support for LL_PHY_*

This prints makes the fields to be printed instead of just decoding
the PDU name.

Change-Id: I0b18a0e73a7e818276151369424757dfbf59223c
Signed-off-by: himanshu <h.himanshu@samsung.com>
4 years agomonitor: Add decoding support for LL_LENGTH_*
Luiz Augusto von Dentz [Tue, 26 Feb 2019 11:38:30 +0000 (13:38 +0200)]
monitor: Add decoding support for LL_LENGTH_*

This prints makes the fields to be printed instead of just decoding
the PDU name.

Change-Id: I827ee274dc83c747df247a6cc9b79a5bf7f17fdc
Signed-off-by: himanshu <h.himanshu@samsung.com>
4 years agotest/example-advertisement: add shutdown code
Hunt, Preston [Mon, 24 Sep 2018 15:46:41 +0000 (15:46 +0000)]
test/example-advertisement: add shutdown code

The previous sample code did not release all resources when shutting
down. This is fine when it's a standalone program since Python will free
all resources automatically when the process terminates. However, in a
long-running process, this will eventually cause problems.

This changeset shows how to properly release all resources, if an optional
command line "--timeout" argument is used. The default is no timeout to
maintain behavior of the previous implementation (advertisements will run
forever).

Change-Id: Ica1bbbf1f9a78625e2a6d5f9ac5570609c5376e5
Signed-off-by: himanshu <h.himanshu@samsung.com>
4 years agoclient: Fix build with older version on libdbus
Luiz Augusto von Dentz [Tue, 26 Feb 2019 17:24:40 +0000 (19:24 +0200)]
client: Fix build with older version on libdbus

This fixes the following error when building with older version of
D-Bus:

client/gatt.c:2973: undefined reference to `dbus_message_iter_get_element_count'

Change-Id: Ie285fced42f67448a6a075f2e65a7726be10956c
Signed-off-by: himanshu <h.himanshu@samsung.com>
4 years agoshell: Allow multiple prompt inputs
Luiz Augusto von Dentz [Fri, 22 Feb 2019 11:32:25 +0000 (13:32 +0200)]
shell: Allow multiple prompt inputs

This allow queueing input prompts so that the application don't have to
queue themselves.

Change-Id: I5316426ce3dd2e24ff24c30276ca0f538c6d48ee
Signed-off-by: himanshu <h.himanshu@samsung.com>
4 years agoclient: Print AdvertisingManager properties on command 'show'
Luiz Augusto von Dentz [Thu, 21 Feb 2019 12:05:57 +0000 (14:05 +0200)]
client: Print AdvertisingManager properties on command 'show'

This outputs the AdvertisingManager properties command 'show':

bluetoothctl> show
...
Advertising Features:
ActiveInstances: 0x00
SupportedInstances: 0x05
SupportedIncludes: tx-power
SupportedIncludes: appearance
SupportedIncludes: local-name

Change-Id: I351131b1041ba749a1ee8afdb209dd03891c11a8
Signed-off-by: himanshu <h.himanshu@samsung.com>
4 years agoclient: Add advertise.secondary command
Luiz Augusto von Dentz [Fri, 15 Feb 2019 14:19:59 +0000 (16:19 +0200)]
client: Add advertise.secondary command

This adds advertose.secondary command which can be used to set a
secondary channel to advertise.

Change-Id: I3bfeb3620583efbe77150617b659ef02b5375dd2
Signed-off-by: himanshu <h.himanshu@samsung.com>
4 years agoadvertising: Add implementation of SecondaryChannel
Luiz Augusto von Dentz [Fri, 15 Feb 2019 12:23:22 +0000 (14:23 +0200)]
advertising: Add implementation of SecondaryChannel

This add the parsing for SecondaryChannel which indicates what secondary
PHY shall be used.

Change-Id: I419f0bfa4d53c359c767e0493170d664f7493ef7
Signed-off-by: himanshu <h.himanshu@samsung.com>
4 years agoadvertising: Add implementation of SupportedSecondaryChannels
Luiz Augusto von Dentz [Fri, 15 Feb 2019 11:53:08 +0000 (13:53 +0200)]
advertising: Add implementation of SupportedSecondaryChannels

This implements SupportedSecondaryChannels property which expose what
the supported secondary channels.

Change-Id: I95c8ba8ecb2d8379d334bbe5532fc53b90ebdeae
Signed-off-by: himanshu <h.himanshu@samsung.com>
4 years agodoc/advertising-api: Add support for setting Secondary Channel
Luiz Augusto von Dentz [Fri, 15 Feb 2019 09:15:28 +0000 (11:15 +0200)]
doc/advertising-api: Add support for setting Secondary Channel

This enables reading and setting the Secondary Channel/PHY supported
by the controller.

Change-Id: Id935400b376be31cefe18a9af93181b68d2e7ba3
Signed-off-by: himanshu <h.himanshu@samsung.com>
4 years agomonitor: Fix LE Read Transmit Power Command deconding
Szymon Janc [Fri, 15 Feb 2019 12:58:28 +0000 (13:58 +0100)]
monitor: Fix LE Read Transmit Power Command deconding

Min and max TX power are signed intergers.

Change-Id: I09cedfce59a4519cce689ee4d69dd489fea01f74
Signed-off-by: himanshu <h.himanshu@samsung.com>
4 years agoclient: Fix uninitialized error
Luiz Augusto von Dentz [Wed, 13 Feb 2019 15:07:25 +0000 (17:07 +0200)]
client: Fix uninitialized error

trusted should be initialized with false since the property may not be
available.

Change-Id: Id1529b0821d3b7a466bab8c52c150dac0d2a3714
Signed-off-by: himanshu <h.himanshu@samsung.com>
4 years agoclient: Improve logging of GATT operations
Luiz Augusto von Dentz [Wed, 13 Feb 2019 15:05:21 +0000 (17:05 +0200)]
client: Improve logging of GATT operations

This prints the UUID along with attribute path and also print the
hexdump when payload is available.

Change-Id: If48e517894a93572f0e7a19a16fe58c85a3fbfb1
Signed-off-by: himanshu <h.himanshu@samsung.com>
4 years agoclient: Forward notifications from cloned attributes
Luiz Augusto von Dentz [Wed, 13 Feb 2019 14:25:05 +0000 (16:25 +0200)]
client: Forward notifications from cloned attributes

Notifications come in a form of 'Value' property changes thus this
copies the values to the local attribute so they are in sync.

Change-Id: I76b8d58a4518c8059eb84cd3d0cdfebc0fd7daa3
Signed-off-by: himanshu <h.himanshu@samsung.com>
4 years agoclient: Remove cloned services if the proxy is removed
Luiz Augusto von Dentz [Tue, 12 Feb 2019 11:38:46 +0000 (13:38 +0200)]
client: Remove cloned services if the proxy is removed

This unregister the cloned services if the proxy is removed since they
would no longer be accessible.

Change-Id: I657787c1f534cc2493e77a61f3f062dca20494ec
Signed-off-by: himanshu <h.himanshu@samsung.com>
4 years agoclient: Proxy calls to StartNotify/StopNotify
Luiz Augusto von Dentz [Tue, 12 Feb 2019 11:23:06 +0000 (13:23 +0200)]
client: Proxy calls to StartNotify/StopNotify

This uses the proxies created by clone command to forward the
subscriptions to the cloned services.

Change-Id: I04ba4be9b9e6208afe2ea1cbcff7642e2fa3c053
Signed-off-by: himanshu <h.himanshu@samsung.com>
4 years agoclient: Proxy calls to ReadValue and WriteValue
Luiz Augusto von Dentz [Tue, 12 Feb 2019 10:00:08 +0000 (12:00 +0200)]
client: Proxy calls to ReadValue and WriteValue

This uses the proxies created by clone command to forward the requests
to the cloned services.

Change-Id: Icd16e294a5811f8ea7ba71622d3ee2079708213b
Signed-off-by: himanshu <h.himanshu@samsung.com>
4 years agoclient: Add gatt.clone command
Luiz Augusto von Dentz [Mon, 11 Feb 2019 16:36:27 +0000 (18:36 +0200)]
client: Add gatt.clone command

This adds clone command to gatt submenu which can be use to clone
services as follow:

Clone all services from the connected device:
> gatt.clone

Clone a given service
> gatt.select-attribute <attribute/uuid>
> gatt.clone

In either case there is a prompt to confirm since this may add a lot of
service the user must confim before proceding.

Then finally:

> gatt.register-application

Change-Id: Ia3298b1f1a52c04b0dad34a7b794c9f177c8978d
Signed-off-by: himanshu <h.himanshu@samsung.com>
4 years agogatt: Fix not allowing 'extended-properties' as flags
Luiz Augusto von Dentz [Mon, 11 Feb 2019 16:33:58 +0000 (18:33 +0200)]
gatt: Fix not allowing 'extended-properties' as flags

Allows 'extended-propeties' as flags.

Change-Id: I6b8c9952dd97fd0392acefe7ba687b3f07f0abf7
Signed-off-by: himanshu <h.himanshu@samsung.com>
4 years agoshared/gatt-db: Fix crash if next_handle is 0
Luiz Augusto von Dentz [Tue, 12 Feb 2019 14:38:58 +0000 (16:38 +0200)]
shared/gatt-db: Fix crash if next_handle is 0

If the database is reseted all the services shall be ignored and no
hash shall be generated.

Change-Id: I4e396dd0c5e0e9823f307115cbdebd21bb5b88ad
Signed-off-by: himanshu <h.himanshu@samsung.com>
4 years agodevice: Store Database Hash on storage
Luiz Augusto von Dentz [Mon, 12 Mar 2018 13:30:37 +0000 (15:30 +0200)]
device: Store Database Hash on storage

This stores the hash on the storage so it can be reloaded when the
daemon/system restarts.

Change-Id: Ie8d397ab41ceb60b143998a0a516b392088d5e62
Signed-off-by: himanshu <h.himanshu@samsung.com>
4 years agoshared/gatt-client: Write Client Features
Luiz Augusto von Dentz [Tue, 6 Mar 2018 12:11:14 +0000 (14:11 +0200)]
shared/gatt-client: Write Client Features

This writes the supported client features setting Robust Caching bit.

Change-Id: I13dec10d7b2888fb4d8d0774d12a06ee1f026522
Signed-off-by: himanshu <h.himanshu@samsung.com>
4 years agoshared/gatt-client: Read database hash if available
Luiz Augusto von Dentz [Tue, 6 Mar 2018 08:29:25 +0000 (10:29 +0200)]
shared/gatt-client: Read database hash if available

This reads the database hash if available and compares to the existing
value, if it matches consider the discovery is completed.

Change-Id: I5dabc14550049afe4bc1e4c6ab790cd2d25e57e2
Signed-off-by: himanshu <h.himanshu@samsung.com>
4 years agogatt: Implement Robust Caching handling for server
Luiz Augusto von Dentz [Fri, 2 Mar 2018 12:27:48 +0000 (14:27 +0200)]
gatt: Implement Robust Caching handling for server

This detects when a client becomes change-unware returning
DB Out of Sync error when that happens.

Change-Id: I0377d966ac00fbb5e17b0f2b74c660ca72d71c83
Signed-off-by: himanshu <h.himanshu@samsung.com>
4 years agoshared/gatt-server: Add bt_gatt_server_set_authorize
Luiz Augusto von Dentz [Wed, 25 Apr 2018 12:06:47 +0000 (15:06 +0300)]
shared/gatt-server: Add bt_gatt_server_set_authorize

bt_gatt_server_set_authorize can be used to set the callback to
authorize attribute operations which is required in order to send
out of sync error as that has to happen even in case the handle is
not valid.

Change-Id: I884c18492254b8401966a83b448e965b3f244bd6
Signed-off-by: himanshu <h.himanshu@samsung.com>
4 years agoshared/gatt-db: Add gatt_db_set_authorize
Luiz Augusto von Dentz [Fri, 2 Mar 2018 08:05:04 +0000 (10:05 +0200)]
shared/gatt-db: Add gatt_db_set_authorize

gatt_db_set_authorize can be used to set the callback to authorize
attribute operations.

Change-Id: Ibf79fc30ce75cff20c235371507c05ad02739105
Signed-off-by: himanshu <h.himanshu@samsung.com>
4 years agogatt: Add caching support for server
Luiz Augusto von Dentz [Thu, 1 Mar 2018 15:43:22 +0000 (17:43 +0200)]
gatt: Add caching support for server

This registers both Client Features and Database Hash Characteristics
which are mandatory for the server.

Change-Id: Ic4d808830fbc54852e77fc7a741fbf9e9d61e44b
Signed-off-by: himanshu <h.himanshu@samsung.com>
4 years agoshared/gatt-db: Generate database hash
Luiz Augusto von Dentz [Mon, 5 Mar 2018 09:33:48 +0000 (11:33 +0200)]
shared/gatt-db: Generate database hash

This use bt_crypto_hash (AES-CMAC) to generate a database hash
using the content of the attribute:

In ascending order of attribute handles, starting with the first handle,
concatenate the fields Attribute Handle, Attribute Type, and Attribute
Value if the attribute has one of the following types:
«Primary Service», «Secondary Service», «Included Service»,
«Characteristic», or «Characteristic Extended Properties», concatenate
the fields Attribute Handle and Attribute Type if the attribute has one
of the following types: «Characteristic User Description»,
«Client Characteristic Configuration»,
«Server Characteristic Configuration», «Characteristic Format», or
«Characteristic Aggregate Format», and ignore the attribute if it has
any other type (such attributes are not part of the concatenation).

Change-Id: If27ed2e2a6bfbf2549492061c928cf64afbaf10e
Signed-off-by: himanshu <h.himanshu@samsung.com>
4 years agoshared/gatt-db: Introduce Database Hash
Luiz Augusto von Dentz [Thu, 1 Mar 2018 15:41:05 +0000 (17:41 +0200)]
shared/gatt-db: Introduce Database Hash

This introduces a database hash which is generate whenever the database
changes.

Change-Id: I901800b64b7811527b7b978498ac8f0ceebe7403
Signed-off-by: himanshu <h.himanshu@samsung.com>
4 years agoApply secure log to uinput path 36/224136/1 accepted/tizen/unified/20200214.050257 submit/tizen/20200212.082409
Deokhyun Kim [Thu, 6 Feb 2020 11:27:26 +0000 (20:27 +0900)]
Apply secure log to uinput path

<6>[  712.832464]  [1:     bluetoothd: 4557] input: 64:7B:XX:XX:5A:71 as /devices/virtual/input/input6

Change-Id: I68dfc2f3362f03036d4a99a15906a95482b70354
Signed-off-by: Deokhyun Kim <dukan.kim@samsung.com>
4 years agomesh: remove unused node_set_device_key() 51/223851/1
Jakub Witowski [Thu, 30 Jan 2020 14:34:24 +0000 (15:34 +0100)]
mesh: remove unused node_set_device_key()

This patch removes node_set_device_key() function,
because it is unused.

Change-Id: Ia5468c3b055a156a8bcaed40da2930c53e565463
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
4 years agomesh: use static node_comp instead of the pointer 50/223850/1
Jakub Witowski [Thu, 30 Jan 2020 14:34:22 +0000 (15:34 +0100)]
mesh: use static node_comp instead of the pointer

There is no need to use the pointer to the node_comp data.
This pach uses static node_comp instead.

Change-Id: Ifc526013a168314678e68afcb199549344dd2083
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
4 years agomesh: Re-arrange replay protection check and add 49/223849/1
Brian Gix [Thu, 30 Jan 2020 18:59:24 +0000 (10:59 -0800)]
mesh: Re-arrange replay protection check and add

Re-arranged for efficiency. Replay Protection was set up as an atomic
check-and-add operation. Now we check the message early so we can
discard it without taking further action, and only add it to the RPL
once fully verified that it was authorized and addressed to us.

Change-Id: Ie82982c224714398a75b383df02d80be5d167eda
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
4 years agomesh: Add NVM storage of Replay Protection 48/223848/1
Brian Gix [Thu, 30 Jan 2020 18:59:23 +0000 (10:59 -0800)]
mesh: Add NVM storage of Replay Protection

Mesh specification requires that Replay Protection be preserved
across node restarts.  This adds that storage in
<node_uuid>/rpl/<iv_index>/<src>

Realtime access remains in an l_queue structure, and stored as
messages are processed.

Change-Id: I38c5992946ef788859d5859a6bd71a514706b44b
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
4 years agomesh: Apply Replay Protection to all incoming packets 47/223847/1
Brian Gix [Thu, 30 Jan 2020 18:59:22 +0000 (10:59 -0800)]
mesh: Apply Replay Protection to all incoming packets

Replay Protection was only being applied against Application Keys,
but messages with Device Keys are just as vulnerable, and need to be
checked as well.

Change-Id: Ie5643672ae04bcef045bead703db218992385e79
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
4 years agomesh: Clean-up unneeded Sequence Number increments 46/223846/1
Brian Gix [Thu, 30 Jan 2020 18:59:21 +0000 (10:59 -0800)]
mesh: Clean-up unneeded Sequence Number increments

Scrub of Sequence Number handling of OB messages to account for in-node
delivery of segmented messages, so that each discrete message has a
unique sequence number for the RPL.

Change-Id: Icff849476b9c050ae4a1ea59d0d38548eb79ac96
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
4 years agomesh: Move Replay Protection to mesh/net.c 45/223845/1
Brian Gix [Thu, 30 Jan 2020 18:59:20 +0000 (10:59 -0800)]
mesh: Move Replay Protection to mesh/net.c

The specification calls for a flatter Replay Protection List that
applies to all processed messages, regardless of which credentials
were used to secure them. So storage and checking is now centralized
in mesh/net.c

Change-Id: Icbd695147bff0cfc8aeacf727f05bcfeb7a000bc
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
4 years agomesh: Relocate tree deletion to util.c/h 44/223844/1
Brian Gix [Thu, 30 Jan 2020 18:59:19 +0000 (10:59 -0800)]
mesh: Relocate tree deletion to util.c/h

Change-Id: Ida672061f0a61cab5c69a4397c5b559446eed4f1
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
4 years agomesh: Handle publickey exchange phase for initiator 43/223843/1
Prathyusha N [Tue, 21 Jan 2020 09:14:58 +0000 (14:44 +0530)]
mesh: Handle publickey exchange phase for initiator

In Public Key OOB case, when provisioner receives public key via
OOB, provisioner has to send it's public key to remote node and
and then proceed for authentication.

Handle invalid keys case.

Change-Id: If03f436d6f94fa00f8cd4ceca41d2889c5137189
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
4 years agomesh: Fix provisioning agent method call failure 42/223842/1
Shaunak Soman [Wed, 22 Jan 2020 12:16:10 +0000 (17:46 +0530)]
mesh: Fix provisioning agent method call failure

Provisioning agent interface methods PublicKey, PrivateKey and
Cancel do not accept any parameters. So, while invoking them
explicitly set the parameters to "".

Change-Id: Ib09dc31791cda38de98af1046bd2c3db4874ec58
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
4 years agodoc/mesh-api: Fix reference discrepancy for Import() 41/223841/1
Inga Stotland [Wed, 22 Jan 2020 03:32:05 +0000 (19:32 -0800)]
doc/mesh-api: Fix reference discrepancy for Import()

Remove mentioning of ImportLocalNode() method, use Import() instead.

Change-Id: I81b110028505153bbc974717ba4d23019c2657cd
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
4 years agotools/mesh: Implement model group subscription commands 40/223840/1
Inga Stotland [Sat, 18 Jan 2020 04:22:33 +0000 (20:22 -0800)]
tools/mesh: Implement model group subscription commands

This adds implementation for:
Config Model Subscription Delete
Config Model Subscription Delete All
Config Model Subscription Overwrite

and adds handling vendor model IDs for
Config Model Subscription Add
Config Model Subscription Get

Change-Id: I204cdb350b8212bcca8b729493ed78b6f6db81ea
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
4 years agotools/mesh: Add support for Vendor Model App Get/List 39/223839/1
Inga Stotland [Sat, 18 Jan 2020 04:22:32 +0000 (20:22 -0800)]
tools/mesh: Add support for Vendor Model App Get/List

This adds implementation for sending Config Vendor App Get message
and receiving Config Vendor App List response.

Change-Id: Iac8c514285fb6443a245fd985a37f1941fd91d69
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
4 years agotools/mesh: Add length checks for rxed messages 38/223838/1
Inga Stotland [Sat, 18 Jan 2020 04:22:31 +0000 (20:22 -0800)]
tools/mesh: Add length checks for rxed messages

This adds missing validation of received responses.
If the length of a received message does not pass the
validation, it's not processed.

Change-Id: I8682c0e9b8d24ad3498927973fe7a5794e103999
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
4 years agotools/mesh: Refactor code for generating model ID 37/223837/1
Inga Stotland [Sat, 18 Jan 2020 04:22:30 +0000 (20:22 -0800)]
tools/mesh: Refactor code for generating model ID

Common code for populating message buffer with Model ID
(either SIG or vendor defined) for misc commands is refactored
into a single function.

Change-Id: I245ca1a773f334623685cdefa2afd6f099430f21
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
4 years agoRevert "Add custom uuid support to trusted profile" 75/223375/1
Anupam Roy [Wed, 29 Jan 2020 05:29:56 +0000 (14:29 +0900)]
Revert "Add custom uuid support to trusted profile"

This reverts commit 0e702c6685b29fa7e5bf4298fd9e2a12717b8767.

Change-Id: I9ae0be1e2c25784aa9aeb4f03860a61091b201d6
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomonitor: Decode GATT Caching errors
Luiz Augusto von Dentz [Tue, 6 Mar 2018 15:56:13 +0000 (17:56 +0200)]
monitor: Decode GATT Caching errors

This enables decoding of Database Out of Sync and Value Not Allowed
ATT errors introduced with GATT Caching improvements.

Change-Id: Ia130b26716745691b3cf72e81d2b9aac643657b5
Signed-off-by: himanshu <h.himanshu@samsung.com>
4 years agoshared/att-types: Add errors introduced by GATT caching
Luiz Augusto von Dentz [Thu, 1 Mar 2018 15:39:21 +0000 (17:39 +0200)]
shared/att-types: Add errors introduced by GATT caching

This adds Database Out of Sync and Value Not Allowed errors.

Change-Id: Icfc819ee46fc159e665c2e4becfef6d779da66a7
Signed-off-by: himanshu <h.himanshu@samsung.com>
4 years agoshared/util: Add decoding support for GATT caching attributes
Luiz Augusto von Dentz [Tue, 6 Mar 2018 14:58:14 +0000 (16:58 +0200)]
shared/util: Add decoding support for GATT caching attributes

This adds support to decode Client Supported Features and Database
Hash.

Change-Id: I1b7bbff5a4882d478158f5545d89783d09831b83
Signed-off-by: himanshu <h.himanshu@samsung.com>
4 years agolib/uuid: Introduce definition for GATT caching attributes
Luiz Augusto von Dentz [Thu, 1 Mar 2018 15:36:47 +0000 (17:36 +0200)]
lib/uuid: Introduce definition for GATT caching attributes

This introduces UUIDs for Client Features and Database Hash
characteristics.

Change-Id: I17fb8fd9db5309bec713b72a3ac9caee14f04974
Signed-off-by: himanshu <h.himanshu@samsung.com>
4 years agounit/test-crypto: Add test for bt_crypto_gatt_hash
Luiz Augusto von Dentz [Mon, 5 Mar 2018 14:36:55 +0000 (16:36 +0200)]
unit/test-crypto: Add test for bt_crypto_gatt_hash

This adds test case base on the example given in the spec.

Change-Id: Ibc713afd03926375087c248a4fe9882784ea95a7
Signed-off-by: himanshu <h.himanshu@samsung.com>
4 years agoshared/crypto: Add bt_crypto_gatt_hash
Luiz Augusto von Dentz [Mon, 5 Mar 2018 09:30:43 +0000 (11:30 +0200)]
shared/crypto: Add bt_crypto_gatt_hash

The bt_crypto_gatt_hash uses AES-CCM to create a hash with the contents
stored in the iovec.

Note: The spec disregards the byte order so both the key, msg and res
are not swapped.

Change-Id: Ifaa2b5ce256c17344b6a78b5f056ad5b1d63e1d7
Signed-off-by: himanshu <h.himanshu@samsung.com>
4 years agoclient: Don't expose pointer value in attribute path
Luiz Augusto von Dentz [Wed, 30 Jan 2019 13:24:18 +0000 (15:24 +0200)]
client: Don't expose pointer value in attribute path

Instead use the position in the list to create a unique path:

[bluetooth]# register-service 0x1820
[NEW] Primary Service (Handle 0x0000)
/org/bluez/app/service0
0x1820
Internet Protocol Support

Change-Id: I79485003fd2b645ff5e8698c98f52ba4ae9ce8cd
Signed-off-by: himanshu <h.himanshu@samsung.com>
4 years agoclient: Enable list-attributes to print local attributes
Luiz Augusto von Dentz [Tue, 29 Jan 2019 14:20:41 +0000 (16:20 +0200)]
client: Enable list-attributes to print local attributes

This enable passing "local" to list-attributes to print the attributes
registered locally:

> list-attributes local
Primary Service (Handle 0x0400)
/org/bluez/app/service0x74ccb0
0x1820
Internet Protocol Support

Change-Id: I13a383687c6c653097917093388f1ec41ce656f4
Signed-off-by: himanshu <h.himanshu@samsung.com>
4 years agoclient: Enable setting attribute handles
Luiz Augusto von Dentz [Mon, 28 Jan 2019 18:52:23 +0000 (20:52 +0200)]
client: Enable setting attribute handles

This emulates application setting their attribute handles.

Change-Id: Ia5e84fbc3ed591856680fb025238b12f451f1e7c
Signed-off-by: himanshu <h.himanshu@samsung.com>
4 years agoclient: Enable Handle property for GATT attributes
Luiz Augusto von Dentz [Mon, 28 Jan 2019 15:21:27 +0000 (17:21 +0200)]
client: Enable Handle property for GATT attributes

This enable bluetoothd to write back the actual value of attribute
handles.

Change-Id: I6ac327f90c2be775fa72fd95cc200a638b950358
Signed-off-by: himanshu <h.himanshu@samsung.com>
4 years agogatt: Write back the handle to Handle property
Luiz Augusto von Dentz [Mon, 28 Jan 2019 15:19:13 +0000 (17:19 +0200)]
gatt: Write back the handle to Handle property

If the application has set an attribute with Handle set to 0 inform the
allocated handle by writting the Handle property.

Change-Id: Ia1e9d3bcc55d1f7a476560c0d8bb712cdaf45194
Signed-off-by: himanshu <h.himanshu@samsung.com>
4 years agogatt: Implement Handle property
Luiz Augusto von Dentz [Mon, 28 Jan 2019 14:39:51 +0000 (16:39 +0200)]
gatt: Implement Handle property

This parses the Handle property and if it exists attempt to insert
attributes in their locations.

Change-Id: I90f34b5dae5415a4243a643d0ab034c964fd8c6b
Signed-off-by: himanshu <h.himanshu@samsung.com>
4 years agoshared/gatt-db: Allow passing 0 as handle to gatt_db_insert_*
Luiz Augusto von Dentz [Mon, 28 Jan 2019 14:38:17 +0000 (16:38 +0200)]
shared/gatt-db: Allow passing 0 as handle to gatt_db_insert_*

Handle 0 should be allocate on the next handle just as any of
gatt_db_add_* functions.

Change-Id: I5d16794c2db66203c2ccae0893ce42505f33f62f
Signed-off-by: himanshu <h.himanshu@samsung.com>
4 years agodoc/gatt-api: Add Handle property
Luiz Augusto von Dentz [Fri, 25 Jan 2019 14:32:48 +0000 (16:32 +0200)]
doc/gatt-api: Add Handle property

When acting as server it is useful to select where to allocate the
handle for an attribute so it can be restored in the same position when
restarting the daemon or rebooting the system.

In order to do that the application also needs to know in which handle
the attribute is allocated the very first time it is registered, this
also allows for a better integration with PTS and tools like auto-pts
which needs to know the handles where the attributes have been
allocated.

Change-Id: I298c07b8e6e6cb1bc163412b5c7acaed9a64b004
Signed-off-by: himanshu <h.himanshu@samsung.com>
4 years agoa2dp-codecs: Fix SBC_MAX_BITPOOL and add SBC quality modes
Pali Rohár [Tue, 29 Jan 2019 17:12:07 +0000 (18:12 +0100)]
a2dp-codecs: Fix SBC_MAX_BITPOOL and add SBC quality modes

According to A2DP specification; section SBC; Codec Specific Information
Elements; Minimum / Maximum Bitpool Value, range for Bitpool value is from
2 to 250.

A2DP specification also defines bitpool values for two SBC modes: Middle
Quality and High Quality. They depends on channel mode and frequency. So
add definitions for them into a2dp-codecs file too.

File android/hal-audio-sbc.c was updated to use High Quality mode for
chosen frequency.

Change-Id: I77cfd4c13314abf223e64cec5bab98f1d42b92a6
Signed-off-by: himanshu <h.himanshu@samsung.com>
4 years agoavinfo: Fix parsing capabilities
Pali Rohár [Sat, 26 Jan 2019 10:24:15 +0000 (11:24 +0100)]
avinfo: Fix parsing capabilities

Function print_caps() expects capabilities buffer without AVDTP header.
Previously avinfo somehow worked, because AVDTP header looks like
capability header with unknown category which was skipped.

Change-Id: Ieaf08b3cd128893d29b11d92f13f0d301059a26e
Signed-off-by: himanshu <h.himanshu@samsung.com>
4 years agoavinfo: Dump unknown codecs and unknown categories
Pali Rohár [Sat, 26 Jan 2019 10:24:50 +0000 (11:24 +0100)]
avinfo: Dump unknown codecs and unknown categories

Change-Id: Id80736771383aa6e33d66d52009c7bbc562b09ee
Signed-off-by: himanshu <h.himanshu@samsung.com>
4 years agoa2dp-codecs & avinfo: Simplify defintions and parsing of aptX family
Pali Rohár [Sat, 26 Jan 2019 10:46:06 +0000 (11:46 +0100)]
a2dp-codecs & avinfo: Simplify defintions and parsing of aptX family

Reuse whole a2dp_aptx_t structure and defines as they are same for aptX Low
Latency and aptX HD.

Change-Id: Ibeebd93c7c795f86ba07a8b2ce6df056c4c5c1a0
Signed-off-by: himanshu <h.himanshu@samsung.com>
4 years agolib: Add version number for Bluetooth 5.1
Johan Hedberg [Tue, 29 Jan 2019 15:33:15 +0000 (17:33 +0200)]
lib: Add version number for Bluetooth 5.1

Change-Id: If48f1b76a41c2891b49acecc7f2bdede93b0204f
Signed-off-by: himanshu <h.himanshu@samsung.com>
4 years agomonitor: Add Bluetooth 5.1 features and version information
Johan Hedberg [Tue, 29 Jan 2019 15:32:45 +0000 (17:32 +0200)]
monitor: Add Bluetooth 5.1 features and version information

Change-Id: I150d8cdf1780f4b06e91f2f567717d15328435a9
Signed-off-by: himanshu <h.himanshu@samsung.com>
4 years agomonitor: Reformat LE features table
Johan Hedberg [Tue, 29 Jan 2019 15:31:34 +0000 (17:31 +0200)]
monitor: Reformat LE features table

Bluetooth 5.1 has many features with long names, so reformat the table
before adding any new ones.

Change-Id: Id13571a5807d86c5c83b92501f69746e4495959b
Signed-off-by: himanshu <h.himanshu@samsung.com>
4 years agoa2dp: Add reverse discovery
Luiz Augusto von Dentz [Tue, 22 Jan 2019 13:28:12 +0000 (15:28 +0200)]
a2dp: Add reverse discovery

Now that remote endpoints are exposed there is a chance that a
configured device will reconnect and initiate SetConfiguration skipping
the discovery phase which is now required in order to be able to switch
endpoints, so this introduces the reverse discovery logic in order to
find out about remote endpoints capabilities if they have not been
found yet.

Change-Id: Ib92837aca13a17ccc1b37e363d157f0cdb6e13bc
Signed-off-by: himanshu <h.himanshu@samsung.com>
4 years agoa2dp: Add implementation of MediaEndpoint.Device
Luiz Augusto von Dentz [Tue, 15 Jan 2019 14:07:13 +0000 (11:07 -0300)]
a2dp: Add implementation of MediaEndpoint.Device

This adds the implementation of MediaEndpoint.Device property so the
clints don't need to guess what device the endpoint belongs.

Change-Id: I29a24302fced1922df417735b8b07d3fd92bc590
Signed-off-by: himanshu <h.himanshu@samsung.com>
4 years agodoc/media-api: Add Device property to MediaEndpoint
Luiz Augusto von Dentz [Tue, 15 Jan 2019 14:06:04 +0000 (11:06 -0300)]
doc/media-api: Add Device property to MediaEndpoint

This adds Device property which indicates which device the endpoint
belongs to.

Change-Id: Ic93c2478aae90e856480cd6dc51df0d4e46706c8
Signed-off-by: himanshu <h.himanshu@samsung.com>
4 years agoa2dp: Cache remote endpoints
Luiz Augusto von Dentz [Tue, 8 Jan 2019 13:34:42 +0000 (10:34 -0300)]
a2dp: Cache remote endpoints

In order to always have the Endpoint interface available the remote
endpoints needs to be cached since the remote stack may config a stream
on its own there may not be a chance to discover the endpoits available
which would make it impossible to switch endpoints.

Change-Id: I2d82cc4dd30c919428c6f21b0148710a3f458689
Signed-off-by: himanshu <h.himanshu@samsung.com>
4 years agodoc/settings-storage: Add Endpoint group to cache
Luiz Augusto von Dentz [Tue, 8 Jan 2019 13:56:13 +0000 (10:56 -0300)]
doc/settings-storage: Add Endpoint group to cache

This documents how A2DP endpoints should be stored in the cache.

Change-Id: Id84cd397f7b065cb25a308606bfe0cf75261dc4f
Signed-off-by: himanshu <h.himanshu@samsung.com>
4 years agoa2dp: Implement MediaTransport.Endpoint
Luiz Augusto von Dentz [Fri, 4 Jan 2019 19:24:18 +0000 (16:24 -0300)]
a2dp: Implement MediaTransport.Endpoint

This implements MediaTransport.Endpoint property which exposes what
endpoint is being used by the transport.

Change-Id: I423a774f8b5bd57f34ac206f65f81b7cfa1a6806
Signed-off-by: himanshu <h.himanshu@samsung.com>
4 years agodoc/media-api: Add Endpoint property to MediaTransport
Luiz Augusto von Dentz [Fri, 4 Jan 2019 19:22:05 +0000 (16:22 -0300)]
doc/media-api: Add Endpoint property to MediaTransport

Adds endpoint object to MediaTransport so application can resolve which
MediaEndpoint is in use.

Change-Id: I46106a3c0fa474409a04d29cf8eb9e8f3aff9a3f
Signed-off-by: himanshu <h.himanshu@samsung.com>
4 years agoa2dp: Expose remote SEP
Luiz Augusto von Dentz [Thu, 3 Jan 2019 16:45:43 +0000 (13:45 -0300)]
a2dp: Expose remote SEP

This implements MediaEndpoint for remote SEP which can be used by
clients to switch configuration on demand.

Change-Id: I52edc5217fd404757fd2162f9c0b7dfa65379bfb
Signed-off-by: himanshu <h.himanshu@samsung.com>