| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_GATT_SERVICE_H_ | 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_GATT_SERVICE_H_ |
| 6 #define DEVICE_BLUETOOTH_BLUETOOTH_GATT_SERVICE_H_ | 6 #define DEVICE_BLUETOOTH_BLUETOOTH_GATT_SERVICE_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 // requests that are issued from remote clients. | 38 // requests that are issued from remote clients. |
| 39 class Delegate { | 39 class Delegate { |
| 40 public: | 40 public: |
| 41 // Callbacks used for communicating GATT request responses. | 41 // Callbacks used for communicating GATT request responses. |
| 42 typedef base::Callback<void(const std::vector<uint8>)> ValueCallback; | 42 typedef base::Callback<void(const std::vector<uint8>)> ValueCallback; |
| 43 typedef base::Closure ErrorCallback; | 43 typedef base::Closure ErrorCallback; |
| 44 | 44 |
| 45 // Called when a remote device in the central role requests to read the | 45 // Called when a remote device in the central role requests to read the |
| 46 // value of the characteristic |characteristic| starting at offset |offset|. | 46 // value of the characteristic |characteristic| starting at offset |offset|. |
| 47 // This method is only called if the characteristic was specified as | 47 // This method is only called if the characteristic was specified as |
| 48 // readable and any authentication and authorization challanges were | 48 // readable and any authentication and authorization challenges were |
| 49 // satisfied by the remote device. | 49 // satisfied by the remote device. |
| 50 // | 50 // |
| 51 // To respond to the request with success and return the requested value, | 51 // To respond to the request with success and return the requested value, |
| 52 // the delegate must invoke |callback| with the value. Doing so will | 52 // the delegate must invoke |callback| with the value. Doing so will |
| 53 // automatically update the value property of |characteristic|. To respond | 53 // automatically update the value property of |characteristic|. To respond |
| 54 // to the request with failure (e.g. if an invalid offset was given), | 54 // to the request with failure (e.g. if an invalid offset was given), |
| 55 // delegates must invoke |error_callback|. If neither callback parameter is | 55 // delegates must invoke |error_callback|. If neither callback parameter is |
| 56 // invoked, the request will time out and result in an error. Therefore, | 56 // invoked, the request will time out and result in an error. Therefore, |
| 57 // delegates MUST invoke either |callback| or |error_callback|. | 57 // delegates MUST invoke either |callback| or |error_callback|. |
| 58 virtual void OnCharacteristicReadRequest( | 58 virtual void OnCharacteristicReadRequest( |
| 59 const BluetoothGattService* service, | 59 const BluetoothGattService* service, |
| 60 const BluetoothGattCharacteristic* characteristic, | 60 const BluetoothGattCharacteristic* characteristic, |
| 61 int offset, | 61 int offset, |
| 62 const ValueCallback& callback, | 62 const ValueCallback& callback, |
| 63 const ErrorCallback& error_callback) = 0; | 63 const ErrorCallback& error_callback) = 0; |
| 64 | 64 |
| 65 // Called when a remote device in the central role requests to write the | 65 // Called when a remote device in the central role requests to write the |
| 66 // value of the characteristic |characteristic| starting at offset |offset|. | 66 // value of the characteristic |characteristic| starting at offset |offset|. |
| 67 // This method is only called if the characteristic was specified as | 67 // This method is only called if the characteristic was specified as |
| 68 // writeable and any authentication and authorization challanges were | 68 // writable and any authentication and authorization challenges were |
| 69 // satisfied by the remote device. | 69 // satisfied by the remote device. |
| 70 // | 70 // |
| 71 // To respond to the request with success the delegate must invoke | 71 // To respond to the request with success the delegate must invoke |
| 72 // |callback| with the new value of the characteristic. Doing so will | 72 // |callback| with the new value of the characteristic. Doing so will |
| 73 // automatically update the value property of |characteristic|. To respond | 73 // automatically update the value property of |characteristic|. To respond |
| 74 // to the request with failure (e.g. if an invalid offset was given), | 74 // to the request with failure (e.g. if an invalid offset was given), |
| 75 // delegates must invoke |error_callback|. If neither callback parameter is | 75 // delegates must invoke |error_callback|. If neither callback parameter is |
| 76 // invoked, the request will time out and result in an error. Therefore, | 76 // invoked, the request will time out and result in an error. Therefore, |
| 77 // delegates MUST invoke either |callback| or |error_callback|. | 77 // delegates MUST invoke either |callback| or |error_callback|. |
| 78 virtual void OnCharacteristicWriteRequest( | 78 virtual void OnCharacteristicWriteRequest( |
| 79 const BluetoothGattService* service, | 79 const BluetoothGattService* service, |
| 80 const BluetoothGattCharacteristic* characteristic, | 80 const BluetoothGattCharacteristic* characteristic, |
| 81 const std::vector<uint8>& value, | 81 const std::vector<uint8>& value, |
| 82 int offset, | 82 int offset, |
| 83 const ValueCallback& callback, | 83 const ValueCallback& callback, |
| 84 const ErrorCallback& error_callback) = 0; | 84 const ErrorCallback& error_callback) = 0; |
| 85 | 85 |
| 86 // Called when a remote device in the central role requests to read the | 86 // Called when a remote device in the central role requests to read the |
| 87 // value of the descriptor |descriptor| starting at offset |offset|. | 87 // value of the descriptor |descriptor| starting at offset |offset|. |
| 88 // This method is only called if the characteristic was specified as | 88 // This method is only called if the characteristic was specified as |
| 89 // readable and any authentication and authorization challanges were | 89 // readable and any authentication and authorization challenges were |
| 90 // satisfied by the remote device. | 90 // satisfied by the remote device. |
| 91 // | 91 // |
| 92 // To respond to the request with success and return the requested value, | 92 // To respond to the request with success and return the requested value, |
| 93 // the delegate must invoke |callback| with the value. Doing so will | 93 // the delegate must invoke |callback| with the value. Doing so will |
| 94 // automatically update the value property of |descriptor|. To respond | 94 // automatically update the value property of |descriptor|. To respond |
| 95 // to the request with failure (e.g. if an invalid offset was given), | 95 // to the request with failure (e.g. if an invalid offset was given), |
| 96 // delegates must invoke |error_callback|. If neither callback parameter is | 96 // delegates must invoke |error_callback|. If neither callback parameter is |
| 97 // invoked, the request will time out and result in an error. Therefore, | 97 // invoked, the request will time out and result in an error. Therefore, |
| 98 // delegates MUST invoke either |callback| or |error_callback|. | 98 // delegates MUST invoke either |callback| or |error_callback|. |
| 99 virtual void OnDescriptorReadRequest( | 99 virtual void OnDescriptorReadRequest( |
| 100 const BluetoothGattService* service, | 100 const BluetoothGattService* service, |
| 101 const BluetoothGattDescriptor* descriptor, | 101 const BluetoothGattDescriptor* descriptor, |
| 102 int offset, | 102 int offset, |
| 103 const ValueCallback& callback, | 103 const ValueCallback& callback, |
| 104 const ErrorCallback& error_callback) = 0; | 104 const ErrorCallback& error_callback) = 0; |
| 105 | 105 |
| 106 // Called when a remote device in the central role requests to write the | 106 // Called when a remote device in the central role requests to write the |
| 107 // value of the descriptor |descriptor| starting at offset |offset|. | 107 // value of the descriptor |descriptor| starting at offset |offset|. |
| 108 // This method is only called if the characteristic was specified as | 108 // This method is only called if the characteristic was specified as |
| 109 // writeable and any authentication and authorization challanges were | 109 // writable and any authentication and authorization challenges were |
| 110 // satisfied by the remote device. | 110 // satisfied by the remote device. |
| 111 // | 111 // |
| 112 // To respond to the request with success the delegate must invoke | 112 // To respond to the request with success the delegate must invoke |
| 113 // |callback| with the new value of the descriptor. Doing so will | 113 // |callback| with the new value of the descriptor. Doing so will |
| 114 // automatically update the value property of |descriptor|. To respond | 114 // automatically update the value property of |descriptor|. To respond |
| 115 // to the request with failure (e.g. if an invalid offset was given), | 115 // to the request with failure (e.g. if an invalid offset was given), |
| 116 // delegates must invoke |error_callback|. If neither callback parameter is | 116 // delegates must invoke |error_callback|. If neither callback parameter is |
| 117 // invoked, the request will time out and result in an error. Therefore, | 117 // invoked, the request will time out and result in an error. Therefore, |
| 118 // delegates MUST invoke either |callback| or |error_callback|. | 118 // delegates MUST invoke either |callback| or |error_callback|. |
| 119 virtual void OnDescriptorWriteRequest( | 119 virtual void OnDescriptorWriteRequest( |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 protected: | 220 protected: |
| 221 BluetoothGattService(); | 221 BluetoothGattService(); |
| 222 | 222 |
| 223 private: | 223 private: |
| 224 DISALLOW_COPY_AND_ASSIGN(BluetoothGattService); | 224 DISALLOW_COPY_AND_ASSIGN(BluetoothGattService); |
| 225 }; | 225 }; |
| 226 | 226 |
| 227 } // namespace device | 227 } // namespace device |
| 228 | 228 |
| 229 #endif // DEVICE_BLUETOOTH_BLUETOOTH_GATT_SERVICE_H_ | 229 #endif // DEVICE_BLUETOOTH_BLUETOOTH_GATT_SERVICE_H_ |
| OLD | NEW |