| 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_GATT_CHARACTERISTIC_H_ | 5 #ifndef DEVICE_BLUETOOTH_GATT_CHARACTERISTIC_H_ |
| 6 #define DEVICE_BLUETOOTH_GATT_CHARACTERISTIC_H_ | 6 #define DEVICE_BLUETOOTH_GATT_CHARACTERISTIC_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "device/bluetooth/bluetooth_utils.h" | 12 #include "device/bluetooth/bluetooth_uuid.h" |
| 13 | 13 |
| 14 namespace device { | 14 namespace device { |
| 15 | 15 |
| 16 class BluetoothGattDescriptor; | 16 class BluetoothGattDescriptor; |
| 17 class BluetoothGattService; | 17 class BluetoothGattService; |
| 18 | 18 |
| 19 // BluetoothGattCharacteristic represents a local or remote GATT characteristic. | 19 // BluetoothGattCharacteristic represents a local or remote GATT characteristic. |
| 20 // A GATT characteristic is a basic data element used to construct a GATT | 20 // A GATT characteristic is a basic data element used to construct a GATT |
| 21 // service. Hence, instances of a BluetoothGattCharacteristic are associated | 21 // service. Hence, instances of a BluetoothGattCharacteristic are associated |
| 22 // with a BluetoothGattService. There are two ways in which this class is used: | 22 // with a BluetoothGattService. There are two ways in which this class is used: |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 // Interface for observing changes from a BluetoothGattCharacteristic. | 73 // Interface for observing changes from a BluetoothGattCharacteristic. |
| 74 // Properties of remote characteristics are received asynchonously. The | 74 // Properties of remote characteristics are received asynchonously. The |
| 75 // Observer interface can be used to be notified when the initial values of a | 75 // Observer interface can be used to be notified when the initial values of a |
| 76 // characteristic are received as well as when successive changes occur during | 76 // characteristic are received as well as when successive changes occur during |
| 77 // its life cycle. | 77 // its life cycle. |
| 78 class Observer { | 78 class Observer { |
| 79 public: | 79 public: |
| 80 // Called when the UUID of |characteristic| has changed. | 80 // Called when the UUID of |characteristic| has changed. |
| 81 virtual void UuidChanged( | 81 virtual void UuidChanged( |
| 82 BluetoothGattCharacteristic* characteristic, | 82 BluetoothGattCharacteristic* characteristic, |
| 83 const bluetooth_utils::UUID& uuid) {} | 83 const BluetoothUUID& uuid) {} |
| 84 | 84 |
| 85 // Called when the current value of |characteristic| has changed. | 85 // Called when the current value of |characteristic| has changed. |
| 86 virtual void ValueChanged( | 86 virtual void ValueChanged( |
| 87 BluetoothGattCharacteristic* characteristic, | 87 BluetoothGattCharacteristic* characteristic, |
| 88 const std::vector<uint8>& value) {} | 88 const std::vector<uint8>& value) {} |
| 89 | 89 |
| 90 // Called when the descriptors that are associated with |characteristic| | 90 // Called when the descriptors that are associated with |characteristic| |
| 91 // have changed. | 91 // have changed. |
| 92 virtual void DescriptorsChanged( | 92 virtual void DescriptorsChanged( |
| 93 BluetoothGattCharacteristic* characteristic, | 93 BluetoothGattCharacteristic* characteristic, |
| (...skipping 24 matching lines...) Expand all Loading... |
| 118 // for write requests by default, unless an instance of | 118 // for write requests by default, unless an instance of |
| 119 // BluetoothGattService::Delegate has been provided to the associated | 119 // BluetoothGattService::Delegate has been provided to the associated |
| 120 // BluetoothGattService instance, in which case the delegate will handle read | 120 // BluetoothGattService instance, in which case the delegate will handle read |
| 121 // and write requests. | 121 // and write requests. |
| 122 // | 122 // |
| 123 // NOTE: Don't explicitly set |kPropertyExtendedProperties| in |properties|. | 123 // NOTE: Don't explicitly set |kPropertyExtendedProperties| in |properties|. |
| 124 // Instead, create and add a BluetoothGattDescriptor that represents the | 124 // Instead, create and add a BluetoothGattDescriptor that represents the |
| 125 // "Characteristic Extended Properties" descriptor and this will automatically | 125 // "Characteristic Extended Properties" descriptor and this will automatically |
| 126 // set the correspoding bit in the characteristic's properties field. If | 126 // set the correspoding bit in the characteristic's properties field. If |
| 127 // |properties| has |kPropertyExtendedProperties| set, it will be ignored. | 127 // |properties| has |kPropertyExtendedProperties| set, it will be ignored. |
| 128 static BluetoothGattCharacteristic* Create(const bluetooth_utils::UUID& uuid, | 128 static BluetoothGattCharacteristic* Create(const BluetoothUUID& uuid, |
| 129 const std::vector<uint8>& value, | 129 const std::vector<uint8>& value, |
| 130 Properties properties, | 130 Properties properties, |
| 131 Permissions permissions); | 131 Permissions permissions); |
| 132 | 132 |
| 133 // The Bluetooth-specific UUID of the characteristic. | 133 // The Bluetooth-specific UUID of the characteristic. |
| 134 virtual const bluetooth_utils::UUID& GetUuid() const = 0; | 134 virtual const BluetoothUUID& GetUuid() const = 0; |
| 135 | 135 |
| 136 // Returns true, if this characteristic is hosted locally. If false, then this | 136 // Returns true, if this characteristic is hosted locally. If false, then this |
| 137 // instance represents a remote GATT characteristic. | 137 // instance represents a remote GATT characteristic. |
| 138 virtual bool IsLocal() const = 0; | 138 virtual bool IsLocal() const = 0; |
| 139 | 139 |
| 140 // Returns a pointer to the GATT service this characteristic belongs to. | 140 // Returns a pointer to the GATT service this characteristic belongs to. |
| 141 virtual const BluetoothGattService* GetService() const = 0; | 141 virtual const BluetoothGattService* GetService() const = 0; |
| 142 | 142 |
| 143 // Returns the list of GATT characteristic descriptors that provide more | 143 // Returns the list of GATT characteristic descriptors that provide more |
| 144 // information about this characteristic. | 144 // information about this characteristic. |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 BluetoothGattCharacteristic(); | 186 BluetoothGattCharacteristic(); |
| 187 virtual ~BluetoothGattCharacteristic(); | 187 virtual ~BluetoothGattCharacteristic(); |
| 188 | 188 |
| 189 private: | 189 private: |
| 190 DISALLOW_COPY_AND_ASSIGN(BluetoothGattCharacteristic); | 190 DISALLOW_COPY_AND_ASSIGN(BluetoothGattCharacteristic); |
| 191 }; | 191 }; |
| 192 | 192 |
| 193 } // namespace device | 193 } // namespace device |
| 194 | 194 |
| 195 #endif // DEVICE_BLUETOOTH_GATT_CHARACTERISTIC_H_ | 195 #endif // DEVICE_BLUETOOTH_GATT_CHARACTERISTIC_H_ |
| OLD | NEW |