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