aboutsummaryrefslogtreecommitdiff
path: root/x86_64-w64-mingw32/include/bluetoothapis.h
blob: b6a1185d3fdacad39710be87d0464172b2c435da (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
/**
 * This file has no copyright assigned and is placed in the Public Domain.
 * This file is part of the mingw-w64 runtime package.
 * No warranty is given; refer to the file DISCLAIMER.PD within this package.
 */
#ifndef _INC_BLUETOOTHAPIS
#define _INC_BLUETOOTHAPIS

#include <_mingw.h>
#include <bthdef.h>
#include <bthsdpdef.h>

#define BLUETOOTH_MAX_NAME_SIZE 248

#ifdef __cplusplus
extern "C" {
#endif

typedef LPVOID HBLUETOOTH_DEVICE_FIND;
typedef LPVOID HBLUETOOTH_RADIO_FIND;
typedef LPVOID HBLUETOOTH_AUTHENTICATION_REGISTRATION;
typedef LPVOID HBLUETOOTH_CONTAINER_ELEMENT;

typedef struct _BLUETOOTH_ADDRESS {
  __C89_NAMELESS union {
    BTH_ADDR ullLong;
    BYTE     rgBytes[6];
  };
} BLUETOOTH_ADDRESS;

typedef struct _BLUETOOTH_COD_PAIRS {
  ULONG   ulCODMask;
  LPCWSTR pcszDescription;
} BLUETOOTH_COD_PAIRS;

typedef struct _BLUETOOTH_DEVICE_INFO {
  DWORD             dwSize;
  BLUETOOTH_ADDRESS Address;
  ULONG             ulClassofDevice;
  WINBOOL           fConnected;
  WINBOOL           fRemembered;
  WINBOOL           fAuthenticated;
  SYSTEMTIME        stLastSeen;
  SYSTEMTIME        stLastUsed;
  WCHAR             szName[BLUETOOTH_MAX_NAME_SIZE];
} BLUETOOTH_DEVICE_INFO, *PBLUETOOTH_DEVICE_INFO;

typedef struct _BLUETOOTH_DEVICE_SEARCH_PARAMS {
  DWORD     dwSize;
  WINBOOL   fReturnAuthenticated;
  WINBOOL   fReturnRemembered;
  WINBOOL   fReturnUnknown;
  WINBOOL   fReturnConnected;
  WINBOOL   fIssueInquiry;
  UCHAR     cTimeoutMultiplier;
  HANDLE    hRadio;
} BLUETOOTH_DEVICE_SEARCH_PARAMS;

typedef struct _BLUETOOTH_FIND_RADIO_PARAMS {
  DWORD dwSize;
} BLUETOOTH_FIND_RADIO_PARAMS;

typedef struct _BLUETOOTH_RADIO_INFO {
  DWORD             dwSize;
  BLUETOOTH_ADDRESS address;
  WCHAR             szName[BLUETOOTH_MAX_NAME_SIZE];
  ULONG             ulClassofDevice;
  USHORT            lmpSubversion;
  USHORT            manufacturer;
} BLUETOOTH_RADIO_INFO, *PBLUETOOTH_RADIO_INFO;

typedef enum _BLUETOOTH_AUTHENTICATION_METHOD {
  BLUETOOTH_AUTHENTICATION_METHOD_LEGACY                 = 0x1,
  BLUETOOTH_AUTHENTICATION_METHOD_OOB,
  BLUETOOTH_AUTHENTICATION_METHOD_NUMERIC_COMPARISON,
  BLUETOOTH_AUTHENTICATION_METHOD_PASSKEY_NOTIFICATION,
  BLUETOOTH_AUTHENTICATION_METHOD_PASSKEY
} BLUETOOTH_AUTHENTICATION_METHOD;

typedef enum _BLUETOOTH_IO_CAPABILITY {
  BLUETOOTH_IO_CAPABILITY_DISPLAYONLY       = 0x00,
  BLUETOOTH_IO_CAPABILITY_DISPLAYYESNO      = 0x01,
  BLUETOOTH_IO_CAPABILITY_KEYBOARDONLY      = 0x02,
  BLUETOOTH_IO_CAPABILITY_NOINPUTNOOUTPUT   = 0x03,
  BLUETOOTH_IO_CAPABILITY_UNDEFINED         = 0xff
} BLUETOOTH_IO_CAPABILITY;

typedef enum _BLUETOOTH_AUTHENTICATION_REQUIREMENTS {
  MITMProtectionNotRequired                 = 0x00,
  MITMProtectionRequired                    = 0x01,
  MITMProtectionNotRequiredBonding          = 0x02,
  MITMProtectionRequiredBonding             = 0x03,
  MITMProtectionNotRequiredGeneralBonding   = 0x04,
  MITMProtectionRequiredGeneralBonding      = 0x05,
  MITMProtectionNotDefined                  = 0xff
} BLUETOOTH_AUTHENTICATION_REQUIREMENTS;

typedef struct _BLUETOOTH_AUTHENTICATION_CALLBACK_PARAMS {
  BLUETOOTH_DEVICE_INFO                 deviceInfo;
  BLUETOOTH_AUTHENTICATION_METHOD       authenticationMethod;
  BLUETOOTH_IO_CAPABILITY               ioCapability;
  BLUETOOTH_AUTHENTICATION_REQUIREMENTS authenticationRequirements;
  __C89_NAMELESS union {
    ULONG Numeric_Value;
    ULONG Passkey;
  } ;
} BLUETOOTH_AUTHENTICATION_CALLBACK_PARAMS, *PBLUETOOTH_AUTHENTICATION_CALLBACK_PARAMS;

#define BLUETOOTH_MAX_SERVICE_NAME_SIZE 256
#define BLUETOOTH_DEVICE_NAME_SIZE 256
typedef struct _BLUETOOTH_LOCAL_SERVICE_INFO {
  BOOL              Enabled;
  BLUETOOTH_ADDRESS btAddr;
  WCHAR             szName[BLUETOOTH_MAX_SERVICE_NAME_SIZE];
  WCHAR             szDeviceString[BLUETOOTH_DEVICE_NAME_SIZE];
} BLUETOOTH_LOCAL_SERVICE_INFO;

#define BTH_MAX_PIN_SIZE 16
typedef struct _BLUETOOTH_PIN_INFO {
  UCHAR pin[BTH_MAX_PIN_SIZE];
  UCHAR pinLength;
} BLUETOOTH_PIN_INFO, *PBLUETOOTH_PIN_INFO;

typedef struct _BLUETOOTH_OOB_DATA_INFO {
  UCHAR C[16];
  UCHAR R[16];
} BLUETOOTH_OOB_DATA_INFO, *PBLUETOOTH_OOB_DATA_INFO;

typedef struct _BLUETOOTH_NUMERIC_COMPARISON_INFO {
  ULONG NumericValue;
} BLUETOOTH_NUMERIC_COMPARISON_INFO, *PBLUETOOTH_NUMERIC_COMPARISON_INFO;

typedef struct _BLUETOOTH_PASSKEY_INFO {
  ULONG passkey;
} BLUETOOTH_PASSKEY_INFO, *PBLUETOOTH_PASSKEY_INFO;

typedef struct _BLUETOOTH_AUTHENTICATE_RESPONSE {
  BLUETOOTH_ADDRESS               bthAddressRemote;
  BLUETOOTH_AUTHENTICATION_METHOD authMethod;
  __C89_NAMELESS union {
    BLUETOOTH_PIN_INFO                pinInfo;
    BLUETOOTH_OOB_DATA_INFO           oobInfo;
    BLUETOOTH_NUMERIC_COMPARISON_INFO numericCompInfo;
    BLUETOOTH_PASSKEY_INFO            passkeyInfo;
  };
  UCHAR                           negativeResponse;
} BLUETOOTH_AUTHENTICATE_RESPONSE, *PBLUETOOTH_AUTHENTICATE_RESPONSE;

typedef WINBOOL (*PFN_DEVICE_CALLBACK)(LPVOID pvParam,PBLUETOOTH_DEVICE_INFO pDevice);
typedef WINBOOL (*CALLBACK PFN_AUTHENTICATION_CALLBACK_EX)(LPVOID pvParam,PBLUETOOTH_AUTHENTICATION_CALLBACK_PARAMS pAuthCallbackParams);
typedef WINBOOL (*PFN_AUTHENTICATION_CALLBACK)(LPVOID pvParam,PBLUETOOTH_DEVICE_INFO pDevice);
typedef WINBOOL (*PFN_BLUETOOTH_ENUM_ATTRIBUTES_CALLBACK)(ULONG uAttribId,LPBYTE pValueStream,ULONG cbStreamSize,LPVOID pvParam);

typedef struct _BLUETOOTH_SELECT_DEVICE_PARAMS {
  DWORD                  dwSize;
  ULONG                  cNumOfClasses;
  BLUETOOTH_COD_PAIRS    *prgClassOfDevices;
  LPWSTR                 pszInfo;
  HWND                   hwndParent;
  BOOL                   fForceAuthentication;
  BOOL                   fShowAuthenticated;
  BOOL                   fShowRemembered;
  BOOL                   fShowUnknown;
  BOOL                   fAddNewDeviceWizard;
  BOOL                   fSkipServicesPage;
  PFN_DEVICE_CALLBACK    pfnDeviceCallback;
  LPVOID                 pvParam;
  DWORD                  cNumDevices;
  PBLUETOOTH_DEVICE_INFO pDevices;
} BLUETOOTH_SELECT_DEVICE_PARAMS;

DWORD WINAPI BluetoothAuthenticateMultipleDevices(
    HWND hwndParent,
    HANDLE hRadio,
    DWORD cDevices,
    BLUETOOTH_DEVICE_INFO *pbtdi
);

HRESULT WINAPI BluetoothAuthenticateDeviceEx(
  HWND hwndParentIn,
  HANDLE hRadioIn,
  BLUETOOTH_DEVICE_INFO *pbtdiInout,
  PBLUETOOTH_OOB_DATA_INFO pbtOobData,
  BLUETOOTH_AUTHENTICATION_REQUIREMENTS authenticationRequirement
);

WINBOOL WINAPI BluetoothDisplayDeviceProperties(
    HWND hwndParent,
    BLUETOOTH_DEVICE_INFO *pbtdi
);

WINBOOL WINAPI BluetoothEnableDiscovery(
    HANDLE hRadio,
    WINBOOL fEnabled
);

WINBOOL WINAPI BluetoothEnableIncomingConnections(
    HANDLE hRadio,
    WINBOOL fEnabled
);

DWORD WINAPI BluetoothEnumerateInstalledServices(
    HANDLE hRadio,
    BLUETOOTH_DEVICE_INFO *pbtdi,
    DWORD *pcServices,
    GUID *pGuidServices
);

WINBOOL WINAPI BluetoothFindDeviceClose(
    HBLUETOOTH_DEVICE_FIND hFind
);

HBLUETOOTH_DEVICE_FIND WINAPI BluetoothFindFirstDevice(
    BLUETOOTH_DEVICE_SEARCH_PARAMS *pbtsp,
    BLUETOOTH_DEVICE_INFO *pbtdi
);

HBLUETOOTH_RADIO_FIND WINAPI BluetoothFindFirstRadio(
  BLUETOOTH_FIND_RADIO_PARAMS *pbtfrp,
  HANDLE *phRadio
);

WINBOOL WINAPI BluetoothFindNextDevice(
    HBLUETOOTH_DEVICE_FIND hFind,
    BLUETOOTH_DEVICE_INFO *pbtdi
);

WINBOOL WINAPI BluetoothFindNextRadio(
  HBLUETOOTH_RADIO_FIND hFind,
  HANDLE *phRadio
);

WINBOOL WINAPI BluetoothFindRadioClose(
    HBLUETOOTH_RADIO_FIND hFind
);

DWORD WINAPI BluetoothGetDeviceInfo(
    HANDLE hRadio,
    BLUETOOTH_DEVICE_INFO *pbtdi
);

DWORD WINAPI BluetoothGetRadioInfo(
    HANDLE hRadio,
    PBLUETOOTH_RADIO_INFO pRadioInfo
);

WINBOOL WINAPI BluetoothIsDiscoverable(
    HANDLE hRadio
);

WINBOOL WINAPI BluetoothIsConnectable(
    HANDLE hRadio
);

DWORD WINAPI BluetoothRegisterForAuthentication(
    BLUETOOTH_DEVICE_INFO *pbtdi,
    HBLUETOOTH_AUTHENTICATION_REGISTRATION *phRegHandle,
    PFN_AUTHENTICATION_CALLBACK pfnCallback,
    PVOID pvParam
);

HRESULT WINAPI BluetoothRegisterForAuthenticationEx(
  const BLUETOOTH_DEVICE_INFO *pbtdiln,
  HBLUETOOTH_AUTHENTICATION_REGISTRATION *phRegHandleOut,
  PFN_AUTHENTICATION_CALLBACK_EX pfnCallbackIn,
  PVOID pvParam
);

DWORD WINAPI BluetoothRemoveDevice(
    BLUETOOTH_ADDRESS *pAddress
);

WINBOOL WINAPI BluetoothSdpEnumAttributes(
    LPBYTE pSDPStream,
    ULONG cbStreamSize,
    PFN_BLUETOOTH_ENUM_ATTRIBUTES_CALLBACK pfnCallback,
    LPVOID pvParam
);

DWORD WINAPI BluetoothSdpGetAttributeValue(
  LPBYTE pRecordStream,
  ULONG cbRecordLength,
  USHORT usAttributeId,
  PSDP_ELEMENT_DATA pAttributeData
);

DWORD WINAPI BluetoothSdpGetContainerElementData(
  LPBYTE pContainerStream,
  ULONG cbContainerLength,
  HBLUETOOTH_CONTAINER_ELEMENT *pElement,
  PSDP_ELEMENT_DATA pData
);

DWORD BluetoothSdpGetElementData(
  LPBYTE pSdpStream,
  ULONG cbSpdStreamLength,
  PSDP_ELEMENT_DATA pData
);

DWORD BluetoothSdpGetString(
  LPBYTE pRecordStream,
  ULONG cbRecordLength,
  PSDP_STRING_TYPE_DATA pStringData,
  USHORT usStringOffset,
  PWCHAR pszString,
  PULONG pcchStringLength
);

WINBOOL WINAPI BluetoothSelectDevices(
    BLUETOOTH_SELECT_DEVICE_PARAMS *pbtsdp
);

WINBOOL WINAPI BluetoothSelectDevicesFree(
    BLUETOOTH_SELECT_DEVICE_PARAMS *pbtsdp
);

DWORD WINAPI BluetoothSendAuthenticationResponse(
    HANDLE hRadio,
    BLUETOOTH_DEVICE_INFO *pbtdi,
    LPWSTR pszPasskey
);

HRESULT WINAPI BluetoothSendAuthenticationResponseEx(
  HANDLE hRadioIn,
  PBLUETOOTH_AUTHENTICATE_RESPONSE pauthResponse
);

DWORD WINAPI BluetoothSetLocalServiceInfo(
  HANDLE hRadioIn,
  const GUID *pClassGuid,
  ULONG ulInstance,
  const BLUETOOTH_LOCAL_SERVICE_INFO *pServiceInfoIn
);

DWORD WINAPI BluetoothSetServiceState(
    HANDLE hRadio,
    BLUETOOTH_DEVICE_INFO *pbtdi,
    GUID *pGuidService,
    DWORD dwServiceFlags
);

WINBOOL WINAPI BluetoothUnregisterAuthentication(
    HBLUETOOTH_AUTHENTICATION_REGISTRATION hRegHandle
);

DWORD WINAPI BluetoothUpdateDeviceRecord(
    BLUETOOTH_DEVICE_INFO *pbtdi
);

#ifdef __cplusplus
}
#endif

#endif /*_INC_BLUETOOTHAPIS*/