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 #include "device/bluetooth/bluetooth_gatt_descriptor.h" | 5 #include "device/bluetooth/bluetooth_gatt_descriptor.h" |
6 | 6 |
| 7 #include <vector> |
| 8 |
| 9 #include "base/lazy_instance.h" |
7 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/macros.h" |
8 | 12 |
9 namespace device { | 13 namespace device { |
| 14 namespace { |
10 | 15 |
11 const BluetoothUUID BluetoothGattDescriptor:: | 16 struct UUIDs { |
12 kCharacteristicExtendedPropertiesUuid("2900"); | 17 UUIDs() : uuids_(MakeUUIDVector()) {} |
13 const BluetoothUUID BluetoothGattDescriptor:: | 18 |
14 kCharacteristicUserDescriptionUuid("2901"); | 19 const std::vector<BluetoothUUID> uuids_; |
15 const BluetoothUUID BluetoothGattDescriptor:: | 20 |
16 kClientCharacteristicConfigurationUuid("2902"); | 21 private: |
17 const BluetoothUUID BluetoothGattDescriptor:: | 22 static std::vector<BluetoothUUID> MakeUUIDVector() { |
18 kServerCharacteristicConfigurationUuid("2903"); | 23 std::vector<BluetoothUUID> uuids; |
19 const BluetoothUUID BluetoothGattDescriptor:: | 24 static const char* const strings[] = { |
20 kCharacteristicPresentationFormatUuid("2904"); | 25 "0x2900", "0x2901", "0x2902", "0x2903", "0x2904", "0x2905" |
21 const BluetoothUUID BluetoothGattDescriptor:: | 26 }; |
22 kCharacteristicAggregateFormatUuid("2905"); | 27 |
| 28 for (size_t i = 0; i < arraysize(strings); ++i) |
| 29 uuids.push_back(BluetoothUUID(strings[i])); |
| 30 |
| 31 return uuids; |
| 32 } |
| 33 }; |
| 34 |
| 35 base::LazyInstance<const UUIDs>::Leaky g_uuids = LAZY_INSTANCE_INITIALIZER; |
| 36 |
| 37 } // namespace |
| 38 |
| 39 // static |
| 40 const BluetoothUUID& |
| 41 BluetoothGattDescriptor::CharacteristicExtendedPropertiesUuid() { |
| 42 return g_uuids.Get().uuids_[0]; |
| 43 } |
| 44 |
| 45 // static |
| 46 const BluetoothUUID& |
| 47 BluetoothGattDescriptor::CharacteristicUserDescriptionUuid() { |
| 48 return g_uuids.Get().uuids_[1]; |
| 49 } |
| 50 |
| 51 // static |
| 52 const BluetoothUUID& |
| 53 BluetoothGattDescriptor::ClientCharacteristicConfigurationUuid() { |
| 54 return g_uuids.Get().uuids_[2]; |
| 55 } |
| 56 |
| 57 // static |
| 58 const BluetoothUUID& |
| 59 BluetoothGattDescriptor::ServerCharacteristicConfigurationUuid() { |
| 60 return g_uuids.Get().uuids_[3]; |
| 61 } |
| 62 |
| 63 // static |
| 64 const BluetoothUUID& |
| 65 BluetoothGattDescriptor::CharacteristicPresentationFormatUuid() { |
| 66 return g_uuids.Get().uuids_[4]; |
| 67 } |
| 68 |
| 69 // static |
| 70 const BluetoothUUID& |
| 71 BluetoothGattDescriptor::CharacteristicAggregateFormatUuid() { |
| 72 return g_uuids.Get().uuids_[5]; |
| 73 } |
23 | 74 |
24 BluetoothGattDescriptor::BluetoothGattDescriptor() { | 75 BluetoothGattDescriptor::BluetoothGattDescriptor() { |
25 } | 76 } |
26 | 77 |
27 BluetoothGattDescriptor::~BluetoothGattDescriptor() { | 78 BluetoothGattDescriptor::~BluetoothGattDescriptor() { |
28 } | 79 } |
29 | 80 |
30 // static | 81 // static |
31 BluetoothGattDescriptor* BluetoothGattDescriptor::Create( | 82 BluetoothGattDescriptor* BluetoothGattDescriptor::Create( |
32 const BluetoothUUID& uuid, | 83 const BluetoothUUID& uuid, |
33 const std::vector<uint8>& value, | 84 const std::vector<uint8>& value, |
34 BluetoothGattCharacteristic::Permissions permissions) { | 85 BluetoothGattCharacteristic::Permissions permissions) { |
35 LOG(ERROR) << "Creating local GATT characteristic descriptors currently not " | 86 LOG(ERROR) << "Creating local GATT characteristic descriptors currently not " |
36 << "supported."; | 87 << "supported."; |
37 return NULL; | 88 return NULL; |
38 } | 89 } |
39 | 90 |
40 } // namespace device | 91 } // namespace device |
OLD | NEW |