New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 605187 link

Starred by 1 user

Issue metadata

Status: Verified
Owner:
Closed: May 2016
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Linux , Chrome
Pri: 1
Type: Bug

Blocking:
issue 602465



Sign in to add a comment

Change BlueZ GATT Server DBus API.

Project Member Reported by r...@chromium.org, Apr 20 2016

Issue description

The BlueZ GATT server DBus API currently has missing parts. Particularly,

.) The ReadValue/WriteValue methods do not include a device object, indicating which device a read/write value request came from.
.) There is no method to notify a remote connected device that a local characteristic/descriptor value has changed. This call needs to be added.

 

Comment 1 by r...@chromium.org, Apr 20 2016

Cc: luiz.von...@intel.com
+vudentz

This is on my list, what Im planning is basically the following:

diff --git a/doc/gatt-api.txt b/doc/gatt-api.txt
index ad2ab16..0861930 100644
--- a/doc/gatt-api.txt
+++ b/doc/gatt-api.txt
@@ -61,23 +61,29 @@ Service		org.bluez
 Interface	org.bluez.GattCharacteristic1 [Experimental]
 Object path	[variable prefix]/{hci0,hci1,...}/dev_XX_XX_XX_XX_XX_XX/serviceXX/charYYYY
 
-Methods		array{byte} ReadValue()
+Methods		array{byte} ReadValue(dict flags)
 
 			Issues a request to read the value of the
 			characteristic and returns the value if the
 			operation was successful.
 
+			Possible flags: "offset": Start offset (optional)
+					"device": Device path (Server only)
+
 			Possible Errors: org.bluez.Error.Failed
 					 org.bluez.Error.InProgress
 					 org.bluez.Error.NotPermitted
 					 org.bluez.Error.NotAuthorized
 					 org.bluez.Error.NotSupported
 
-		void WriteValue(array{byte} value)
+		void WriteValue(array{byte} value, dict flags)
 
 			Issues a request to write the value of the
 			characteristic.
 
+			Possible flags: "offset": Start offset (optional)
+					"device": Device path (Server only)
+
 			Possible Errors: org.bluez.Error.Failed
 					 org.bluez.Error.InProgress
 					 org.bluez.Error.NotPermitted
@@ -154,23 +160,29 @@ Service		org.bluez
 Interface	org.bluez.GattDescriptor1 [Experimental]
 Object path	[variable prefix]/{hci0,hci1,...}/dev_XX_XX_XX_XX_XX_XX/serviceXX/charYYYY/descriptorZZZ
 
-Methods		array{byte} ReadValue()
+Methods		array{byte} ReadValue(dict flags)
 
 			Issues a request to read the value of the
 			characteristic and returns the value if the
 			operation was successful.
 
+			Possible flags: "offset": Start offset (optional)
+					"device": Device path (Server only)
+
 			Possible Errors: org.bluez.Error.Failed
 					 org.bluez.Error.InProgress
 					 org.bluez.Error.NotPermitted
 					 org.bluez.Error.NotAuthorized
 					 org.bluez.Error.NotSupported
 
-		void WriteValue(array{byte} value)
+		void WriteValue(array{byte} value, dict flags)
 
 			Issues a request to write the value of the
 			characteristic.
 
+			Possible flags: "offset": Start offset (optional)
+					"device": Device path (Server only)
+
 			Possible Errors: org.bluez.Error.Failed
 					 org.bluez.Error.InProgress
 					 org.bluez.Error.NotPermitted
@@ -294,7 +306,7 @@ Object path	[variable prefix]/{hci0,hci1,...}
 Methods		void RegisterApplication(object application, dict options)
 
 			Registers a local GATT services hierarchy as described
-			above.
+			above (GATT Server) and/or profiles (GATT Client).
 
 			The application object path together with the D-Bus
 			system bus connection ID define the identification of

Comment 3 by r...@chromium.org, Apr 22 2016

Thanks for the update! Have just two questions :)

.) This doesn't add an API to let us send notifications to a central device that we've updated a local characteristic/descriptor value, right? How much work do you believe that would be?
.) Do you have an approximate idea of what timelines are you looking at? Is there any way we can help?
Changes to local characteristic/descriptor is better done changing the entire service since ServiceChanged has be sent with the range of the service so the client can perform a discovery, furthermore most GATT database don't reserve extra space in between services which means you will not be able to add new attributes to service. Also note that while it would be possible for BlueZ to reserve space in practice this would cause extra time for clients discovering these area. While this is true we could perhaps allow this over D-Bus but internally we still would remove/add the services.

As for timeline I would like to have this as soon as possible, so fill free to send patches, I will probably start with the API changes above.

Comment 5 by ortuno@chromium.org, Apr 25 2016

Components: IO>Bluetooth

Comment 6 by ortuno@chromium.org, Apr 25 2016

Components: -OS>Systems>Bluetooth

Comment 7 by r...@chromium.org, Apr 26 2016

So last question Luiz. I am trying to figure out the BlueZ equivalent to this API:
http://developer.android.com/reference/android/bluetooth/BluetoothGattServer.html#notifyCharacteristicChanged(android.bluetooth.BluetoothDevice,%20android.bluetooth.BluetoothGattCharacteristic,%20boolean)

Currently there doesn't seem to be an explicit API to do this. We could probably simulate this by sending a properties changed signal on a characteristic but having an explicit API might be useful since both Android and iOS provide it.


The iOS equivalent API is:
https://developer.apple.com/library/tvos/documentation/CoreBluetooth/Reference/CBPeripheralManager_Class/index.html#//apple_ref/occ/instm/CBPeripheralManager/updateValue:forCharacteristic:onSubscribedCentrals:

Comment 8 by r...@chromium.org, Apr 28 2016

vudentz replied on IRC:

<vudentz> rkc, there is the StartNotification then the Application just need to send PropertiesChanged("Value") which will be send with ATT notification, and in the plus side we actually tell the application with StopNotification when there is no device connected with CCC configured.

So ideally we 'should' just be able to use the properties changed signal to trigger a notification. This is only if the remote central has requested a StartNotification though.
Just a heads up that Ive started implementing the changes, should be posting them later today or tomorrow.
Status: Started (was: Assigned)
Thanks. Luiz. I also started looking at this.
Friendly ping.
I still waiting for the implementation to start looking at this.
Will be sending the changes today, we found a bug that prevent the proper ordering of signals on D-Bus thus the delay.
Project Member

Comment 13 by bugdroid1@chromium.org, May 14 2016

Labels: merge-merged-chromeos-5.39
The following revision refers to this bug:
  https://chromium.googlesource.com/chromiumos/third_party/bluez/+/2a2e7102cd86ec3c28cc2b7e003ba8deb07f4731

commit 2a2e7102cd86ec3c28cc2b7e003ba8deb07f4731
Author: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Date: Mon May 09 13:51:18 2016

FROMLIST: doc/gatt-api: Add options dictionary to ReadValue/WriteValue

This adds the possibility to pass an offset to these operations, and
also in the server case to give the device object.

(am from http://www.spinics.net/lists/linux-bluetooth/msg67177.html)
[puthik: fix conflict with the patch below in src/gatt-client.c
 96bfbb5 - CHROMIUM: Make GATT server API non-experimental]

BUG= 605187 
TEST=Build

Change-Id: I8db42d59a2cf79cfd437a609ebf89712df56c1d1
Reviewed-on: https://chromium-review.googlesource.com/344691
Commit-Ready: Rahul Chaturvedi <rkc@chromium.org>
Tested-by: Rahul Chaturvedi <rkc@chromium.org>
Reviewed-by: Rahul Chaturvedi <rkc@chromium.org>

[modify] https://crrev.com/2a2e7102cd86ec3c28cc2b7e003ba8deb07f4731/src/gatt-client.c
[modify] https://crrev.com/2a2e7102cd86ec3c28cc2b7e003ba8deb07f4731/doc/gatt-api.txt
[modify] https://crrev.com/2a2e7102cd86ec3c28cc2b7e003ba8deb07f4731/src/gatt-database.c

3 days from branch. Please remove M-52 label from issues, or schedule for 53, as appropriate.

Comment 15 by r...@chromium.org, May 16 2016

Status: Fixed (was: Started)
Status: Verified (was: Fixed)
bulk verify of io>bluetooth gatt server bugs

Sign in to add a comment