00001 00002 #ifndef BTAPI_H_1348463732 00003 #define BTAPI_H_1348463732 00004 00005 #include <windows.h> 00006 #include <zeusbase/Net/bluetooth/bcb6/ws2bth.h> 00007 00008 #define BLUETOOTH_MAX_NAME_SIZE (248) 00009 #define BLUETOOTH_MAX_PASSKEY_SIZE (16) 00010 #define BLUETOOTH_MAX_PASSKEY_BUFFER_SIZE (BLUETOOTH_MAX_PASSKEY_SIZE + 1) 00011 #define BLUETOOTH_MAX_SERVICE_NAME_SIZE (256) 00012 #define BLUETOOTH_DEVICE_NAME_SIZE (256) 00013 00014 00015 #ifdef __cplusplus 00016 extern "C" { 00017 #endif 00018 00019 // *************************************************************************** 00020 // 00021 // Bluetooth Address 00022 // 00023 // *************************************************************************** 00024 00025 typedef ULONGLONG BTH_ADDR; 00026 00027 typedef struct _BLUETOOTH_ADDRESS { 00028 union { 00029 BTH_ADDR ullLong; // easier to compare again BLUETOOTH_NULL_ADDRESS 00030 BYTE rgBytes[ 6 ]; // easier to format when broken out 00031 }; 00032 00033 } BLUETOOTH_ADDRESS_STRUCT; 00034 00035 #define BLUETOOTH_ADDRESS BLUETOOTH_ADDRESS_STRUCT 00036 00037 #define BLUETOOTH_NULL_ADDRESS ( (ULONGLONG) 0x0 ) 00038 00039 // *************************************************************************** 00040 // 00041 // Device Information Stuctures 00042 // 00043 // *************************************************************************** 00044 00045 typedef struct _BLUETOOTH_DEVICE_INFO 00046 { 00047 DWORD dwSize; // size, in bytes, of this structure - must be the sizeof(BLUETOOTH_DEVICE_INFO) 00048 00049 BLUETOOTH_ADDRESS Address; // Bluetooth address 00050 00051 ULONG ulClassofDevice; // Bluetooth "Class of Device" 00052 00053 BOOL fConnected; // Device connected/in use 00054 BOOL fRemembered; // Device remembered 00055 BOOL fAuthenticated; // Device authenticated/paired/bonded 00056 00057 SYSTEMTIME stLastSeen; // Last time the device was seen 00058 SYSTEMTIME stLastUsed; // Last time the device was used for other than RNR, inquiry, or SDP 00059 00060 WCHAR szName[ BLUETOOTH_MAX_NAME_SIZE ]; // Name of the device 00061 00062 } BLUETOOTH_DEVICE_INFO_STRUCT; 00063 00064 #define BLUETOOTH_DEVICE_INFO BLUETOOTH_DEVICE_INFO_STRUCT 00065 00066 typedef BLUETOOTH_DEVICE_INFO * PBLUETOOTH_DEVICE_INFO; 00067 00068 // *************************************************************************** 00069 // 00070 // Device Enumeration 00071 // 00072 // Description: 00073 // Enumerates the Bluetooth devices. The types of returned device depends 00074 // on the flags set in the BLUETOOTH_DEVICE_SEARCH_PARAMS (see structure 00075 // definition for details). 00076 // 00077 // Sample Usage: 00078 // HBLUETOOTH_DEVICE_FIND hFind; 00079 // BLUETOOTH_DEVICE_SEARCH_PARAMS btsp = { sizeof(btsp) }; 00080 // BLUETOOTH_DEVICE_INFO btdi = { sizeof(btdi) }; 00081 // 00082 // btsp.fReturnAuthenticated = TRUE; 00083 // btsp.fReturnRemembered = TRUE; 00084 // 00085 // hFind = BluetoothFindFirstDevice( &btsp, &btdi ); 00086 // if ( NULL != hFind ) 00087 // { 00088 // do 00089 // { 00090 // // 00091 // // TODO: Do something useful with the device info. 00092 // // 00093 // 00094 // } while( BluetoothFindNextDevice( hFind, &btdi ) ); 00095 // 00096 // BluetoothFindDeviceClose( hFind ); 00097 // } 00098 // 00099 // *************************************************************************** 00100 00101 typedef struct _BLUETOOTH_DEVICE_SEARCH_PARAMS { 00102 DWORD dwSize; // IN sizeof this structure 00103 00104 BOOL fReturnAuthenticated; // IN return authenticated devices 00105 BOOL fReturnRemembered; // IN return remembered devices 00106 BOOL fReturnUnknown; // IN return unknown devices 00107 BOOL fReturnConnected; // IN return connected devices 00108 00109 BOOL fIssueInquiry; // IN issue a new inquiry 00110 UCHAR cTimeoutMultiplier; // IN timeout for the inquiry 00111 00112 HANDLE hRadio; // IN handle to radio to enumerate - NULL == all radios will be searched 00113 00114 } BLUETOOTH_DEVICE_SEARCH_PARAMS; 00115 00116 typedef HANDLE HBLUETOOTH_DEVICE_FIND; 00117 00118 00119 // *************************************************************************** 00120 // 00121 // Radio Enumeration 00122 // 00123 // Description: 00124 // This group of APIs enumerates the installed Bluetooth radios. 00125 // 00126 // Sample Usage: 00127 // HANDLE hRadio; 00128 // BLUETOOTH_FIND_RADIO_PARAMS btfrp = { sizeof(btfrp) }; 00129 // 00130 // HBLUETOOTH_RADIO_FIND hFind = BluetoothFindFirstRadio( &btfrp, &hRadio ); 00131 // if ( NULL != hFind ) 00132 // { 00133 // do 00134 // { 00135 // // 00136 // // TODO: Do something with the radio handle. 00137 // // 00138 // 00139 // CloseHandle( hRadio ); 00140 // 00141 // } while( BluetoothFindNextRadio( hFind, &hRadio ) ); 00142 // 00143 // BluetoothFindRadioClose( hFind ); 00144 // } 00145 // 00146 // *************************************************************************** 00147 00148 typedef struct _BLUETOOTH_FIND_RADIO_PARAMS { 00149 DWORD dwSize; // IN sizeof this structure 00150 00151 } BLUETOOTH_FIND_RADIO_PARAMS; 00152 00153 typedef HANDLE HBLUETOOTH_RADIO_FIND; 00154 00155 // *************************************************************************** 00156 // 00157 // Radio Information 00158 // 00159 // *************************************************************************** 00160 00161 typedef struct _BLUETOOTH_RADIO_INFO { 00162 DWORD dwSize; // Size, in bytes, of this entire data structure 00163 00164 BLUETOOTH_ADDRESS address; // Address of the local radio 00165 00166 WCHAR szName[ BLUETOOTH_MAX_NAME_SIZE ]; // Name of the local radio 00167 00168 ULONG ulClassofDevice; // Class of device for the local radio 00169 00170 USHORT lmpSubversion; // lmpSubversion, manufacturer specifc. 00171 USHORT manufacturer; // Manufacturer of the radio, BTH_MFG_Xxx value. For the most up to date 00172 // list, goto the Bluetooth specification website and get the Bluetooth 00173 // assigned numbers document. 00174 } BLUETOOTH_RADIO_INFO, *PBLUETOOTH_RADIO_INFO; 00175 00176 00177 // 00178 // Description: 00179 // Begins the enumeration of Bluetooth devices. 00180 // 00181 // Parameters: 00182 // pbtsp 00183 // A pointer to a BLUETOOTH_DEVICE_SEARCH_PARAMS structure. This 00184 // structure contains the flags and inputs used to conduct the search. 00185 // See BLUETOOTH_DEVICE_SEARCH_PARAMS for details. 00186 // 00187 // pbtdi 00188 // A pointer to a BLUETOOTH_DEVICE_INFO structure to return information 00189 // about the first Bluetooth device found. Note that the dwSize member 00190 // of the structure must be the sizeof(BLUETOOTH_DEVICE_INFO) before 00191 // calling because the APIs hast to know the size of the buffer being 00192 // past in. The dwSize member must also match the exact 00193 // sizeof(BLUETOOTH_DEVICE_INFO) or the call will fail. 00194 // 00195 // Return Values: 00196 // NULL 00197 // Error opening radios or not devices found. Use GetLastError for more info. 00198 // 00199 // ERROR_INVALID_PARAMETER 00200 // pbtsp parameter or pbtdi parameter is NULL. 00201 // 00202 // ERROR_REVISION_MISMATCH 00203 // The pbtfrp structure is not the right length. 00204 // 00205 // other Win32 errors 00206 // 00207 // any other value 00208 // Success. The return handle is valid and pbtdi points to valid data. 00209 // 00210 HBLUETOOTH_DEVICE_FIND 00211 WINAPI 00212 BluetoothFindFirstDevice( 00213 const BLUETOOTH_DEVICE_SEARCH_PARAMS * pbtsp, 00214 BLUETOOTH_DEVICE_INFO * pbtdi 00215 ); 00216 00217 // 00218 // Description: 00219 // Finds the next Bluetooth device in the enumeration. 00220 // 00221 // Parameters: 00222 // hFind 00223 // The handle returned from BluetoothFindFirstDevice(). 00224 // 00225 // pbtdi 00226 // A pointer to a BLUETOOTH_DEVICE_INFO structure to return information 00227 // about the first Bluetooth device found. Note that the dwSize member 00228 // of the structure must be the sizeof(BLUETOOTH_DEVICE_INFO) before 00229 // calling because the APIs hast to know the size of the buffer being 00230 // past in. The dwSize member must also match the exact 00231 // sizeof(BLUETOOTH_DEVICE_INFO) or the call will fail. 00232 // 00233 // Return Values: 00234 // TRUE 00235 // Next device succesfully found. pHandleOut points to valid handle. 00236 // 00237 // FALSE 00238 // No device found. pHandleOut points to an invalid handle. Call 00239 // GetLastError() for more details. 00240 // 00241 // ERROR_INVALID_HANDLE 00242 // The handle is NULL. 00243 // 00244 // ERROR_NO_MORE_ITEMS 00245 // No more radios found. 00246 // 00247 // ERROR_OUTOFMEMORY 00248 // Out of memory. 00249 // 00250 // other Win32 errors 00251 // 00252 BOOL 00253 WINAPI 00254 BluetoothFindNextDevice( 00255 HBLUETOOTH_DEVICE_FIND hFind, 00256 BLUETOOTH_DEVICE_INFO * pbtdi 00257 ); 00258 00259 // 00260 // Description: 00261 // Closes the enumeration handle. 00262 // 00263 // Parameters: 00264 // hFind 00265 // The handle returned from BluetoothFindFirstDevice(). 00266 // 00267 // Return Values: 00268 // TRUE 00269 // Handle succesfully closed. 00270 // 00271 // FALSE 00272 // Failure. Check GetLastError() for details. 00273 // 00274 // ERROR_INVALID_HANDLE 00275 // The handle is NULL. 00276 // 00277 BOOL 00278 WINAPI 00279 BluetoothFindDeviceClose( 00280 HBLUETOOTH_DEVICE_FIND hFind 00281 ); 00282 00283 // 00284 // Description: 00285 // Begins the enumeration of local Bluetooth radios. 00286 // 00287 // Parameters: 00288 // pbtfrp 00289 // A pointer to a BLUETOOTH_FIND_RADIO_PARAMS structure. The dwSize 00290 // member of this structure must match the sizeof the of the structure. 00291 // 00292 // phRadio 00293 // A pointer where the first radio HANDLE enumerated will be returned. 00294 // 00295 // Return Values: 00296 // NULL 00297 // Error opening radios or no devices found. Use GetLastError() for 00298 // more info. 00299 // 00300 // ERROR_INVALID_PARAMETER 00301 // pbtfrp parameter is NULL. 00302 // 00303 // ERROR_REVISION_MISMATCH 00304 // The pbtfrp structure is not the right length. 00305 // 00306 // ERROR_OUTOFMEMORY 00307 // Out of memory. 00308 // 00309 // other Win32 errors. 00310 // 00311 // any other 00312 // Success. The return handle is valid and phRadio points to a valid handle. 00313 // 00314 HBLUETOOTH_RADIO_FIND 00315 WINAPI 00316 BluetoothFindFirstRadio( 00317 const BLUETOOTH_FIND_RADIO_PARAMS * pbtfrp, 00318 HANDLE * phRadio 00319 ); 00320 00321 // 00322 // Description: 00323 // Finds the next installed Bluetooth radio. 00324 // 00325 // Parameters: 00326 // hFind 00327 // The handle returned by BluetoothFindFirstRadio(). 00328 // 00329 // phRadio 00330 // A pointer where the next radio HANDLE enumerated will be returned. 00331 // 00332 // Return Values: 00333 // TRUE 00334 // Next device succesfully found. pHandleOut points to valid handle. 00335 // 00336 // FALSE 00337 // No device found. pHandleOut points to an invalid handle. Call 00338 // GetLastError() for more details. 00339 // 00340 // ERROR_INVALID_HANDLE 00341 // The handle is NULL. 00342 // 00343 // ERROR_NO_MORE_ITEMS 00344 // No more radios found. 00345 // 00346 // ERROR_OUTOFMEMORY 00347 // Out of memory. 00348 // 00349 // other Win32 errors 00350 // 00351 BOOL 00352 WINAPI 00353 BluetoothFindNextRadio( 00354 HBLUETOOTH_RADIO_FIND hFind, 00355 HANDLE * phRadio 00356 ); 00357 00358 00359 // 00360 // Description: 00361 // Retrieves the information about the radio represented by the handle. 00362 // 00363 // Parameters: 00364 // hRadio 00365 // Handle to a local radio retrieved through BluetoothFindFirstRadio() 00366 // et al or SetupDiEnumerateDeviceInterfaces() 00367 // 00368 // pRadioInfo 00369 // Radio information to be filled in. The dwSize member must match the 00370 // size of the structure. 00371 // 00372 // Return Values: 00373 // ERROR_SUCCESS 00374 // The information was retrieved successfully. 00375 // 00376 // ERROR_INVALID_PARAMETER 00377 // pRadioInfo or hRadio is NULL. 00378 // 00379 // ERROR_REVISION_MISMATCH 00380 // pRadioInfo->dwSize is invalid. 00381 // 00382 // other Win32 error codes. 00383 // 00384 DWORD 00385 WINAPI 00386 BluetoothGetRadioInfo( 00387 HANDLE hRadio, 00388 PBLUETOOTH_RADIO_INFO pRadioInfo 00389 ); 00390 00391 // 00392 // Description: 00393 // Closes the enumeration handle. 00394 // 00395 // Parameters 00396 // hFind 00397 // The handle returned by BluetoothFindFirstRadio(). 00398 // 00399 // Return Values: 00400 // TRUE 00401 // Handle succesfully closed. 00402 // 00403 // FALSE 00404 // Failure. Check GetLastError() for details. 00405 // 00406 // ERROR_INVALID_HANDLE 00407 // The handle is NULL. 00408 // 00409 BOOL 00410 WINAPI 00411 BluetoothFindRadioClose( 00412 HBLUETOOTH_RADIO_FIND hFind 00413 ); 00414 00415 00416 #ifdef __cplusplus 00417 } 00418 #endif 00419 00420 #endif