Bluetooth class changes for implementing local GATT attributes.
In this CL, we implement the changes to the platform independent and BlueZ
specific class changes to support local GATT services. The major changes
from the code in trunk are,
.) Cleaning up of the classes and implementing all missing parts.
.) Adding code to properly take ownership of attributes of all three kinds.
.) Adding structure to the attributes to correctly setup the hierarchy
expected (services <-- characteristics <-- descriptors).
.) Addition of an AttributeDelegate to handle calls from DBus and wrappers
to translate them to the BluetoothLocalGattService::Delegate.
.) Cleanup in all the code touched.
Part 1 of a 3 patch series:
https://crrev.com/1915803002 Bluetooth class changes <<<
https://crrev.com/1914893002 DBus class changes
https://crrev.com/1919683002 Adapter changes + tests
[email protected], [email protected]
BUG=601935
Review-Url: https://codereview.chromium.org/1915803002
Cr-Commit-Position: refs/heads/master@{#390315}
diff --git a/device/bluetooth/bluetooth_local_gatt_service.h b/device/bluetooth/bluetooth_local_gatt_service.h
index 30c1131..668985ae 100644
--- a/device/bluetooth/bluetooth_local_gatt_service.h
+++ b/device/bluetooth/bluetooth_local_gatt_service.h
@@ -44,7 +44,7 @@
class Delegate {
public:
// Callbacks used for communicating GATT request responses.
- typedef base::Callback<void(const std::vector<uint8_t>)> ValueCallback;
+ typedef base::Callback<void(const std::vector<uint8_t>&)> ValueCallback;
typedef base::Closure ErrorCallback;
// Called when a remote device in the central role requests to read the
@@ -74,18 +74,16 @@
// satisfied by the remote device.
//
// To respond to the request with success the delegate must invoke
- // |callback| with the new value of the characteristic. Doing so will
- // automatically update the value property of |characteristic|. To respond
- // to the request with failure (e.g. if an invalid offset was given),
- // delegates must invoke |error_callback|. If neither callback parameter is
- // invoked, the request will time out and result in an error. Therefore,
- // delegates MUST invoke either |callback| or |error_callback|.
+ // |callback|. To respond to the request with failure delegates must invoke
+ // |error_callback|. If neither callback parameter is invoked, the request
+ // will time out and result in an error. Therefore, delegates MUST invoke
+ // either |callback| or |error_callback|.
virtual void OnCharacteristicWriteRequest(
const BluetoothLocalGattService* service,
const BluetoothLocalGattCharacteristic* characteristic,
const std::vector<uint8_t>& value,
int offset,
- const ValueCallback& callback,
+ const base::Closure& callback,
const ErrorCallback& error_callback) = 0;
// Called when a remote device in the central role requests to read the
@@ -115,18 +113,16 @@
// satisfied by the remote device.
//
// To respond to the request with success the delegate must invoke
- // |callback| with the new value of the descriptor. Doing so will
- // automatically update the value property of |descriptor|. To respond
- // to the request with failure (e.g. if an invalid offset was given),
- // delegates must invoke |error_callback|. If neither callback parameter is
- // invoked, the request will time out and result in an error. Therefore,
- // delegates MUST invoke either |callback| or |error_callback|.
+ // |callback|. To respond to the request with failure delegates must invoke
+ // |error_callback|. If neither callback parameter is invoked, the request
+ // will time out and result in an error. Therefore, delegates MUST invoke
+ // either |callback| or |error_callback|.
virtual void OnDescriptorWriteRequest(
const BluetoothLocalGattService* service,
const BluetoothLocalGattDescriptor* descriptor,
const std::vector<uint8_t>& value,
int offset,
- const ValueCallback& callback,
+ const base::Closure& callback,
const ErrorCallback& error_callback) = 0;
};