| 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" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 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 // |
| 38 static const BluetoothUUID kCharacteristicExtendedPropertiesUuid; | 38 static const BluetoothUUID& CharacteristicExtendedPropertiesUuid(); |
| 39 | 39 |
| 40 // The "Characteristic User Description" descriptor defines a UTF-8 string of | 40 // The "Characteristic User Description" descriptor defines a UTF-8 string of |
| 41 // variable size that is a user textual description of the associated | 41 // variable size that is a user textual description of the associated |
| 42 // characteristic's value. There can be only one instance of this descriptor | 42 // characteristic's value. There can be only one instance of this descriptor |
| 43 // per characteristic. This descriptor can be written to if the "Writable | 43 // per characteristic. This descriptor can be written to if the "Writable |
| 44 // Auxiliaries" bit of the Characteristic Properties (via the "Characteristic | 44 // Auxiliaries" bit of the Characteristic Properties (via the "Characteristic |
| 45 // Extended Properties" descriptor) has been set. | 45 // Extended Properties" descriptor) has been set. |
| 46 static const BluetoothUUID kCharacteristicUserDescriptionUuid; | 46 static const BluetoothUUID& CharacteristicUserDescriptionUuid(); |
| 47 | 47 |
| 48 // The "Client Characteristic Configuration" descriptor defines how the | 48 // The "Client Characteristic Configuration" descriptor defines how the |
| 49 // characteristic may be configured by a specific client. A server-side | 49 // characteristic may be configured by a specific client. A server-side |
| 50 // instance of this descriptor exists for each client that has bonded with | 50 // instance of this descriptor exists for each client that has bonded with |
| 51 // the server and the value can be read and written by that client only. As | 51 // the server and the value can be read and written by that client only. As |
| 52 // of Core v4.0, this descriptor is used by clients to set up notifications | 52 // of Core v4.0, this descriptor is used by clients to set up notifications |
| 53 // and indications from a characteristic. The value is a bit field and the | 53 // and indications from a characteristic. The value is a bit field and the |
| 54 // predefined bits are: | 54 // predefined bits are: |
| 55 // | 55 // |
| 56 // - Default: 0x0000 | 56 // - Default: 0x0000 |
| 57 // - Notification: 0x0001 | 57 // - Notification: 0x0001 |
| 58 // - Indication: 0x0002 | 58 // - Indication: 0x0002 |
| 59 // | 59 // |
| 60 static const BluetoothUUID kClientCharacteristicConfigurationUuid; | 60 static const BluetoothUUID& ClientCharacteristicConfigurationUuid(); |
| 61 | 61 |
| 62 // The "Server Characteristic Configuration" descriptor defines how the | 62 // The "Server Characteristic Configuration" descriptor defines how the |
| 63 // characteristic may be configured for the server. There is one instance | 63 // characteristic may be configured for the server. There is one instance |
| 64 // of this descriptor for all clients and setting the value of this descriptor | 64 // of this descriptor for all clients and setting the value of this descriptor |
| 65 // affects its configuration for all clients. As of Core v4.0, this descriptor | 65 // affects its configuration for all clients. As of Core v4.0, this descriptor |
| 66 // is used to set up the server to broadcast the characteristic value if | 66 // is used to set up the server to broadcast the characteristic value if |
| 67 // advertising resources are available. The value is a bit field and the | 67 // advertising resources are available. The value is a bit field and the |
| 68 // predefined bits are: | 68 // predefined bits are: |
| 69 // | 69 // |
| 70 // - Default: 0x0000 | 70 // - Default: 0x0000 |
| 71 // - Broadcast: 0x0001 | 71 // - Broadcast: 0x0001 |
| 72 // | 72 // |
| 73 static const BluetoothUUID kServerCharacteristicConfigurationUuid; | 73 static const BluetoothUUID& ServerCharacteristicConfigurationUuid(); |
| 74 | 74 |
| 75 // The "Characteristic Presentation Format" declaration defines the format of | 75 // The "Characteristic Presentation Format" declaration defines the format of |
| 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 kCharacteristicPresentationFormatUuid; | 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 // aggragated 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" desciptors belong to a characteristic. |
| 99 // The API will construct a BluetoothGattDescriptor object for each instance | 99 // The API will construct a BluetoothGattDescriptor object for each instance |
| 100 // of "Characteristic Presentation Format" descriptor per instance of | 100 // of "Characteristic Presentation Format" descriptor per instance of |
| 101 // BluetoothGattCharacteristic that represents a remote characteristic. | 101 // BluetoothGattCharacteristic that represents a remote characteristic. |
| 102 // Similarly for local characteristics, implementations DO NOT need to create | 102 // Similarly for local characteristics, implementations DO NOT need to create |
| 103 // an instance of BluetoothGattDescriptor for this descriptor as this will be | 103 // an instance of BluetoothGattDescriptor for this descriptor as this will be |
| 104 // handled by the subsystem. | 104 // handled by the subsystem. |
| 105 static const BluetoothUUID kCharacteristicAggregateFormatUuid; | 105 static const BluetoothUUID& CharacteristicAggregateFormatUuid(); |
| 106 | 106 |
| 107 // The ErrorCallback is used by methods to asynchronously report errors. | 107 // The ErrorCallback is used by methods to asynchronously report errors. |
| 108 typedef base::Closure ErrorCallback; | 108 typedef base::Closure ErrorCallback; |
| 109 | 109 |
| 110 // The ValueCallback is used to return the value of a remote characteristic | 110 // The ValueCallback is used to return the value of a remote characteristic |
| 111 // descriptor upon a read request. | 111 // descriptor upon a read request. |
| 112 typedef base::Callback<void(const std::vector<uint8>&)> ValueCallback; | 112 typedef base::Callback<void(const std::vector<uint8>&)> ValueCallback; |
| 113 | 113 |
| 114 // Constructs a BluetoothGattDescriptor that can be associated with a local | 114 // Constructs a BluetoothGattDescriptor that can be associated with a local |
| 115 // GATT characteristic when the adapter is in the peripheral role. To | 115 // GATT characteristic when the adapter is in the peripheral role. To |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 BluetoothGattDescriptor(); | 179 BluetoothGattDescriptor(); |
| 180 virtual ~BluetoothGattDescriptor(); | 180 virtual ~BluetoothGattDescriptor(); |
| 181 | 181 |
| 182 private: | 182 private: |
| 183 DISALLOW_COPY_AND_ASSIGN(BluetoothGattDescriptor); | 183 DISALLOW_COPY_AND_ASSIGN(BluetoothGattDescriptor); |
| 184 }; | 184 }; |
| 185 | 185 |
| 186 } // namespace device | 186 } // namespace device |
| 187 | 187 |
| 188 #endif // DEVICE_BLUETOOTH_BLUETOOTH_GATT_DESCRIPTOR_H_ | 188 #endif // DEVICE_BLUETOOTH_BLUETOOTH_GATT_DESCRIPTOR_H_ |
| OLD | NEW |