1 /** 2 * This file has no copyright assigned and is placed in the Public Domain. 3 * This file is part of the mingw-w64 runtime package. 4 * No warranty is given; refer to the file DISCLAIMER.PD within this package. 5 */ 6 #ifndef _INC_BLUETOOTHAPIS 7 #define _INC_BLUETOOTHAPIS 8 9 #include <_mingw.h> 10 #include <bthdef.h> 11 #include <bthsdpdef.h> 12 13 #define BLUETOOTH_MAX_NAME_SIZE 248 14 15 #ifdef __cplusplus 16 extern "C" { 17 #endif 18 19 typedef LPVOID HBLUETOOTH_DEVICE_FIND; 20 typedef LPVOID HBLUETOOTH_RADIO_FIND; 21 typedef LPVOID HBLUETOOTH_AUTHENTICATION_REGISTRATION; 22 typedef LPVOID HBLUETOOTH_CONTAINER_ELEMENT; 23 24 typedef struct _BLUETOOTH_ADDRESS { 25 __C89_NAMELESS union { 26 BTH_ADDR ullLong; 27 BYTE rgBytes[6]; 28 }; 29 } BLUETOOTH_ADDRESS; 30 31 typedef struct _BLUETOOTH_COD_PAIRS { 32 ULONG ulCODMask; 33 LPCWSTR pcszDescription; 34 } BLUETOOTH_COD_PAIRS; 35 36 typedef struct _BLUETOOTH_DEVICE_INFO { 37 DWORD dwSize; 38 BLUETOOTH_ADDRESS Address; 39 ULONG ulClassofDevice; 40 WINBOOL fConnected; 41 WINBOOL fRemembered; 42 WINBOOL fAuthenticated; 43 SYSTEMTIME stLastSeen; 44 SYSTEMTIME stLastUsed; 45 WCHAR szName[BLUETOOTH_MAX_NAME_SIZE]; 46 } BLUETOOTH_DEVICE_INFO, *PBLUETOOTH_DEVICE_INFO; 47 48 typedef struct _BLUETOOTH_DEVICE_SEARCH_PARAMS { 49 DWORD dwSize; 50 WINBOOL fReturnAuthenticated; 51 WINBOOL fReturnRemembered; 52 WINBOOL fReturnUnknown; 53 WINBOOL fReturnConnected; 54 WINBOOL fIssueInquiry; 55 UCHAR cTimeoutMultiplier; 56 HANDLE hRadio; 57 } BLUETOOTH_DEVICE_SEARCH_PARAMS; 58 59 typedef struct _BLUETOOTH_FIND_RADIO_PARAMS { 60 DWORD dwSize; 61 } BLUETOOTH_FIND_RADIO_PARAMS; 62 63 typedef struct _BLUETOOTH_RADIO_INFO { 64 DWORD dwSize; 65 BLUETOOTH_ADDRESS address; 66 WCHAR szName[BLUETOOTH_MAX_NAME_SIZE]; 67 ULONG ulClassofDevice; 68 USHORT lmpSubversion; 69 USHORT manufacturer; 70 } BLUETOOTH_RADIO_INFO, *PBLUETOOTH_RADIO_INFO; 71 72 typedef enum _BLUETOOTH_AUTHENTICATION_METHOD { 73 BLUETOOTH_AUTHENTICATION_METHOD_LEGACY = 0x1, 74 BLUETOOTH_AUTHENTICATION_METHOD_OOB, 75 BLUETOOTH_AUTHENTICATION_METHOD_NUMERIC_COMPARISON, 76 BLUETOOTH_AUTHENTICATION_METHOD_PASSKEY_NOTIFICATION, 77 BLUETOOTH_AUTHENTICATION_METHOD_PASSKEY 78 } BLUETOOTH_AUTHENTICATION_METHOD; 79 80 typedef enum _BLUETOOTH_IO_CAPABILITY { 81 BLUETOOTH_IO_CAPABILITY_DISPLAYONLY = 0x00, 82 BLUETOOTH_IO_CAPABILITY_DISPLAYYESNO = 0x01, 83 BLUETOOTH_IO_CAPABILITY_KEYBOARDONLY = 0x02, 84 BLUETOOTH_IO_CAPABILITY_NOINPUTNOOUTPUT = 0x03, 85 BLUETOOTH_IO_CAPABILITY_UNDEFINED = 0xff 86 } BLUETOOTH_IO_CAPABILITY; 87 88 typedef enum _BLUETOOTH_AUTHENTICATION_REQUIREMENTS { 89 MITMProtectionNotRequired = 0x00, 90 MITMProtectionRequired = 0x01, 91 MITMProtectionNotRequiredBonding = 0x02, 92 MITMProtectionRequiredBonding = 0x03, 93 MITMProtectionNotRequiredGeneralBonding = 0x04, 94 MITMProtectionRequiredGeneralBonding = 0x05, 95 MITMProtectionNotDefined = 0xff 96 } BLUETOOTH_AUTHENTICATION_REQUIREMENTS; 97 98 typedef struct _BLUETOOTH_AUTHENTICATION_CALLBACK_PARAMS { 99 BLUETOOTH_DEVICE_INFO deviceInfo; 100 BLUETOOTH_AUTHENTICATION_METHOD authenticationMethod; 101 BLUETOOTH_IO_CAPABILITY ioCapability; 102 BLUETOOTH_AUTHENTICATION_REQUIREMENTS authenticationRequirements; 103 __C89_NAMELESS union { 104 ULONG Numeric_Value; 105 ULONG Passkey; 106 } ; 107 } BLUETOOTH_AUTHENTICATION_CALLBACK_PARAMS, *PBLUETOOTH_AUTHENTICATION_CALLBACK_PARAMS; 108 109 #define BLUETOOTH_MAX_SERVICE_NAME_SIZE 256 110 #define BLUETOOTH_DEVICE_NAME_SIZE 256 111 typedef struct _BLUETOOTH_LOCAL_SERVICE_INFO { 112 BOOL Enabled; 113 BLUETOOTH_ADDRESS btAddr; 114 WCHAR szName[BLUETOOTH_MAX_SERVICE_NAME_SIZE]; 115 WCHAR szDeviceString[BLUETOOTH_DEVICE_NAME_SIZE]; 116 } BLUETOOTH_LOCAL_SERVICE_INFO; 117 118 #define BTH_MAX_PIN_SIZE 16 119 typedef struct _BLUETOOTH_PIN_INFO { 120 UCHAR pin[BTH_MAX_PIN_SIZE]; 121 UCHAR pinLength; 122 } BLUETOOTH_PIN_INFO, *PBLUETOOTH_PIN_INFO; 123 124 typedef struct _BLUETOOTH_OOB_DATA_INFO { 125 UCHAR C[16]; 126 UCHAR R[16]; 127 } BLUETOOTH_OOB_DATA_INFO, *PBLUETOOTH_OOB_DATA_INFO; 128 129 typedef struct _BLUETOOTH_NUMERIC_COMPARISON_INFO { 130 ULONG NumericValue; 131 } BLUETOOTH_NUMERIC_COMPARISON_INFO, *PBLUETOOTH_NUMERIC_COMPARISON_INFO; 132 133 typedef struct _BLUETOOTH_PASSKEY_INFO { 134 ULONG passkey; 135 } BLUETOOTH_PASSKEY_INFO, *PBLUETOOTH_PASSKEY_INFO; 136 137 typedef struct _BLUETOOTH_AUTHENTICATE_RESPONSE { 138 BLUETOOTH_ADDRESS bthAddressRemote; 139 BLUETOOTH_AUTHENTICATION_METHOD authMethod; 140 __C89_NAMELESS union { 141 BLUETOOTH_PIN_INFO pinInfo; 142 BLUETOOTH_OOB_DATA_INFO oobInfo; 143 BLUETOOTH_NUMERIC_COMPARISON_INFO numericCompInfo; 144 BLUETOOTH_PASSKEY_INFO passkeyInfo; 145 }; 146 UCHAR negativeResponse; 147 } BLUETOOTH_AUTHENTICATE_RESPONSE, *PBLUETOOTH_AUTHENTICATE_RESPONSE; 148 149 typedef WINBOOL (*PFN_DEVICE_CALLBACK)(LPVOID pvParam,PBLUETOOTH_DEVICE_INFO pDevice); 150 typedef WINBOOL (*CALLBACK PFN_AUTHENTICATION_CALLBACK_EX)(LPVOID pvParam,PBLUETOOTH_AUTHENTICATION_CALLBACK_PARAMS pAuthCallbackParams); 151 typedef WINBOOL (*PFN_AUTHENTICATION_CALLBACK)(LPVOID pvParam,PBLUETOOTH_DEVICE_INFO pDevice); 152 typedef WINBOOL (*PFN_BLUETOOTH_ENUM_ATTRIBUTES_CALLBACK)(ULONG uAttribId,LPBYTE pValueStream,ULONG cbStreamSize,LPVOID pvParam); 153 154 typedef struct _BLUETOOTH_SELECT_DEVICE_PARAMS { 155 DWORD dwSize; 156 ULONG cNumOfClasses; 157 BLUETOOTH_COD_PAIRS *prgClassOfDevices; 158 LPWSTR pszInfo; 159 HWND hwndParent; 160 BOOL fForceAuthentication; 161 BOOL fShowAuthenticated; 162 BOOL fShowRemembered; 163 BOOL fShowUnknown; 164 BOOL fAddNewDeviceWizard; 165 BOOL fSkipServicesPage; 166 PFN_DEVICE_CALLBACK pfnDeviceCallback; 167 LPVOID pvParam; 168 DWORD cNumDevices; 169 PBLUETOOTH_DEVICE_INFO pDevices; 170 } BLUETOOTH_SELECT_DEVICE_PARAMS; 171 172 DWORD WINAPI BluetoothAuthenticateMultipleDevices( 173 HWND hwndParent, 174 HANDLE hRadio, 175 DWORD cDevices, 176 BLUETOOTH_DEVICE_INFO *pbtdi 177 ); 178 179 HRESULT WINAPI BluetoothAuthenticateDeviceEx( 180 HWND hwndParentIn, 181 HANDLE hRadioIn, 182 BLUETOOTH_DEVICE_INFO *pbtdiInout, 183 PBLUETOOTH_OOB_DATA_INFO pbtOobData, 184 BLUETOOTH_AUTHENTICATION_REQUIREMENTS authenticationRequirement 185 ); 186 187 WINBOOL WINAPI BluetoothDisplayDeviceProperties( 188 HWND hwndParent, 189 BLUETOOTH_DEVICE_INFO *pbtdi 190 ); 191 192 WINBOOL WINAPI BluetoothEnableDiscovery( 193 HANDLE hRadio, 194 WINBOOL fEnabled 195 ); 196 197 WINBOOL WINAPI BluetoothEnableIncomingConnections( 198 HANDLE hRadio, 199 WINBOOL fEnabled 200 ); 201 202 DWORD WINAPI BluetoothEnumerateInstalledServices( 203 HANDLE hRadio, 204 BLUETOOTH_DEVICE_INFO *pbtdi, 205 DWORD *pcServices, 206 GUID *pGuidServices 207 ); 208 209 WINBOOL WINAPI BluetoothFindDeviceClose( 210 HBLUETOOTH_DEVICE_FIND hFind 211 ); 212 213 HBLUETOOTH_DEVICE_FIND WINAPI BluetoothFindFirstDevice( 214 BLUETOOTH_DEVICE_SEARCH_PARAMS *pbtsp, 215 BLUETOOTH_DEVICE_INFO *pbtdi 216 ); 217 218 HBLUETOOTH_RADIO_FIND WINAPI BluetoothFindFirstRadio( 219 BLUETOOTH_FIND_RADIO_PARAMS *pbtfrp, 220 HANDLE *phRadio 221 ); 222 223 WINBOOL WINAPI BluetoothFindNextDevice( 224 HBLUETOOTH_DEVICE_FIND hFind, 225 BLUETOOTH_DEVICE_INFO *pbtdi 226 ); 227 228 WINBOOL WINAPI BluetoothFindNextRadio( 229 HBLUETOOTH_RADIO_FIND hFind, 230 HANDLE *phRadio 231 ); 232 233 WINBOOL WINAPI BluetoothFindRadioClose( 234 HBLUETOOTH_RADIO_FIND hFind 235 ); 236 237 DWORD WINAPI BluetoothGetDeviceInfo( 238 HANDLE hRadio, 239 BLUETOOTH_DEVICE_INFO *pbtdi 240 ); 241 242 DWORD WINAPI BluetoothGetRadioInfo( 243 HANDLE hRadio, 244 PBLUETOOTH_RADIO_INFO pRadioInfo 245 ); 246 247 WINBOOL WINAPI BluetoothIsDiscoverable( 248 HANDLE hRadio 249 ); 250 251 WINBOOL WINAPI BluetoothIsConnectable( 252 HANDLE hRadio 253 ); 254 255 DWORD WINAPI BluetoothRegisterForAuthentication( 256 BLUETOOTH_DEVICE_INFO *pbtdi, 257 HBLUETOOTH_AUTHENTICATION_REGISTRATION *phRegHandle, 258 PFN_AUTHENTICATION_CALLBACK pfnCallback, 259 PVOID pvParam 260 ); 261 262 HRESULT WINAPI BluetoothRegisterForAuthenticationEx( 263 const BLUETOOTH_DEVICE_INFO *pbtdiln, 264 HBLUETOOTH_AUTHENTICATION_REGISTRATION *phRegHandleOut, 265 PFN_AUTHENTICATION_CALLBACK_EX pfnCallbackIn, 266 PVOID pvParam 267 ); 268 269 DWORD WINAPI BluetoothRemoveDevice( 270 BLUETOOTH_ADDRESS *pAddress 271 ); 272 273 WINBOOL WINAPI BluetoothSdpEnumAttributes( 274 LPBYTE pSDPStream, 275 ULONG cbStreamSize, 276 PFN_BLUETOOTH_ENUM_ATTRIBUTES_CALLBACK pfnCallback, 277 LPVOID pvParam 278 ); 279 280 DWORD WINAPI BluetoothSdpGetAttributeValue( 281 LPBYTE pRecordStream, 282 ULONG cbRecordLength, 283 USHORT usAttributeId, 284 PSDP_ELEMENT_DATA pAttributeData 285 ); 286 287 DWORD WINAPI BluetoothSdpGetContainerElementData( 288 LPBYTE pContainerStream, 289 ULONG cbContainerLength, 290 HBLUETOOTH_CONTAINER_ELEMENT *pElement, 291 PSDP_ELEMENT_DATA pData 292 ); 293 294 DWORD BluetoothSdpGetElementData( 295 LPBYTE pSdpStream, 296 ULONG cbSpdStreamLength, 297 PSDP_ELEMENT_DATA pData 298 ); 299 300 DWORD BluetoothSdpGetString( 301 LPBYTE pRecordStream, 302 ULONG cbRecordLength, 303 PSDP_STRING_TYPE_DATA pStringData, 304 USHORT usStringOffset, 305 PWCHAR pszString, 306 PULONG pcchStringLength 307 ); 308 309 WINBOOL WINAPI BluetoothSelectDevices( 310 BLUETOOTH_SELECT_DEVICE_PARAMS *pbtsdp 311 ); 312 313 WINBOOL WINAPI BluetoothSelectDevicesFree( 314 BLUETOOTH_SELECT_DEVICE_PARAMS *pbtsdp 315 ); 316 317 DWORD WINAPI BluetoothSendAuthenticationResponse( 318 HANDLE hRadio, 319 BLUETOOTH_DEVICE_INFO *pbtdi, 320 LPWSTR pszPasskey 321 ); 322 323 HRESULT WINAPI BluetoothSendAuthenticationResponseEx( 324 HANDLE hRadioIn, 325 PBLUETOOTH_AUTHENTICATE_RESPONSE pauthResponse 326 ); 327 328 DWORD WINAPI BluetoothSetLocalServiceInfo( 329 HANDLE hRadioIn, 330 const GUID *pClassGuid, 331 ULONG ulInstance, 332 const BLUETOOTH_LOCAL_SERVICE_INFO *pServiceInfoIn 333 ); 334 335 DWORD WINAPI BluetoothSetServiceState( 336 HANDLE hRadio, 337 BLUETOOTH_DEVICE_INFO *pbtdi, 338 GUID *pGuidService, 339 DWORD dwServiceFlags 340 ); 341 342 WINBOOL WINAPI BluetoothUnregisterAuthentication( 343 HBLUETOOTH_AUTHENTICATION_REGISTRATION hRegHandle 344 ); 345 346 DWORD WINAPI BluetoothUpdateDeviceRecord( 347 BLUETOOTH_DEVICE_INFO *pbtdi 348 ); 349 350 #ifdef __cplusplus 351 } 352 #endif 353 354 #endif /*_INC_BLUETOOTHAPIS*/ 355 356