| 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_DESCRIPTOR_H_ | 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_GATT_DESCRIPTOR_H_ |
| 6 #define DEVICE_BLUETOOTH_BLUETOOTH_GATT_DESCRIPTOR_H_ | 6 #define DEVICE_BLUETOOTH_BLUETOOTH_GATT_DESCRIPTOR_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_gatt_characteristic.h" | 12 #include "device/bluetooth/bluetooth_gatt_characteristic.h" |
| 13 #include "device/bluetooth/bluetooth_uuid.h" | 13 #include "device/bluetooth/bluetooth_uuid.h" |
| 14 | 14 |
| 15 namespace device { | 15 namespace device { |
| 16 | 16 |
| 17 // BluetoothGattDescriptor represents a local or remote GATT characteristic | 17 // BluetoothGattDescriptor represents a local or remote GATT characteristic |
| 18 // descriptor. A GATT characteristic descriptor provides further information | 18 // descriptor. A GATT characteristic descriptor provides further information |
| 19 // about a characteristic's value. They can be used to describe the | 19 // about a characteristic's value. They can be used to describe the |
| 20 // characteristic's features or to control certain behaviors. | 20 // characteristic's features or to control certain behaviors. |
| 21 class BluetoothGattDescriptor { | 21 class BluetoothGattDescriptor { |
| 22 public: | 22 public: |
| 23 // The Bluetooth Specification declares several predefined descriptors that | 23 // The Bluetooth Specification declares several predefined descriptors that |
| 24 // profiles can use. The following are definitions for the list of UUIDs | 24 // profiles can use. The following are definitions for the list of UUIDs |
| 25 // and descriptions of the characteristic descriptors that they represent. | 25 // and descriptions of the characteristic descriptors that they represent. |
| 26 // Possible values for and further information on each descriptor can be found | 26 // Possible values for and further information on each descriptor can be found |
| 27 // in Core v4.0, Volume 3, Part G, Section 3.3.3. All of these desciptors are | 27 // in Core v4.0, Volume 3, Part G, Section 3.3.3. All of these descriptors are |
| 28 // optional and may not be present for a given characteristic. | 28 // optional and may not be present for a given characteristic. |
| 29 | 29 |
| 30 // The "Characteristic Extended Properties" descriptor. This defines | 30 // The "Characteristic Extended Properties" descriptor. This defines |
| 31 // additional "Characteristic Properties" which cannot fit into the allocated | 31 // additional "Characteristic Properties" which cannot fit into the allocated |
| 32 // single octet property field of a characteristic. The value is a bit field | 32 // single octet property field of a characteristic. The value is a bit field |
| 33 // and the two predefined bits, as per Bluetooth Core Specification v4.0, are: | 33 // and the two predefined bits, as per Bluetooth Core Specification v4.0, are: |
| 34 // | 34 // |
| 35 // - Reliable Write: 0x0001 | 35 // - Reliable Write: 0x0001 |
| 36 // - Writable Auxiliaries: 0x0002 | 36 // - Writable Auxiliaries: 0x0002 |
| 37 // | 37 // |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 // the Characteristic Value. The value is composed of 7 octets which are | 76 // the Characteristic Value. The value is composed of 7 octets which are |
| 77 // divided into groups that represent different semantic meanings. For a | 77 // divided into groups that represent different semantic meanings. For a |
| 78 // detailed description of how the value of this descriptor should be | 78 // detailed description of how the value of this descriptor should be |
| 79 // interpreted, refer to Core v4.0, Volume 3, Part G, Section 3.3.3.5. If more | 79 // interpreted, refer to Core v4.0, Volume 3, Part G, Section 3.3.3.5. If more |
| 80 // than one declaration of this descriptor exists for a characteristic, then a | 80 // than one declaration of this descriptor exists for a characteristic, then a |
| 81 // "Characteristic Aggregate Format" descriptor must also exist for that | 81 // "Characteristic Aggregate Format" descriptor must also exist for that |
| 82 // characteristic. | 82 // characteristic. |
| 83 static const BluetoothUUID& CharacteristicPresentationFormatUuid(); | 83 static const BluetoothUUID& CharacteristicPresentationFormatUuid(); |
| 84 | 84 |
| 85 // The "Characteristic Aggregate Format" descriptor defines the format of an | 85 // The "Characteristic Aggregate Format" descriptor defines the format of an |
| 86 // aggragated characteristic value. In GATT's underlying protocol, ATT, each | 86 // aggregated characteristic value. In GATT's underlying protocol, ATT, each |
| 87 // attribute is identified by a handle that is unique for the hosting server. | 87 // attribute is identified by a handle that is unique for the hosting server. |
| 88 // Multiple characteristics can share the same instance(s) of a | 88 // Multiple characteristics can share the same instance(s) of a |
| 89 // "Characteristic Presentation Format" descriptor. The value of the | 89 // "Characteristic Presentation Format" descriptor. The value of the |
| 90 // "Characteristic Aggregate Format" descriptor contains a list of handles | 90 // "Characteristic Aggregate Format" descriptor contains a list of handles |
| 91 // that each refer to a "Characteristic Presentation Format" descriptor that | 91 // that each refer to a "Characteristic Presentation Format" descriptor that |
| 92 // is used by that characteristic. Hence, exactly one instance of this | 92 // is used by that characteristic. Hence, exactly one instance of this |
| 93 // descriptor must exist if more than one "Characteristic Presentation Format" | 93 // descriptor must exist if more than one "Characteristic Presentation Format" |
| 94 // descriptors exist for a characteristic. | 94 // descriptors exist for a characteristic. |
| 95 // | 95 // |
| 96 // Applications that are using the device::Bluetooth API do not have access to | 96 // Applications that are using the device::Bluetooth API do not have access to |
| 97 // the underlying handles and shouldn't use this descriptor to determine which | 97 // the underlying handles and shouldn't use this descriptor to determine which |
| 98 // "Characteristic Presentation Format" desciptors belong to a characteristic. | 98 // "Characteristic Presentation Format" descriptors belong to a |
| 99 // characteristic. |
| 99 // The API will construct a BluetoothGattDescriptor object for each instance | 100 // The API will construct a BluetoothGattDescriptor object for each instance |
| 100 // of "Characteristic Presentation Format" descriptor per instance of | 101 // of "Characteristic Presentation Format" descriptor per instance of |
| 101 // BluetoothGattCharacteristic that represents a remote characteristic. | 102 // BluetoothGattCharacteristic that represents a remote characteristic. |
| 102 // Similarly for local characteristics, implementations DO NOT need to create | 103 // Similarly for local characteristics, implementations DO NOT need to create |
| 103 // an instance of BluetoothGattDescriptor for this descriptor as this will be | 104 // an instance of BluetoothGattDescriptor for this descriptor as this will be |
| 104 // handled by the subsystem. | 105 // handled by the subsystem. |
| 105 static const BluetoothUUID& CharacteristicAggregateFormatUuid(); | 106 static const BluetoothUUID& CharacteristicAggregateFormatUuid(); |
| 106 | 107 |
| 107 // The ErrorCallback is used by methods to asynchronously report errors. | 108 // The ErrorCallback is used by methods to asynchronously report errors. |
| 108 typedef base::Callback<void(BluetoothGattService::GattErrorCode)> | 109 typedef base::Callback<void(BluetoothGattService::GattErrorCode)> |
| (...skipping 17 matching lines...) Expand all Loading... |
| 126 // | 127 // |
| 127 // Currently, only custom UUIDs, |kCharacteristicDescriptionUuid|, and | 128 // Currently, only custom UUIDs, |kCharacteristicDescriptionUuid|, and |
| 128 // |kCharacteristicPresentationFormat| are supported for locally hosted | 129 // |kCharacteristicPresentationFormat| are supported for locally hosted |
| 129 // descriptors. This method will return NULL if |uuid| is any one of the | 130 // descriptors. This method will return NULL if |uuid| is any one of the |
| 130 // unsupported predefined descriptor UUIDs. | 131 // unsupported predefined descriptor UUIDs. |
| 131 static BluetoothGattDescriptor* Create( | 132 static BluetoothGattDescriptor* Create( |
| 132 const BluetoothUUID& uuid, | 133 const BluetoothUUID& uuid, |
| 133 const std::vector<uint8>& value, | 134 const std::vector<uint8>& value, |
| 134 BluetoothGattCharacteristic::Permissions permissions); | 135 BluetoothGattCharacteristic::Permissions permissions); |
| 135 | 136 |
| 136 // Identifier used to uniquely identify a GATT descriptorobject. This is | 137 // Identifier used to uniquely identify a GATT descriptor object. This is |
| 137 // different from the descriptor UUID: while multiple descriptors with the | 138 // different from the descriptor UUID: while multiple descriptors with the |
| 138 // same UUID can exist on a Bluetooth device, the identifier returned from | 139 // same UUID can exist on a Bluetooth device, the identifier returned from |
| 139 // this method is unique among all descriptors of a device. The contents of | 140 // this method is unique among all descriptors of a device. The contents of |
| 140 // the identifier are platform specific. | 141 // the identifier are platform specific. |
| 141 virtual std::string GetIdentifier() const = 0; | 142 virtual std::string GetIdentifier() const = 0; |
| 142 | 143 |
| 143 // The Bluetooth-specific UUID of the characteristic descriptor. | 144 // The Bluetooth-specific UUID of the characteristic descriptor. |
| 144 virtual BluetoothUUID GetUUID() const = 0; | 145 virtual BluetoothUUID GetUUID() const = 0; |
| 145 | 146 |
| 146 // Returns true, if this characteristic descriptor is hosted locally. If | 147 // Returns true, if this characteristic descriptor is hosted locally. If |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 BluetoothGattDescriptor(); | 181 BluetoothGattDescriptor(); |
| 181 virtual ~BluetoothGattDescriptor(); | 182 virtual ~BluetoothGattDescriptor(); |
| 182 | 183 |
| 183 private: | 184 private: |
| 184 DISALLOW_COPY_AND_ASSIGN(BluetoothGattDescriptor); | 185 DISALLOW_COPY_AND_ASSIGN(BluetoothGattDescriptor); |
| 185 }; | 186 }; |
| 186 | 187 |
| 187 } // namespace device | 188 } // namespace device |
| 188 | 189 |
| 189 #endif // DEVICE_BLUETOOTH_BLUETOOTH_GATT_DESCRIPTOR_H_ | 190 #endif // DEVICE_BLUETOOTH_BLUETOOTH_GATT_DESCRIPTOR_H_ |
| OLD | NEW |