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_LOW_ENERGY_DEFS_WIN_H_ | 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_LOW_ENERGY_DEFS_WIN_H_ |
6 #define DEVICE_BLUETOOTH_BLUETOOTH_LOW_ENERGY_DEFS_WIN_H_ | 6 #define DEVICE_BLUETOOTH_BLUETOOTH_LOW_ENERGY_DEFS_WIN_H_ |
7 | 7 |
8 #include <windows.h> | 8 #include <windows.h> |
9 #include <cfg.h> | 9 #include <cfg.h> |
10 #include <devpkey.h> | 10 #include <devpkey.h> |
11 #include <setupapi.h> | 11 #include <setupapi.h> |
12 // #include <bthledef.h> | |
13 // TODO(rpaquay): | |
14 // bthledef.h from Win8 SDK has a couple of issues when used in a Win32 app: | |
15 // * line 420: usage of "pragma pop" instead of "pragma warning(pop)" | |
16 // * line 349: no CALLBACK modifier in the definition of | |
17 // PFNBLUETOOTH_GATT_EVENT_CALLBACK. | |
18 // | |
19 // So, we duplicate the definitions we need and prevent the build from including | |
20 // the content of bthledef.h. | |
21 #ifndef __BTHLEDEF_H__ | |
22 #define __BTHLEDEF_H__ | |
23 | 12 |
24 // | 13 #pragma warning(push) |
25 // Bluetooth LE device interface GUID | 14 // bthledef.h is buggy and contains |
26 // | 15 // #pragma pop |
27 // {781aee18-7733-4ce4-adb0-91f41c67b592} | 16 // which should be |
28 DEFINE_GUID(GUID_BLUETOOTHLE_DEVICE_INTERFACE, | 17 // #pragma warning(pop) |
29 0x781aee18, | 18 // So, we disable the "unknown pragma" warning, then actually pop, and then pop |
30 0x7733, | 19 // our disabling of 4068. |
31 0x4ce4, | 20 #pragma warning(disable: 4068) |
32 0xad, | 21 #include <bthledef.h> |
33 0xd0, | 22 #pragma warning(pop) |
34 0x91, | 23 #pragma warning(pop) |
35 0xf4, | |
36 0x1c, | |
37 0x67, | |
38 0xb5, | |
39 0x92); | |
40 | 24 |
41 DEFINE_GUID(BTH_LE_ATT_BLUETOOTH_BASE_GUID, | |
42 0x00000000, | |
43 0x0000, | |
44 0x1000, | |
45 0x80, | |
46 0x00, | |
47 0x00, | |
48 0x80, | |
49 0x5F, | |
50 0x9B, | |
51 0x34, | |
52 0xFB); | |
53 | |
54 #define BLUETOOTH_GATT_FLAG_NONE 0x00000000 | |
55 | |
56 typedef struct _BTH_LE_UUID { | |
57 BOOLEAN IsShortUuid; | |
58 #ifdef MIDL_PASS | |
59 [ switch_type(BOOLEAN), switch_is((BOOLEAN)IsShortUuid) ] | |
60 #endif | |
61 union { | |
62 #ifdef MIDL_PASS | |
63 [case(TRUE)] | |
64 #endif | |
65 USHORT ShortUuid; | |
66 #ifdef MIDL_PASS | |
67 [case(FALSE)] | |
68 #endif | |
69 GUID LongUuid; | |
70 } Value; | |
71 } BTH_LE_UUID, *PBTH_LE_UUID; | |
72 | |
73 typedef struct _BTH_LE_GATT_SERVICE { | |
74 BTH_LE_UUID ServiceUuid; | |
75 USHORT AttributeHandle; | |
76 } BTH_LE_GATT_SERVICE, *PBTH_LE_GATT_SERVICE; | |
77 | |
78 typedef struct _BTH_LE_GATT_CHARACTERISTIC { | |
79 USHORT ServiceHandle; | |
80 BTH_LE_UUID CharacteristicUuid; | |
81 USHORT AttributeHandle; | |
82 USHORT CharacteristicValueHandle; | |
83 BOOLEAN IsBroadcastable; | |
84 BOOLEAN IsReadable; | |
85 BOOLEAN IsWritable; | |
86 BOOLEAN IsWritableWithoutResponse; | |
87 BOOLEAN IsSignedWritable; | |
88 BOOLEAN IsNotifiable; | |
89 BOOLEAN IsIndicatable; | |
90 BOOLEAN HasExtendedProperties; | |
91 } BTH_LE_GATT_CHARACTERISTIC, *PBTH_LE_GATT_CHARACTERISTIC; | |
92 | |
93 typedef struct _BTH_LE_GATT_CHARACTERISTIC_VALUE { | |
94 ULONG DataSize; | |
95 | |
96 #ifdef MIDL_PASS | |
97 [size_is(DataSize)] UCHAR Data[*]; | |
98 #else | |
99 _Field_size_bytes_(DataSize) UCHAR Data[1]; | |
100 #endif | |
101 } BTH_LE_GATT_CHARACTERISTIC_VALUE, *PBTH_LE_GATT_CHARACTERISTIC_VALUE; | |
102 | |
103 typedef enum _BTH_LE_GATT_DESCRIPTOR_TYPE { | |
104 CharacteristicExtendedProperties, | |
105 CharacteristicUserDescription, | |
106 ClientCharacteristicConfiguration, | |
107 ServerCharacteristicConfiguration, | |
108 CharacteristicFormat, | |
109 CharacteristicAggregateFormat, | |
110 CustomDescriptor | |
111 } BTH_LE_GATT_DESCRIPTOR_TYPE, | |
112 *PBTH_LE_GATT_DESCRIPTOR_TYPE; | |
113 | |
114 typedef struct _BTH_LE_GATT_DESCRIPTOR { | |
115 USHORT ServiceHandle; | |
116 USHORT CharacteristicHandle; | |
117 BTH_LE_GATT_DESCRIPTOR_TYPE DescriptorType; | |
118 BTH_LE_UUID DescriptorUuid; | |
119 USHORT AttributeHandle; | |
120 } BTH_LE_GATT_DESCRIPTOR, *PBTH_LE_GATT_DESCRIPTOR; | |
121 | |
122 typedef struct _BTH_LE_GATT_DESCRIPTOR_VALUE { | |
123 BTH_LE_GATT_DESCRIPTOR_TYPE DescriptorType; | |
124 BTH_LE_UUID DescriptorUuid; | |
125 | |
126 #ifdef MIDL_PASS | |
127 [ | |
128 switch_type(BTH_LE_GATT_DESCRIPTOR_TYPE), | |
129 switch_is((BTH_LE_GATT_DESCRIPTOR_TYPE)DescriptorType) | |
130 ] | |
131 #endif | |
132 union { | |
133 | |
134 #ifdef MIDL_PASS | |
135 [case(CharacteristicExtendedProperties)] | |
136 #endif | |
137 struct { | |
138 BOOLEAN IsReliableWriteEnabled; | |
139 BOOLEAN IsAuxiliariesWritable; | |
140 } CharacteristicExtendedProperties; | |
141 | |
142 #ifdef MIDL_PASS | |
143 [case(ClientCharacteristicConfiguration)] | |
144 #endif | |
145 struct { | |
146 BOOLEAN IsSubscribeToNotification; | |
147 BOOLEAN IsSubscribeToIndication; | |
148 } ClientCharacteristicConfiguration; | |
149 | |
150 #ifdef MIDL_PASS | |
151 [case(ServerCharacteristicConfiguration)] | |
152 #endif | |
153 struct { | |
154 BOOLEAN IsBroadcast; | |
155 } ServerCharacteristicConfiguration; | |
156 | |
157 #ifdef MIDL_PASS | |
158 [case(CharacteristicFormat)] | |
159 #endif | |
160 struct { | |
161 UCHAR Format; | |
162 UCHAR Exponent; | |
163 BTH_LE_UUID Unit; | |
164 UCHAR NameSpace; | |
165 BTH_LE_UUID Description; | |
166 } CharacteristicFormat; | |
167 #ifdef MIDL_PASS | |
168 [default]; | |
169 #endif | |
170 }; | |
171 | |
172 ULONG DataSize; | |
173 | |
174 #ifdef MIDL_PASS | |
175 [size_is(DataSize)] UCHAR Data[*]; | |
176 #else | |
177 _Field_size_bytes_(DataSize) UCHAR Data[1]; | |
178 #endif | |
179 } BTH_LE_GATT_DESCRIPTOR_VALUE, *PBTH_LE_GATT_DESCRIPTOR_VALUE; | |
180 | |
181 typedef enum _BTH_LE_GATT_EVENT_TYPE { | |
182 CharacteristicValueChangedEvent, | |
183 } BTH_LE_GATT_EVENT_TYPE; | |
184 | |
185 typedef ULONG64 BTH_LE_GATT_RELIABLE_WRITE_CONTEXT, | |
186 *PBTH_LE_GATT_RELIABLE_WRITE_CONTEXT; | |
187 | |
188 #endif // __BTHLEDEF_H__ | |
189 #include <bluetoothapis.h> | 25 #include <bluetoothapis.h> |
190 #include <bluetoothleapis.h> | 26 #include <bluetoothleapis.h> |
191 | 27 |
192 #endif // DEVICE_BLUETOOTH_BLUETOOTH_LOW_ENERGY_DEFS_WIN_H_ | 28 #endif // DEVICE_BLUETOOTH_BLUETOOTH_LOW_ENERGY_DEFS_WIN_H_ |
OLD | NEW |