platform/upstream/bluez.git
5 years agotools/btpclient: Fix setting/reseting connectable flag 34/205034/1
Grzegorz Kolodziejczyk [Fri, 12 Jan 2018 14:10:09 +0000 (15:10 +0100)]
tools/btpclient: Fix setting/reseting connectable flag

Defined setting flag is presented as mask.

Change-Id: Ib4561f41c40a1ea83ea76cb1a7ff84494eda871f
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agotools/obexctl: Add generator for session/transfer 33/205033/1
ERAMOTO Masaya [Thu, 28 Dec 2017 05:44:23 +0000 (14:44 +0900)]
tools/obexctl: Add generator for session/transfer

Change-Id: I4c4470c84bab90759a0b1ac1199503f82c4cf5bf
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agotools/bluetooth-player: Add generator for player/item 32/205032/1
ERAMOTO Masaya [Thu, 28 Dec 2017 05:44:20 +0000 (14:44 +0900)]
tools/bluetooth-player: Add generator for player/item

Change-Id: I7c86e9046b5d6cf63bf38eb731d6f09b2c70a779
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agotools/btpclient: Add set connectable command 31/205031/1
Grzegorz Kolodziejczyk [Thu, 28 Dec 2017 13:11:18 +0000 (14:11 +0100)]
tools/btpclient: Add set connectable command

This patch adds set connectable command for btp client.

Change-Id: Ibc06b6df3dfa5edfe17b2181bc76cb1677606ceb
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agotools/btpclient: Add start, stop discovery commands 30/205030/1
Grzegorz Kolodziejczyk [Thu, 28 Dec 2017 13:11:17 +0000 (14:11 +0100)]
tools/btpclient: Add start, stop discovery commands

This patch adds start and stop discovery command for btp client.

Change-Id: Id7740fbcf4014ff64ef0d2ea500ae8aa8080b6d1
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agotools/btpclient: Add device found event 29/205029/1
Grzegorz Kolodziejczyk [Thu, 28 Dec 2017 13:11:16 +0000 (14:11 +0100)]
tools/btpclient: Add device found event

This patch adds device found event handler. It's called when rssi
property of device changes and new device interface is added.

Change-Id: Iabda61beb8d68e38836135b21830318be388f64f
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agotools/btpclient: Add advertising proxy to adapter 28/205028/1
Grzegorz Kolodziejczyk [Thu, 28 Dec 2017 13:11:15 +0000 (14:11 +0100)]
tools/btpclient: Add advertising proxy to adapter

Advertising manager proxy is required to handle advertise related
operations in adapter context.

Change-Id: I4e269e6e5270bd6e3061f3b5a59b280dc8b3bedb
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agotools/btpclient: Move string to address conversion to helper 27/205027/1
Grzegorz Kolodziejczyk [Thu, 28 Dec 2017 13:11:14 +0000 (14:11 +0100)]
tools/btpclient: Move string to address conversion to helper

This patch makes local helper with string to address conversion.

Change-Id: I924ba5f2711d226164dd651e300d88b6db779c40
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoshared/ecc: Make ecc_make_key() a stand alone API 26/205026/1
Brian Gix [Mon, 7 May 2018 22:35:24 +0000 (15:35 -0700)]
shared/ecc: Make ecc_make_key() a stand alone API

And correct minor flaws in API descriptions

Change-Id: I0fd146cbc0c4bc0637a2c0dc894c6fed1209d30a
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agotest: Switch to Python3 25/205025/1
Krzysztof Kozlowski [Mon, 28 May 2018 11:37:08 +0000 (13:37 +0200)]
test: Switch to Python3

Python2 will be maintained till end of 2019.  Switch to Python3 by
replacing iteritems() with items() to fix error when runnig test-nap:

AttributeError: 'dbus.Dictionary' object has no attribute 'iteritems'

Change-Id: Ie810df78bbcab4c772210386643d9210d25652d1
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agogatt: Don't require prepare write authorization for trusted devices 24/205024/1
Grzegorz Kolodziejczyk [Tue, 29 May 2018 08:32:18 +0000 (10:32 +0200)]
gatt: Don't require prepare write authorization for trusted devices

This patch adds possibility to ommit prepare write authorization
request from trusted devices.

Change-Id: I3b10ec4ebe01f6f1c93bbfb43f6e79e44aa0dd79
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoclient: Don't require authorization for trusted devices 23/205023/1
Grzegorz Kolodziejczyk [Tue, 29 May 2018 08:32:17 +0000 (10:32 +0200)]
client: Don't require authorization for trusted devices

This patch adds possibility to ommit authorization request from trusted
devices.

Change-Id: Ic93b8b2c1ef4b57b9d9447a0c2581ca5c25d3566
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoshared/shell: Disable argument count check if optarg are detected 22/205022/1
Luiz Augusto von Dentz [Tue, 29 May 2018 08:26:58 +0000 (11:26 +0300)]
shared/shell: Disable argument count check if optarg are detected

Command which start with optional arguments might be using optargs
format in which case checking argument count check does not work so
this disables it which shall make things btmgmt work:

[mgmt]# add-adv --help
Usage: add-adv [options] <instance_id>
Options:
 -u, --uuid <uuid>         Service UUID
 -d, --adv-data <data>     Advertising Data bytes
 -s, --scan-rsp <data>     Scan Response Data bytes
 -t, --timeout <timeout>   Timeout in seconds
 -D, --duration <duration> Duration in seconds
 -c, --connectable         "connectable" flag
 -g, --general-discov      "general-discoverable" flag
 -l, --limited-discov      "limited-discoverable" flag
 -n, --scan-rsp-local-name "local-name" flag
 -a, --scan-rsp-appearance "appearance" flag
 -m, --managed-flags       "managed-flags" flag
 -p, --tx-power            "tx-power" flag
e.g.:
add-adv -u 180d -u 180f -d 080954657374204C45 1
[mgmt]# add-adv -u 180d -u 180f -d 080954657374204C45 1
Instance added: 1

Change-Id: I6588e8a904d669843c2da9a5c43365d16752afd7
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoclient: Add authorized property handling to characteristic attribute 21/205021/1
Grzegorz Kolodziejczyk [Mon, 28 May 2018 08:20:53 +0000 (10:20 +0200)]
client: Add authorized property handling to characteristic attribute

This patch adds handling of characteristic prepare write authorized
property to bluetoothctl.

Change-Id: Iebd336a271f02aee3c41a64aecb215257001a0d6
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoshared/gatt-server: Request authorization for prepare writes 20/205020/1
Grzegorz Kolodziejczyk [Mon, 28 May 2018 08:20:52 +0000 (10:20 +0200)]
shared/gatt-server: Request authorization for prepare writes

This patch adds gatt-server possibility to request authorization from
application if needed and previously wasn't authorized. Authorization is
requested by sending message with set prepare write authorization reqest
to client.

Change-Id: Ic1d8eca62c8df593d8f7d035451c63eb7267b889
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agodoc/gatt-api: Add authorization options for attributes 19/205019/1
Grzegorz Kolodziejczyk [Mon, 28 May 2018 08:20:51 +0000 (10:20 +0200)]
doc/gatt-api: Add authorization options for attributes

This patch adds authorization property for attributes and prepare write
request for authorization option for write request. This is require to
handle correctly prepare writes, which may response with insufficient
authorization error.

Change-Id: I11da9b9cf6982a71d66f00f1f383f71bcac1d43a
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoinput: Fix compiler error with GCC 8.0 18/205018/1
Luiz Augusto von Dentz [Mon, 28 May 2018 08:22:48 +0000 (11:22 +0300)]
input: Fix compiler error with GCC 8.0

This fixes the following error:

profiles/input/device.c: In function ‘hidp_add_connection’:
profiles/input/device.c:677:47: error: ‘%s’ directive output may be truncated writing up to 127 bytes into a region of size between 0 and 127 [-Werror=format-truncation=]
    snprintf(req->name, sizeof(req->name), "%s %s",
                                               ^~
         pname, sdesc);
                ~~~~~
profiles/input/device.c:677:4: note: ‘snprintf’ output between 2 and 256 bytes into a destination of size 128
    snprintf(req->name, sizeof(req->name), "%s %s",
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         pname, sdesc);

Change-Id: I36f1c408e8e30e95f81d97f5eab182cbec4c80d2
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoandroid: Fix some compilation warnings 17/205017/1
Szymon Janc [Fri, 25 May 2018 11:24:50 +0000 (13:24 +0200)]
android: Fix some compilation warnings

Change-Id: I92c2d127077f482875ea05b52e32e64163f1b2e3
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoandroid/client: Fix compilation with GCC 8 16/205016/1
Szymon Janc [Wed, 9 May 2018 12:11:13 +0000 (14:11 +0200)]
android/client: Fix compilation with GCC 8

  CC       android/client/android_haltest-if-gatt.o
android/client/if-gatt.c: In function ‘multi_adv_set_inst_data_p’:
android/client/if-gatt.c:2034:7: error: ‘set_scan_rsp’ may be used
      uninitialized in this function [-Werror=maybe-uninitialized]
  EXEC(if_gatt->client->multi_adv_set_inst_data, client_if, set_scan_rsp,
       ^~~~~~~
android/client/if-gatt.c:2034:7: error: ‘include_name’ may be used
         uninitialized in this function [-Werror=maybe-uninitialized]
android/client/if-gatt.c:2034:7: error: ‘include_txpower’ may be used
         uninitialized in this function [-Werror=maybe-uninitialized]
android/client/if-gatt.c: In function ‘set_adv_data_p’:
android/client/if-gatt.c:1859:7: error: ‘set_scan_rsp’ may be used
         uninitialized in this function [-Werror=maybe-uninitialized]
  EXEC(if_gatt->client->set_adv_data, client_if, set_scan_rsp,
       ^~~~~~~
android/client/if-gatt.c:1859:7: error: ‘include_name’ may be used
         uninitialized in this function [-Werror=maybe-uninitialized]
android/client/if-gatt.c:1859:7: error: ‘include_txpower’ may be used
         uninitialized in this function [-Werror=maybe-uninitialized]
cc1: all warnings being treated as errors
make[1]: *** [Makefile:6431: android/client/android_haltest-if-gatt.o] Error 1
make: *** [Makefile:3262: all] Error 2

Change-Id: Ic77375ee4c8bd608ede860dad5cc6b763d62d1c4
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agomonitor: Add command line option to disable pager support 15/205015/1
Marcel Holtmann [Thu, 24 May 2018 14:29:50 +0000 (16:29 +0200)]
monitor: Add command line option to disable pager support

Change-Id: I9d720e2947c4f65a85e5b2c9346cd879f19d7f10
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agocups: Fix compiler warning from string operation 14/205014/1
Marcel Holtmann [Thu, 24 May 2018 13:47:50 +0000 (15:47 +0200)]
cups: Fix compiler warning from string operation

Change-Id: I45b0daa738f48bf27e58f959a4c62ba3c7e30d1a
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agomidi: Fix compiler warning from string operation 13/205013/1
Marcel Holtmann [Thu, 24 May 2018 13:47:33 +0000 (15:47 +0200)]
midi: Fix compiler warning from string operation

Change-Id: I48d1c4da0261c6fcbad1b82b38da36ac3b9f1743
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoinput: Fix compiler warning from string operation 12/205012/1
Marcel Holtmann [Thu, 24 May 2018 13:47:09 +0000 (15:47 +0200)]
input: Fix compiler warning from string operation

Change-Id: I486ba2dacf9e058730e5f54f9eadd8ace45875b4
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agohealth: Fix compiler warning from casting functions 11/205011/1
Marcel Holtmann [Thu, 24 May 2018 13:46:53 +0000 (15:46 +0200)]
health: Fix compiler warning from casting functions

Change-Id: I927c2f443c275912f6c63b96389284df8dc56700
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoobex: Fix compiler warning from casting functions 10/205010/1
Marcel Holtmann [Thu, 24 May 2018 13:46:16 +0000 (15:46 +0200)]
obex: Fix compiler warning from casting functions

Change-Id: I62a902faf609375da3a470ba2c39d1172ed2030f
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoclient: Add advertise.discoverable-timeout command 09/205009/1
Luiz Augusto von Dentz [Mon, 21 May 2018 13:21:05 +0000 (16:21 +0300)]
client: Add advertise.discoverable-timeout command

This adds advertise.discoverable-timeout command which can be used to
limit the amount of time the advertisement is discoverable:

[bluetooth]# advertise.discoverable on
[bluetooth]# advertise.discoverable-timeout 10
[bluetooth]# advertise on

@ MGMT Command: Add Advertising (0x003e) plen 14
        Instance: 1
        Flags: 0x00000001
          Switch into Connectable mode
        Duration: 0
        Timeout: 0
        Advertising data length: 3
        Flags: 0x02
          LE General Discoverable Mode
        Scan response length: 0
@ MGMT Event: Advertising Added (0x0023) plen 1
        Instance: 1
@ MGMT Event: Command Complete (0x0001) plen 4
      Add Advertising (0x003e) plen 1
        Status: Success (0x00)
        Instance: 1
@ MGMT Command: Add Advertising (0x003e) plen 14
        Instance: 1
        Flags: 0x00000001
          Switch into Connectable mode
        Duration: 0
        Timeout: 0
        Advertising data length: 3
        Flags: 0x00
        Scan response length: 0

Change-Id: I4d4a936d529355d5ae0092b84e7e62d0c174bf61
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoadvertising: Add implementation of DiscoverableTimeout property 08/205008/1
Luiz Augusto von Dentz [Mon, 21 May 2018 13:20:26 +0000 (16:20 +0300)]
advertising: Add implementation of DiscoverableTimeout property

This parses the contents of DiscoverableTimeout property and add
a timeout handler which clears the discoverable when it expires.

Change-Id: Ibdf4d2b27570aa44fa4a9ae40297a2f1f8e43c67
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoandroid: Fix a few compiler warnings 07/205007/1
Marcel Holtmann [Thu, 24 May 2018 13:45:59 +0000 (15:45 +0200)]
android: Fix a few compiler warnings

Change-Id: Ie480a1741a996280b8afbfd4b7618139a9702cbe
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agodoc/advertising-api: Add DiscoverableTimeout property 06/205006/1
Luiz Augusto von Dentz [Mon, 21 May 2018 13:16:06 +0000 (16:16 +0300)]
doc/advertising-api: Add DiscoverableTimeout property

This property can control how long an instance is visible.

Change-Id: I2aa7d30eba41feba64de2dad02c74d4f70f69cf3
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoclient: Print AD Data and Discoverable once registered 05/205005/1
Luiz Augusto von Dentz [Mon, 7 May 2018 15:52:26 +0000 (18:52 +0300)]
client: Print AD Data and Discoverable once registered

This prints both Data and Discoverable if advertise command succeeds:

[bluetooth]# advertise.data 0x26 0x01 0x00
[bluetooth]# advertise.discoverable on
[bluetooth]# advertise on
Advertising object registered
Data Type: 0x26
  01 00                                            ..
Tx Power: off
Name: off
Apperance: off
Discoverable: on

Change-Id: I51d7d8c05531d62f486c8026cc4bfb2458b57892
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoclient: Add advertise.discoverable command 04/205004/1
Luiz Augusto von Dentz [Mon, 7 May 2018 15:41:10 +0000 (18:41 +0300)]
client: Add advertise.discoverable command

This adds advertise.discoverable command which can be used to set it
own instance:

[bluetooth]# advertise.discoverable on
[bluetooth]# advertise on

@ MGMT Command: Add Advertising (0x003e) plen 14
        Instance: 1
        Flags: 0x00000001
          Switch into Connectable mode
        Duration: 0
        Timeout: 0
        Advertising data length: 3
        Flags: 0x02
          LE General Discoverable Mode
        Scan response length: 0
< HCI Command: LE Set Advertising Data (0x08|0x0008) plen 32
        Length: 3
        Flags: 0x02
          LE General Discoverable Mode

Change-Id: I664dce815fd1d6122177c4b135ecaf89f17270ff
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoadvertising: Add implementation of Discoverable property 03/205003/1
Luiz Augusto von Dentz [Mon, 7 May 2018 15:35:49 +0000 (18:35 +0300)]
advertising: Add implementation of Discoverable property

This parses the contents of Discoverable property and add it to AD data
directly using bt_ad_add_flags.

Change-Id: Ib2bffbd688617335866e59a35521899246fc0b4b
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoshared/ad: Add function to manipulate flags 02/205002/1
Luiz Augusto von Dentz [Mon, 7 May 2018 10:29:55 +0000 (13:29 +0300)]
shared/ad: Add function to manipulate flags

This adds basically functionality to manipulate AD flags.

Change-Id: Ie3158a2ec1b5e1f96551813e97e61402df172e6d
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agodoc/advertising-api: Add Discoverable property 01/205001/1
Luiz Augusto von Dentz [Mon, 7 May 2018 08:18:03 +0000 (11:18 +0300)]
doc/advertising-api: Add Discoverable property

This adds Discoverable which the application can use in case it want
to set the General Discoverable flag per instance.

Note: This would allow for example an application to advertise as
discoverable even if the adapter is not discoverable which may be
required by dual-mode as it may not require BR/EDR to be discoverable.

Change-Id: I3f487a062d3a9ca84221c83b91d82c7729d5a34f
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agocore: Fix compiler warning from wrong array size 00/205000/1
Marcel Holtmann [Wed, 23 May 2018 14:36:05 +0000 (16:36 +0200)]
core: Fix compiler warning from wrong array size

Change-Id: Ic925c621462ef5ee23c1fcef06a9f02e9222ee11
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoinput: Fix compiler warning from wrong array size 99/204999/1
Marcel Holtmann [Wed, 23 May 2018 14:35:43 +0000 (16:35 +0200)]
input: Fix compiler warning from wrong array size

Change-Id: I85037014fe12aec0004e0d7af8843b7cfc2faa6f
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agolib: Fix compiler warning from wrong array size 98/204998/1
Marcel Holtmann [Wed, 23 May 2018 14:35:32 +0000 (16:35 +0200)]
lib: Fix compiler warning from wrong array size

Change-Id: Ia0e7212821f17317447fe0c542151d00cfe24933
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agomonitor: Fix compiler warning from wrong array size 97/204997/1
Marcel Holtmann [Wed, 23 May 2018 14:34:52 +0000 (16:34 +0200)]
monitor: Fix compiler warning from wrong array size

Change-Id: I733c6045f104f04a4e691440a745bc1b1efcec4b
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agocore: Fix compiler warning from casting functions 96/204996/1
Marcel Holtmann [Wed, 23 May 2018 14:33:49 +0000 (16:33 +0200)]
core: Fix compiler warning from casting functions

Change-Id: Ic50f4575ec227e010ee757871830b36e97e25a4e
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agohealth: Fix compiler warning from casting functions 95/204995/1
Marcel Holtmann [Wed, 23 May 2018 14:32:49 +0000 (16:32 +0200)]
health: Fix compiler warning from casting functions

Change-Id: Iadc7298af4b3bd265f9f458b428c3b6bb11a53b1
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agogobex: Fix compiler warning from casting functions 94/204994/1
Marcel Holtmann [Wed, 23 May 2018 14:32:22 +0000 (16:32 +0200)]
gobex: Fix compiler warning from casting functions

Change-Id: Ia92479c68ee53ffdab6b1e5031311e0a8fee6cab
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoclient: Fix use of g_free 93/204993/1
Luiz Augusto von Dentz [Mon, 21 May 2018 11:25:50 +0000 (14:25 +0300)]
client: Fix use of g_free

g_free shall only be used with pointer allocated with g_* functions.

Change-Id: I3785e6d68878094d7384aa803eaac1f003a98087
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoclient: Fix use of g_free 92/204992/1
Luiz Augusto von Dentz [Mon, 21 May 2018 08:35:06 +0000 (11:35 +0300)]
client: Fix use of g_free

g_free shall only be used with pointer allocated with g_* functions.

Change-Id: I21104ef31d029e65544f5a087d2881c8088837dc
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoclient/gatt : Add support for Included Service 91/204991/1
Avichal Agarwal [Thu, 17 May 2018 17:01:16 +0000 (22:31 +0530)]
client/gatt : Add support for Included Service

included service support implemented at service registration

Change-Id: Ia2c17d43018085cc13f9c82c8d5a4da5cf2c33ae
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoFix possible invalid memory access 90/204990/1
Nagaraj D R [Fri, 18 May 2018 03:58:16 +0000 (09:28 +0530)]
Fix possible invalid memory access

Uninitialized data is read from local variable 'addr'

Change-Id: I9ad5b9be4a578f5450a08d0aa60a22c530dff8c5
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoclient: Define maximum attribute value length as initial value 89/204989/1
Grzegorz Kolodziejczyk [Wed, 16 May 2018 13:52:27 +0000 (15:52 +0200)]
client: Define maximum attribute value length as initial value

Initial registered attribute value is set as maximal attribute length.

Change-Id: Ic3ecd011e1a46348e6cee53a99a86158c004608b
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoclient: Add missing duplicated string free 88/204988/1
Grzegorz Kolodziejczyk [Wed, 16 May 2018 13:52:26 +0000 (15:52 +0200)]
client: Add missing duplicated string free

This patch free duplicated strings in read, write attribute callbacks.

Change-Id: I07368a2fc03c66c125868490655a2e503aa816f2
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agosrc/profile: Updates HFP version to 1.7 87/204987/1
Ankit Navik [Thu, 10 May 2018 09:32:03 +0000 (15:02 +0530)]
src/profile: Updates HFP version to 1.7

Add changes to update HFP version to 0x0107 for HFP_HS_UUID and
HFP_AG_UUID. Ofono get this version from bluez and enable HFP 1.7
specific commands.

Change-Id: Ic4093b2e5f57c7a3a5028c906608ce4d90d46f73
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agotest/example-advertisement: add python3 support 86/204986/1
Hunt, Preston [Fri, 4 May 2018 14:59:18 +0000 (14:59 +0000)]
test/example-advertisement: add python3 support

This adds support for python3 to the existing script. The script will
now work with either python2 or python3.

Change-Id: I1c74860c1aaca0adafb99746772590a7e38b6fde
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoobexd: Fix memory leak when loading plugins 85/204985/1
Sahil Pai [Thu, 3 May 2018 12:05:38 +0000 (17:35 +0530)]
obexd: Fix memory leak when loading plugins

On failure to open plugin directory, memory allocated to 'patterns'
and 'excludes' is not being freed, and the following memory leak is
logged:

Direct leak of 28 byte(s) in 1 object(s) allocated from:
    #0 0xb6aa1c49 in malloc (/usr/lib/liblsan.so+0x9c49)
    #1 0xb6976e89 in g_malloc (/lib/libglib-2.0.so.0+0x3ae89)
    #2 0xb69886f1 in g_strsplit_set (/lib/libglib-2.0.so.0+0x4c6f1)
    #3 0xb6f82f3b in plugin_init (/usr/libexec/bluetooth/obexd+0x20f3b)
    #4 0xb6f70dc9 in main (/usr/libexec/bluetooth/obexd+0xedc9)

Change-Id: I9c930ba8fcd4cd04a25f4329ee02c5696c19cf39
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agotest/example-advertisement: Add Data property 84/204984/1
Luiz Augusto von Dentz [Wed, 2 May 2018 09:17:17 +0000 (12:17 +0300)]
test/example-advertisement: Add Data property

This adds Data property using TDS AD type:

@ MGMT Command: Add Advertising (0x003e) plen 59
        Instance: 1
        Flags: 0x00000001
          Switch into Connectable mode
        Duration: 0
        Timeout: 0
        Advertising data length: 29
        16-bit Service UUIDs (complete): 2 entries
          Heart Rate (0x180d)
          Battery Service (0x180f)
        Company: internal use (65535)
          Data: 0001020304
        Service Data (UUID 0x9999): 0001020304
        Transport Discovery Data
          Organization: Bluetooth SIG (0x01)
          Flags: 0x01
            Role: 0x01
              Seeker Only
            Transport Data Incomplete: False (0x00)
            Transport State: 0x00
              Off
          Length: 0
          Data:
        Scan response length: 19
        Name (complete): TestAdvertisement

Change-Id: If00bfc0f9208caf5ad8c9d48c123c4c414523265
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoclient: Make info command print Advertising{Flags,Data} 83/204983/1
Luiz Augusto von Dentz [Fri, 20 Apr 2018 12:57:46 +0000 (15:57 +0300)]
client: Make info command print Advertising{Flags,Data}

Change-Id: Ib2be54fdf70ef8ff8f290a4d480e8c84a4276039
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoclient: Add support for setting advertising Data property 82/204982/1
Luiz Augusto von Dentz [Wed, 18 Apr 2018 10:11:10 +0000 (13:11 +0300)]
client: Add support for setting advertising Data property

This adds data command to advertise menu which can be used to set
an arbitrary/profile specific advertising type and data:

[bluetooth]# data 0x26 0x01 0x01 0x00

Change-Id: I8a5fdbf2d098366aedab00a8c137036f8ec5ae7e
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agomonitor: Add support for Transport Discovery AD 81/204981/1
Luiz Augusto von Dentz [Tue, 17 Apr 2018 13:57:47 +0000 (16:57 +0300)]
monitor: Add support for Transport Discovery AD

This adds support for decoding Transport Discovery Data:

@ MGMT Command: Add Advertising (0x003e) plen 16
        Instance: 1
        Flags: 0x00000001
          Switch into Connectable mode
        Duration: 0
        Timeout: 0
        Advertising data length: 5
        Transport Discovery Data
          Organization: Bluetooth SIG (0x01)
          Flags: 0x01
            Role: 0x01
              Seeker Only
            Transport Data Incomplete: False (0x00)
            Transport State: 0x00
              Off
          Length: 0
          Data:
        Scan response length: 0

Change-Id: Ib4df36ec7bc44eef963c3b6854f03c1ac6010272
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoadvertising: Add Data implementation 80/204980/1
Luiz Augusto von Dentz [Tue, 17 Apr 2018 13:56:18 +0000 (16:56 +0300)]
advertising: Add Data implementation

This adds the support for Data property.

Change-Id: I1e2f7ad6c05b9e470e49c30563eb5573a4453e90
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agodoc/advertising-api: Add Data property 79/204979/1
Luiz Augusto von Dentz [Tue, 17 Apr 2018 13:51:05 +0000 (16:51 +0300)]
doc/advertising-api: Add Data property

Data property can be used to add advertising data with arbitrary/profile
specific type.

Change-Id: I8904912649df7720c7ce631a207f309290097795
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agodevice: Add implementation of AdvertisingData 78/204978/1
Luiz Augusto von Dentz [Tue, 17 Apr 2018 13:26:10 +0000 (16:26 +0300)]
device: Add implementation of AdvertisingData

This adds the implementation of AdvertisingData property:

[CHG] Device 00:1B:DC:07:31:88 AdvertisingData Key: 0x26
[CHG] Device 00:1B:DC:07:31:88 AdvertisingData Value:
  01 01 00                                         ...

Change-Id: Idb4d29968e84d10c2643a1e8bc0dc6c981acd716
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agodoc/device-api: Add AdvertisingData property 77/204977/1
Luiz Augusto von Dentz [Tue, 17 Apr 2018 13:15:11 +0000 (16:15 +0300)]
doc/device-api: Add AdvertisingData property

This adds AdvertisingData which exposes data being advertised which is
may be useful for profiles not handled by bluetoothd.

Change-Id: I50623393e2beba866f371a46c14306c2bd0e9ac1
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoshared/ad: Add support for arbritary type 76/204976/1
Luiz Augusto von Dentz [Tue, 17 Apr 2018 13:07:56 +0000 (16:07 +0300)]
shared/ad: Add support for arbritary type

This adds APIs to include data of arbritary type as long as it is not
of a type which blacklisted due to being handled already or it is
considered to safe to be set by an application.

Change-Id: Ica6e25c20719c98c81858751d4af23687abb9f66
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoclient: Add support for optional gatt write offset parameter 75/204975/1
Grzegorz Kolodziejczyk [Thu, 26 Apr 2018 12:32:00 +0000 (14:32 +0200)]
client: Add support for optional gatt write offset parameter

This patch extends missing optional gatt write offset parameter.

Change-Id: I192723597acb784ce6f86d3a7b36ca99d6b4cedf
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoclient: Add support for optional gatt read offset parameter 74/204974/1
Grzegorz Kolodziejczyk [Thu, 26 Apr 2018 12:31:59 +0000 (14:31 +0200)]
client: Add support for optional gatt read offset parameter

This patch extends missing optional gatt read offset parameter.

Change-Id: I74c8bf0ed060310a9d1c87f4d13e81e1f348c510
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoclient: Fix writing attribute values 73/204973/1
Grzegorz Kolodziejczyk [Thu, 26 Apr 2018 12:31:58 +0000 (14:31 +0200)]
client: Fix writing attribute values

Attribute values is not copied with dbus_message_iter_get_fixed_array,
so gatt write callback needs to replace old value with reallocation and
copy.

Change-Id: I7a22c69f50d289d2d4c8430e938ec2516071d7cc
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoadapter: Fix accessing NULL adv_manager 72/204972/1
Szymon Janc [Fri, 20 Apr 2018 10:45:05 +0000 (12:45 +0200)]
adapter: Fix accessing NULL adv_manager

adv_manager might be NULL also if BR/EDR only mdoe is set in main.conf
or if btd_adv_manager_new failed so checking for LE in supported
settings is not enough. This also makes btd_adv_manager_refresh
consistent with other adv_manager API regarding passing NULL manager
as function parameter.

Change-Id: I5130015896a413de89150d2e669f473e3526c6aa
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoshared/shell: Fix artifacts related to prompt 71/204971/1
Luiz Augusto von Dentz [Fri, 13 Apr 2018 14:42:40 +0000 (17:42 +0300)]
shared/shell: Fix artifacts related to prompt

Both bt_shell_prompt_input and bt_shell_input could cause the prompt to
be printed incorrectly, so they now rely on bt_shell_printf which
properly check if input and prompt shall be saved/restored.

Change-Id: Idf305cd6c29515aaca28a240103d5b08bfe3dc52
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agogatt: Fix crash with BR/EDR only adapter 70/204970/1
Szymon Janc [Wed, 4 Apr 2018 07:28:56 +0000 (09:28 +0200)]
gatt: Fix crash with BR/EDR only adapter

adapter->database can be NULL if controller is BR/EDR only or LE was
disabled. Make btd_gatt_database_restore_svc_chng_ccc accept NULL
pointer and silently ignore it similiar to rest of btd_gatt_database
API.

Invalid read of size 8
   at 0x164DCB: btd_gatt_database_restore_svc_chng_ccc (src/bluez-git/src/bluetoothd)
   by 0x17B70F: read_info_complete (src/bluez-git/src/bluetoothd)
   by 0x1A7E58: request_complete (src/bluez-git/src/bluetoothd)
   by 0x1A89AD: can_read_data (src/bluez-git/src/bluetoothd)
   by 0x1B5752: watch_callback (src/bluez-git/src/bluetoothd)
   by 0x4E852C5: g_main_context_dispatch (in /usr/lib/libglib-2.0.so.0.5600.0)
   by 0x4E856A0: ??? (in /usr/lib/libglib-2.0.so.0.5600.0)
   by 0x4E859D1: g_main_loop_run (in /usr/lib/libglib-2.0.so.0.5600.0)
   by 0x125058: main (src/bluez-git/src/bluetoothd)
 Address 0x40 is not stack'd, malloc'd or (recently) free'd

Change-Id: Ibec4e5ced0c2218d96499c47afcd2863484212eb
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agogatt: Add support for storing Service Changed CCC value 69/204969/1
Szymon Janc [Wed, 28 Mar 2018 10:10:55 +0000 (12:10 +0200)]
gatt: Add support for storing Service Changed CCC value

This adds support for storing CCC value of Service Changed
characteristic. Once bluetoothd is restart stored values are read
and any device subscribed to indications will receive Service Changed
indication with 0x00010-0xffff value. This is to invalidate any
non-core services since there is no way to verify if applications
will register their services in same order (or at all).

This fix accessing invalid handles by stacks that rely only on Service
Changed indication for rediscovery ie. Apple iOS.

Change-Id: I742bb2520a02d73aa69ca0ab5ac8c885e701c498
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoadapter: Don't refresh adv_manager for non-LE devices 68/204968/1
antoine.belvire@laposte.net [Tue, 27 Mar 2018 18:30:26 +0000 (20:30 +0200)]
adapter: Don't refresh adv_manager for non-LE devices

btd_adv_manager_refresh is called upon MGMT_SETTING_DISCOVERABLE setting change
but as only LE adapters have an adv_manager, this leads to segmentation fault
for non-LE devices:

0  btd_adv_manager_refresh (manager=0x0) at src/advertising.c:1176
1  0x0000556fe45fcb02 in settings_changed (settings=<optimized out>,
    adapter=0x556fe53f7c70) at src/adapter.c:543
2  new_settings_callback (index=<optimized out>, length=<optimized out>,
    param=<optimized out>, user_data=0x556fe53f7c70) at src/adapter.c:573
3  0x0000556fe462c278 in request_complete (mgmt=mgmt@entry=0x556fe53f20c0,
    status=<optimized out>, opcode=opcode@entry=7, index=index@entry=0,
    length=length@entry=4, param=0x556fe53eb5f9) at src/shared/mgmt.c:261
4  0x0000556fe462cd9d in can_read_data (io=<optimized out>,
    user_data=0x556fe53f20c0) at src/shared/mgmt.c:353
5  0x0000556fe46396e3 in watch_callback (channel=<optimized out>,
    cond=<optimized out>, user_data=<optimized out>)
    at src/shared/io-glib.c:170
6  0x00007fe351c980e5 in g_main_context_dispatch ()
   from /usr/lib64/libglib-2.0.so.0
7  0x00007fe351c984b0 in ?? () from /usr/lib64/libglib-2.0.so.0
8  0x00007fe351c987c2 in g_main_loop_run () from /usr/lib64/libglib-2.0.so.0
9  0x0000556fe45abc75 in main (argc=<optimized out>, argv=<optimized out>)
    at src/main.c:770

This commit prevents the call to btd_adv_manager_refresh for non-LE devices.

Change-Id: Ibc9d6631cf5f3918fc4078fc39b87d54c7643497
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoclient: Attempt to convert the device path to address 67/204967/1
Luiz Augusto von Dentz [Mon, 26 Mar 2018 12:43:06 +0000 (15:43 +0300)]
client: Attempt to convert the device path to address

Printing the object path is not only long but it also may change.

Change-Id: I9c67ba57485afb0a87b30ee8173eab1976e4127a
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoclient: Add envs for proxies 66/204966/1
Luiz Augusto von Dentz [Mon, 26 Mar 2018 12:09:05 +0000 (15:09 +0300)]
client: Add envs for proxies

This adds envs for device and adapter proxies found so other files are
able to access them.

Change-Id: I3e2c0911a2d44224f6046399d62ca4999e579e89
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agogatt: Fix checking for paired flag instead of bonded 65/204965/1
Luiz Augusto von Dentz [Tue, 27 Mar 2018 15:38:20 +0000 (18:38 +0300)]
gatt: Fix checking for paired flag instead of bonded

Device state should remain valid for devices that are bonded/stored not
only paired.

Change-Id: I7b87d8f75a18c040b52cc6210e468d984b71938c
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agodevice: Fix storing GATT attributes 64/204964/1
Szymon Janc [Mon, 26 Mar 2018 14:11:53 +0000 (16:11 +0200)]
device: Fix storing GATT attributes

This fix two issues:
 - not storing attributes after pairing if device is using RPA
 - storing attributes for temporary device if it is using static
   or public address

Change-Id: I06cfed13e4c347a15138494cfae0be65e283ae30
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agodevice: Change storage warning to debug messages 63/204963/1
Szymon Janc [Mon, 26 Mar 2018 14:11:52 +0000 (16:11 +0200)]
device: Change storage warning to debug messages

It is normal for device to have private address so there is no reason
to issue warning message when not storing data for it.

Change-Id: I9c432f6513c5e581fdc8f60f951a4639fcb6b41b
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agotools/bluetooth-player: Return exit status for non-interactive 62/204962/1
ERAMOTO Masaya [Mon, 26 Mar 2018 08:31:04 +0000 (17:31 +0900)]
tools/bluetooth-player: Return exit status for non-interactive

Change-Id: I654ed7a5e3bee27a057047c0bed1567e4b4b4866
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoclient: Return exit status for non-interactive 61/204961/1
ERAMOTO Masaya [Mon, 26 Mar 2018 08:31:02 +0000 (17:31 +0900)]
client: Return exit status for non-interactive

Change-Id: Icf727225fca0f15fb3c14061181a825133b9d175
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoAdd support for requiring min key size for access GATT characteristics 60/204960/1
Szymon Janc [Fri, 23 Mar 2018 13:08:21 +0000 (14:08 +0100)]
Add support for requiring min key size for access GATT characteristics

This allows to configure bluetoothd to require minimum encryption key
size when accessing GATT server characteristics. It is a global
configuration option affecting whole GATT database.

Change-Id: Ibec567f17447d35421f016c5e0021ef49aa713ef
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoclient: Parse all options passed for GATT attribute 59/204959/1
Luiz Augusto von Dentz [Fri, 23 Mar 2018 13:32:12 +0000 (15:32 +0200)]
client: Parse all options passed for GATT attribute

This parses the options given to Acquire*, WriteValue and ReadValue.

Change-Id: If324abcc5b02f4e36137998dc4c8d4bd77b43e8b
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agogatt: Send device and link options with AcquireNotify 58/204958/1
Luiz Augusto von Dentz [Fri, 23 Mar 2018 09:16:03 +0000 (11:16 +0200)]
gatt: Send device and link options with AcquireNotify

This adds the device and link options to AcquireNotify as mentioned in
the documentation.

Change-Id: I65ba0bc1ecc8a4c4adf90b7bc1ba515b061ee4fd
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agodoc/gatt-api: Update documentation regarding link option 57/204957/1
Luiz Augusto von Dentz [Fri, 23 Mar 2018 09:23:56 +0000 (11:23 +0200)]
doc/gatt-api: Update documentation regarding link option

This reflects what the code has already doing so any server operation which
requires the device option shall also get the link type as well.

Change-Id: Ic5f78954160ec80e053a8b83b169ea918f2ac38e
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agogatt: Fail to register service with invalid Includes property 56/204956/1
Szymon Janc [Thu, 22 Mar 2018 20:07:55 +0000 (21:07 +0100)]
gatt: Fail to register service with invalid Includes property

This is optional property but if it is present it must be of
proper type.

Change-Id: I0a144bc7ce0e7b55a5f8ba0f94d7608397491dfa
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoshared/gatt-client: Fix tracking current service during discovery 55/204955/1
Andrzej Kaczmarek [Thu, 22 Mar 2018 15:21:01 +0000 (16:21 +0100)]
shared/gatt-client: Fix tracking current service during discovery

We should mark service as completed before trying to insert another
characteristic - in case inserting characteristic for new service
fails, previous one won't be discarded.

Change-Id: I14b6af270aebc358a88ffd2419c39573a1728b31
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoshared/gatt-client: Fix discovery of discontinuous database 54/204954/1
Andrzej Kaczmarek [Thu, 22 Mar 2018 15:21:00 +0000 (16:21 +0100)]
shared/gatt-client: Fix discovery of discontinuous database

If local cache of peer's database has gaps where new services appear
after reconnection, GATT client will attempt to discover all included
services and characteristics definitions between starting handle of
first service and end handle of last service. This means the result
will contain also attributes which are already present in active
services in local database and thus attempting to add them again will
fail.

To fix this, instead of discovering whole range we'll only discover
ranges for missing services - starting with included services then
characteristics. To optimize this process we'll merge ranges of
adjacent services and any empty spaces in between - the result is
basically set of ranges without any known service. In most cases this
works the same or very similar to current implementation.

This issue can sometimes be observed with iOS devices as ANCS and CTS
services may not be available all the time.

Change-Id: I2b73f0204f2e3cb7177b97799182f608156138ef
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoshared/gatt-client: Fix removing services from pending list 53/204953/1
Andrzej Kaczmarek [Thu, 22 Mar 2018 15:20:59 +0000 (16:20 +0100)]
shared/gatt-client: Fix removing services from pending list

We should remove from pending list service which was just processed,
not the one that has just started being processed.

Change-Id: I045bc1964f0951f6fae4d116acb973d70161a801
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoclient: Fix stay on error handling in non-interactive 52/204952/1
ERAMOTO Masaya [Mon, 19 Mar 2018 08:40:48 +0000 (17:40 +0900)]
client: Fix stay on error handling in non-interactive

Returns the FAILURE status since there is no meaning of stay in
non-interactive mode when executing some commands with an invalid
argument or with no controller. Also returns with the SUCCESS status
when getting a scan filtering value or disconnecting a non-default
device.

Change-Id: Iac437afcd04648ba9bb4580201c70e1e8396a329
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agogatt: Properly handle service changes when offline 51/204951/1
Luiz Augusto von Dentz [Mon, 19 Mar 2018 12:44:27 +0000 (14:44 +0200)]
gatt: Properly handle service changes when offline

If remote peer is disconnected the indication shall be cached so when
the peer connects again it receives the changes.

Change-Id: Ic887ae4f56fdd80efa998e12f6d42f018ad7a6b3
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agogatt: Add confirmation callback 50/204950/1
Luiz Augusto von Dentz [Mon, 19 Mar 2018 12:44:26 +0000 (14:44 +0200)]
gatt: Add confirmation callback

This replaces indicate flag with confirmation callback to enable
setting custom callback if necessary.

Change-Id: I2378e4dc42a1a241eb79fe7f947a5ab20bf5c5e0
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agodoc/gatt-api: Includes shall not be mandatory 49/204949/1
Luiz Augusto von Dentz [Thu, 22 Mar 2018 09:19:14 +0000 (11:19 +0200)]
doc/gatt-api: Includes shall not be mandatory

It is perfectly fine to have a service without any Includes.

Change-Id: Ibc8746d3a961d0900fa90c7b0be04e2a10b64aca
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agobuild: Fix make distcheck 48/204948/1
Luiz Augusto von Dentz [Thu, 22 Mar 2018 09:16:26 +0000 (11:16 +0200)]
build: Fix make distcheck

Change-Id: I2ac28241236a7367f63610ae040487c9fce86099
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agobuild: Fix not disabling obexd when given --disable-obex 47/204947/1
Luiz Augusto von Dentz [Wed, 21 Mar 2018 16:52:55 +0000 (18:52 +0200)]
build: Fix not disabling obexd when given --disable-obex

--disable-obex shall disable building obexd daemon.

Change-Id: I978627b477f7ec25236e49ab1f6ac43263abf497
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoclient: Add authorization request handling for attribute operations 46/204946/1
Grzegorz Kolodziejczyk [Tue, 20 Mar 2018 14:05:19 +0000 (15:05 +0100)]
client: Add authorization request handling for attribute operations

This patch adds optional authorization request for reading, writing of
gatt database attributes.

Change-Id: Iffeabaa1ebd44b8fbf521194f603b2836e0042eb
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoclient: Update read callbacks with invalid offset error handlers 45/204945/1
Grzegorz Kolodziejczyk [Tue, 20 Mar 2018 14:05:18 +0000 (15:05 +0100)]
client: Update read callbacks with invalid offset error handlers

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

Change-Id: I7c9184e0f0caf0e43c7b37eeaa40a6a12a1fd883
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agogatt: Add org.bluez.Error.InvalidOffset for long read procedure 44/204944/1
Grzegorz Kolodziejczyk [Tue, 20 Mar 2018 14:05:17 +0000 (15:05 +0100)]
gatt: Add org.bluez.Error.InvalidOffset for long read procedure

This patch adds handling of invalid offset error for gatt database in
case if offset in read blob would be invalid.

"The Read Blob Request is repeated until the Read Blob Response’s Part
Attribute Value parameter is zero or an Error Response is sent by the server
with the Error Code set to Invalid Offset." Bluetooth Core 5.0, 4.12.2

"If the prepare Value Offset is greater than the current length of the attribute
value then all pending prepare write values shall be discarded for this client,
the queue shall be cleared and then an Error Response shall be sent with the
«Invalid Offset»." Bluetooth Core 5.0, 3.4.6.3

Change-Id: I678ca6984bde4502a3b325fd1822d21d98e6a1a9
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoclient: Fix reading long values 43/204943/1
Grzegorz Kolodziejczyk [Tue, 20 Mar 2018 14:05:16 +0000 (15:05 +0100)]
client: Fix reading long values

While value has more than single MTU can carry long read procedure will
be triggered. In such cases offset need to bo considered while getting
value from storage.

Change-Id: Ide2d67c7562a83f317e699627a7c22ba058c47f8
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agogatt-database: Add support for Included service 42/204942/1
Avichal Agarwal [Mon, 19 Mar 2018 12:02:26 +0000 (17:32 +0530)]
gatt-database: Add support for Included service

Parse Includes property and register any object path found as included
service.

Change-Id: Id0a311b31bebf6f307a621ce3d66858f209b25f5
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agodoc/gatt-api.txt: Add support for Included Service 41/204941/1
Avichal Agarwal [Tue, 20 Mar 2018 05:09:41 +0000 (10:39 +0530)]
doc/gatt-api.txt: Add support for Included Service

included service support implemented at server side

Change-Id: I1577d5a1a5cb3d469bff2bf65a918740135ddcb5
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoshared/gatt-client: Fix attempting to discovery with handle 0 40/204940/1
Luiz Augusto von Dentz [Wed, 14 Mar 2018 12:51:29 +0000 (14:51 +0200)]
shared/gatt-client: Fix attempting to discovery with handle 0

If a service was removed an no other service was added it may happen
that pending_svc has not empty but first_svc and last_svc has not been
set causing the following request:

< ACL Data TX: Handle 76 flags 0x00 dlen 11
      ATT: Read By Type Request (0x08) len 6
        Handle range: 0x0000-0x0000
        Attribute type: Include (0x2802)

Change-Id: Id628ff103fee0abfcb961aaa4e0032737b0c805c
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoshared/gatt-client: Fix secondary service discovery 39/204939/1
Luiz Augusto von Dentz [Wed, 14 Mar 2018 12:46:05 +0000 (14:46 +0200)]
shared/gatt-client: Fix secondary service discovery

If the error returned is either BT_ATT_ERROR_ATTRIBUTE_NOT_FOUND or
BT_ATT_ERROR_UNSUPPORTED_GROUP_TYPE the discovery shall be marked as
successful and no error shall be printed.

Change-Id: I3caf7be943e0457137732ee4427a38b914c7115f
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoshared/gatt-client: Omit valid errors for primary discovery 38/204938/1
Luiz Augusto von Dentz [Wed, 14 Mar 2018 12:56:30 +0000 (14:56 +0200)]
shared/gatt-client: Omit valid errors for primary discovery

BT_ATT_ERROR_ATTRIBUTE_NOT_FOUND shall not cause anything to be printed
since it is a valid response and just mark the end of primary discovery.

Change-Id: Ideebfd3b7646f5082f07edb0ae03c74272f23ec5
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoshared/gatt-server: Fix crash on read multiple 37/204937/1
Szymon Janc [Tue, 13 Mar 2018 07:47:27 +0000 (08:47 +0100)]
shared/gatt-server: Fix crash on read multiple

When read multiple includes external characteristic, call to
gatt_db_attribute_read's complete callback is asynchronous.

Fix following crash:
Use of uninitialised value of size 8
   at 0x49718A: read_multiple_complete_cb (gatt-server.c:994)
   by 0x498999: pending_read_result (gatt-db.c:136)
   by 0x49A84B: gatt_db_attribute_read_result (gatt-db.c:1787)
   by 0x451F4C: read_reply_cb (gatt-database.c:1712)
   by 0x48B221: method_call_reply (client.c:972)
   by 0x53AB601: ??? (in /usr/lib64/libdbus-1.so.3.19.3)
   by 0x53AEF7E: dbus_connection_dispatch (in /usr/lib64/libdbus-1.so.3.19.3)
   by 0x486FEF: message_dispatch (mainloop.c:72)
   by 0x50CB576: ??? (in /usr/lib64/libglib-2.0.so.0.5400.3)
   by 0x50CEB76: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.5400.3)
   by 0x50CEF1F: ??? (in /usr/lib64/libglib-2.0.so.0.5400.3)
   by 0x50CF231: g_main_loop_run (in /usr/lib64/libglib-2.0.so.0.5400.3)

Invalid read of size 8
   at 0x49718A: read_multiple_complete_cb (gatt-server.c:994)
   by 0x498999: pending_read_result (gatt-db.c:136)
   by 0x49A84B: gatt_db_attribute_read_result (gatt-db.c:1787)
   by 0x451F4C: read_reply_cb (gatt-database.c:1712)
   by 0x48B221: method_call_reply (client.c:972)
   by 0x53AB601: ??? (in /usr/lib64/libdbus-1.so.3.19.3)
   by 0x53AEF7E: dbus_connection_dispatch (in /usr/lib64/libdbus-1.so.3.19.3)
   by 0x486FEF: message_dispatch (mainloop.c:72)
   by 0x50CB576: ??? (in /usr/lib64/libglib-2.0.so.0.5400.3)
   by 0x50CEB76: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.5400.3)
   by 0x50CEF1F: ??? (in /usr/lib64/libglib-2.0.so.0.5400.3)
   by 0x50CF231: g_main_loop_run (in /usr/lib64/libglib-2.0.so.0.5400.3)
 Address 0x8 is not stack'd, malloc'd or (recently) free'd

Change-Id: Id0aca942b2c5229e798c2d4fb9d9d8c3ac86cdde
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoRelease 5.49 36/204936/1
Marcel Holtmann [Sat, 10 Mar 2018 15:35:21 +0000 (16:35 +0100)]
Release 5.49

Change-Id: Icf519908cc6e44b9e760ac7a904052d7a39bcffd
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoavctp: Fix crash when disconnecting 35/204935/1
Luiz Augusto von Dentz [Fri, 9 Mar 2018 09:26:04 +0000 (11:26 +0200)]
avctp: Fix crash when disconnecting

When disconnecting the channel queue shall not be destroyed before
freeeing all requests including those that already have been processed
otherwise the following crash may happen:

4 errors in context 2 of 103:
Invalid read of size 4
   at 0x12A5C2: control_req_destroy (avctp.c:762)
   by 0x12A539: pending_destroy (avctp.c:517)
   by 0x48A0D48: g_slist_foreach (in /usr/lib/libglib-2.0.so.0.3600.0)
   by 0x12A77B: avctp_channel_destroy (avctp.c:553)
   by 0x12A801: avctp_disconnected (avctp.c:570)
   by 0x12A0F1: control_disconnect (control.c:134)
   by 0x1306B9: avrcp_disconnect (avrcp.c:4471)
   by 0x17DAE9: btd_service_disconnect (service.c:307)
   by 0x18437D: dev_disconn_service (device.c:1405)
   by 0x48A0D48: g_slist_foreach (in /usr/lib/libglib-2.0.so.0.3600.0)
   by 0x187D87: device_request_disconnect (device.c:1437)
   by 0x187EC6: dev_disconnect (device.c:1522)
 Address 0x4fde068 is 0 bytes inside a block of size 16 free'd
   at 0x48252B3: free (vg_replace_malloc.c:446)
   by 0x4888172: g_free (in /usr/lib/libglib-2.0.so.0.3600.0)
   by 0x12AB64: avctp_queue_destroy (avctp.c:537)
   by 0x48A0D48: g_slist_foreach (in /usr/lib/libglib-2.0.so.0.3600.0)
   by 0x48A0D91: g_slist_free_full (in /usr/lib/libglib-2.0.so.0.3600.0)
   by 0x12A75E: avctp_channel_destroy (avctp.c:552)
   by 0x12A801: avctp_disconnected (avctp.c:570)
   by 0x12A0F1: control_disconnect (control.c:134)
   by 0x1306B9: avrcp_disconnect (avrcp.c:4471)
   by 0x17DAE9: btd_service_disconnect (service.c:307)
   by 0x18437D: dev_disconn_service (device.c:1405)
   by 0x48A0D48: g_slist_foreach (in /usr/lib/libglib-2.0.so.0.3600.0)

Change-Id: Ida52cd46ad8d1754e8afa84ab52f7e84b68f1065
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>