blob: 95a8f49e07fe8f87e67928701d6e3600434f64b6 [file] [log] [blame]
[email protected]a7641492014-02-13 01:35:221// 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
avi176e2692015-12-22 19:26:527#include <stddef.h>
8
[email protected]f3913062014-04-30 17:21:469#include <vector>
10
11#include "base/lazy_instance.h"
[email protected]a7641492014-02-13 01:35:2212#include "base/logging.h"
[email protected]f3913062014-04-30 17:21:4613#include "base/macros.h"
[email protected]a7641492014-02-13 01:35:2214
15namespace device {
[email protected]f3913062014-04-30 17:21:4616namespace {
[email protected]a7641492014-02-13 01:35:2217
[email protected]f3913062014-04-30 17:21:4618struct 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
37base::LazyInstance<const UUIDs>::Leaky g_uuids = LAZY_INSTANCE_INITIALIZER;
38
39} // namespace
40
41// static
42const BluetoothUUID&
43BluetoothGattDescriptor::CharacteristicExtendedPropertiesUuid() {
44 return g_uuids.Get().uuids_[0];
45}
46
47// static
48const BluetoothUUID&
49BluetoothGattDescriptor::CharacteristicUserDescriptionUuid() {
50 return g_uuids.Get().uuids_[1];
51}
52
53// static
54const BluetoothUUID&
55BluetoothGattDescriptor::ClientCharacteristicConfigurationUuid() {
56 return g_uuids.Get().uuids_[2];
57}
58
59// static
60const BluetoothUUID&
61BluetoothGattDescriptor::ServerCharacteristicConfigurationUuid() {
62 return g_uuids.Get().uuids_[3];
63}
64
65// static
66const BluetoothUUID&
67BluetoothGattDescriptor::CharacteristicPresentationFormatUuid() {
68 return g_uuids.Get().uuids_[4];
69}
70
71// static
72const BluetoothUUID&
73BluetoothGattDescriptor::CharacteristicAggregateFormatUuid() {
74 return g_uuids.Get().uuids_[5];
75}
[email protected]a7641492014-02-13 01:35:2276
77BluetoothGattDescriptor::BluetoothGattDescriptor() {
78}
79
80BluetoothGattDescriptor::~BluetoothGattDescriptor() {
81}
82
83// static
84BluetoothGattDescriptor* BluetoothGattDescriptor::Create(
[email protected]8148ad42014-04-04 04:10:3885 const BluetoothUUID& uuid,
avi176e2692015-12-22 19:26:5286 const std::vector<uint8_t>& value,
[email protected]2a46ef52014-04-11 08:20:1287 BluetoothGattCharacteristic::Permissions permissions) {
[email protected]a7641492014-02-13 01:35:2288 LOG(ERROR) << "Creating local GATT characteristic descriptors currently not "
89 << "supported.";
90 return NULL;
91}
92
93} // namespace device