bt_api.pp 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 2008 Free Pascal development team.
  4. See the file COPYING.FPC, included in this distribution,
  5. for details about the copyright.
  6. This program is distributed in the hope that it will be useful,
  7. but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  9. ********************************************************************** }
  10. //------------------------------------------------------------------------------
  11. //
  12. // Bluetooth client API declarations
  13. //
  14. //
  15. // Module Name:
  16. //
  17. // bt_api.h
  18. //
  19. // Abstract:
  20. //
  21. // This file defines client-level APIs to Bluetooth stack
  22. //
  23. //
  24. //------------------------------------------------------------------------------
  25. //
  26. // Bluetooth client API
  27. //
  28. //
  29. // Microsoft Windows Mobile 6.0 for PocketPC SDK.
  30. //
  31. {$IFNDEF FPC_DOTTEDUNITS}
  32. unit bt_api;
  33. {$ENDIF FPC_DOTTEDUNITS}
  34. {$CALLING cdecl}
  35. interface
  36. {$IFDEF FPC_DOTTEDUNITS}
  37. uses WinApi.Windows, WinApi.Winsock2, WinceAPI.Winioctl, WinceAPI.Ws2bth;
  38. {$ELSE FPC_DOTTEDUNITS}
  39. uses Windows, WinSock2, WinIOCtl, ws2bth;
  40. {$ENDIF FPC_DOTTEDUNITS}
  41. //
  42. // COD classes
  43. //
  44. const
  45. BTH_COD_MAJOR_SERVICE_CLASS_INFORMATION = $800000;
  46. BTH_COD_MAJOR_SERVICE_CLASS_TELEPHONY = $400000;
  47. BTH_COD_MAJOR_SERVICE_CLASS_AUDIO = $200000;
  48. BTH_COD_MAJOR_SERVICE_CLASS_OBEX = $100000;
  49. BTH_COD_MAJOR_SERVICE_CLASS_CAPTURE = $080000;
  50. BTH_COD_MAJOR_SERVICE_CLASS_RENDERING = $040000;
  51. BTH_COD_MAJOR_SERVICE_CLASS_NETWORK = $020000;
  52. BTH_COD_MAJOR_SERVICE_CLASS_LIMITED_DISC = $002000;
  53. BTH_COD_MAJOR_DEVICE_CLASS_MISC = $000000;
  54. BTH_COD_MAJOR_DEVICE_CLASS_COMPUTER = $000100;
  55. BTH_COD_MAJOR_DEVICE_CLASS_PHONE = $000200;
  56. BTH_COD_MAJOR_DEVICE_CLASS_LAP = $000300;
  57. BTH_COD_MAJOR_DEVICE_CLASS_AUDIO = $000400;
  58. BTH_COD_MAJOR_DEVICE_CLASS_PERIPHERAL = $000500;
  59. BTH_COD_MAJOR_DEVICE_CLASS_UNCLASSIFIED = $001f00;
  60. BTH_COD_MINOR_COMPUTER_UNCLASSIFIED = $000000;
  61. BTH_COD_MINOR_COMPUTER_DESKTOP = $000004;
  62. BTH_COD_MINOR_COMPUTER_SERVER = $000008;
  63. BTH_COD_MINOR_COMPUTER_LAPTOP = $00000c;
  64. BTH_COD_MINOR_COMPUTER_HANDHELD = $000010;
  65. BTH_COD_MINOR_COMPUTER_PDA = $000014;
  66. BTH_COD_MINOR_PHONE_UNCLASSIFIED = $000000;
  67. BTH_COD_MINOR_PHONE_CELL = $000004;
  68. BTH_COD_MINOR_PHONE_CORDLESS = $000008;
  69. BTH_COD_MINOR_PHONE_SMART = $00000c;
  70. BTH_COD_MINOR_PHONE_WIRED = $000010;
  71. BTH_COD_MINOR_LAP_AVAILABLE = $000000;
  72. BTH_COD_MINOR_LAP_1_17 = $000004;
  73. BTH_COD_MINOR_LAP_17_33 = $000008;
  74. BTH_COD_MINOR_LAP_33_50 = $00000c;
  75. BTH_COD_MINOR_LAP_50_67 = $000010;
  76. BTH_COD_MINOR_LAP_67_83 = $000014;
  77. BTH_COD_MINOR_LAP_83_99 = $000018;
  78. BTH_COD_MINOR_LAP_NO_SERVICE = $00001c;
  79. BTH_COD_MINOR_AUDIO_UNCLASSIFIED = $000000;
  80. BTH_COD_MINOR_AUDIO_HEADSET = $000004;
  81. BTH_NAMEDEVENT_PAIRING_CHANGED = 'system/events/bluetooth/PairingChange';
  82. BTH_NAMEDEVENT_HARDWARE_CHANGED = 'system/events/bluetooth/HardwareChange';
  83. BTH_NAMEDEVENT_DEVICEID_CHANGED = 'system/events/bluetooth/DeviceIdChange';
  84. BTH_NAMEDEVENT_CONNECTIVITY_CHANGED = 'system/events/bluetooth/ConnectivityChange';
  85. BTH_NAMEDEVENT_SECURITY_CHANGED = 'system/events/bluetooth/SecurityChange';
  86. BTH_NAMEDEVENT_CONNECTIONS_CHANGED = 'system/events/bluetooth/ConnectionsChange';
  87. BTH_NAMEDEVENT_BASEBAND_CHANGED = 'system/events/bluetooth/BasebandChange';
  88. BTH_NAMEDEVENT_STACK_INITED = 'system/events/bluetooth/StackInitialized';
  89. BTH_NAMEDEVENT_PAN_REFRESH = 'system/events/bluetooth/pan/refresh';
  90. {$IFNDEF __bt_ddi_H__}
  91. //
  92. // Attention: also defined in bt_ddi.h! Keep in sync!
  93. //
  94. // Hardware Status
  95. //
  96. const
  97. HCI_HARDWARE_UNKNOWN = 0;
  98. HCI_HARDWARE_NOT_PRESENT = 1;
  99. HCI_HARDWARE_INITIALIZING = 2;
  100. HCI_HARDWARE_RUNNING = 3;
  101. HCI_HARDWARE_SHUTDOWN = 4;
  102. HCI_HARDWARE_ERROR = 5;
  103. {$ENDIF __bt_ddi_H__}
  104. const
  105. BTH_GET_BASEBAND_CONNECTIONS_EX_API_VERSION = 1;
  106. type
  107. _BASEBAND_CONNECTION = record
  108. hConnection:USHORT;
  109. baAddress:BT_ADDR;
  110. cDataPacketsPending:longint;
  111. _flags:UINT;
  112. {
  113. UINT fLinkType : 1; // The type of link. Zero (0) indicates SCO, and 1 indicates ACL.
  114. UINT fEncrypted : 1; // Encryption is enabled.
  115. UINT fAuthenticated : 1; // Indicates whether the connection has been authenticated.
  116. UINT fMode : 3; // The connection mode.
  117. }
  118. end;
  119. BASEBAND_CONNECTION = _BASEBAND_CONNECTION;
  120. PBASEBAND_CONNECTION = ^_BASEBAND_CONNECTION;
  121. type
  122. _BASEBAND_CONNECTION_EX = record
  123. hConnection:USHORT;
  124. baAddress:BT_ADDR;
  125. cDataPacketsPending:longint;
  126. link_type:UCHAR;
  127. mode:UCHAR;
  128. _flags:UINT;
  129. {
  130. UINT fEncrypted : 1;
  131. BOOL fAuthenticated : 1;
  132. }
  133. end;
  134. BASEBAND_CONNECTION_EX = _BASEBAND_CONNECTION_EX;
  135. PBASEBAND_CONNECTION_EX = ^_BASEBAND_CONNECTION_EX;
  136. const
  137. HCI_PAGE_SCAN_TYPE_STANDARD = $00;
  138. HCI_PAGE_SCAN_TYPE_INTERLACED = $01;
  139. HCI_INQUIRY_SCAN_TYPE_STANDARD = $00;
  140. HCI_INQUIRY_SCAN_TYPE_INTERLACED = $01;
  141. //
  142. // Warning: To use the following Bth* APIs you must link to btdrt.lib.
  143. // This library may or may not be available in your SDK.
  144. //
  145. // To preserve Win32 compatibility, consider using the Winsock equivalent
  146. // of these functions.
  147. //
  148. const
  149. BtdrtDll = 'btdrt.dll';
  150. //
  151. // Management APIs
  152. //
  153. function BthWriteScanEnableMask(mask:byte):longint; external BtdrtDll name 'BthWriteScanEnableMask';
  154. function BthReadScanEnableMask(pmask:LPBYTE):longint; external BtdrtDll name 'BthReadScanEnableMask';
  155. function BthWritePageTimeout(timeout:word):longint; external BtdrtDll name 'BthWritePageTimeout';
  156. function BthReadPageTimeout(ptimeout:LPWORD):longint; external BtdrtDll name 'BthReadPageTimeout';
  157. function BthWriteCOD(cod:dword):longint; external BtdrtDll name 'BthWriteCOD';
  158. function BthReadCOD(pcod:LPDWORD):longint; external BtdrtDll name 'BthReadCOD';
  159. function BthGetRemoteCOD(pbt:PBT_ADDR; pcod:LPDWORD):longint; external BtdrtDll name 'BthGetRemoteCOD';
  160. function BthWriteAuthenticationEnable(ae:byte):longint; external BtdrtDll name 'BthWriteAuthenticationEnable';
  161. function BthReadAuthenticationEnable(pae:LPBYTE):longint; external BtdrtDll name 'BthReadAuthenticationEnable';
  162. function BthWriteLinkPolicySettings(pba:PBT_ADDR; lps:word):longint; external BtdrtDll name 'BthWriteLinkPolicySettings';
  163. function BthReadLinkPolicySettings(pba:PBT_ADDR; plps:LPWORD):longint; external BtdrtDll name 'BthReadLinkPolicySettings';
  164. function BthEnterHoldMode(pba:PBT_ADDR; hold_mode_max:word; hold_mode_min:word; pinterval:LPWORD):longint; external BtdrtDll name 'BthEnterHoldMode';
  165. function BthEnterSniffMode(pba:PBT_ADDR;
  166. sniff_mode_max:word;
  167. sniff_mode_min:word;
  168. sniff_attempt:word;
  169. sniff_timeout:word;
  170. pinterval:LPWORD):longint; external BtdrtDll name 'BthEnterSniffMode';
  171. function BthExitSniffMode(pba:PBT_ADDR):longint; external BtdrtDll name 'BthExitSniffMode';
  172. function BthEnterParkMode(pba:PBT_ADDR; beacon_max:word; beacon_min:word; pinterval:LPWORD):longint; external BtdrtDll name 'BthEnterParkMode';
  173. function BthExitParkMode(pba:PBT_ADDR):longint; external BtdrtDll name 'BthExitParkMode';
  174. function BthGetCurrentMode(pba:PBT_ADDR; pmode:LPBYTE):longint; external BtdrtDll name 'BthGetCurrentMode';
  175. function BthGetBasebandHandles(cHandles:longint; pHandles:LPWORD; pcHandlesReturned:PLongint):longint; external BtdrtDll name 'BthGetBasebandHandles';
  176. function BthGetBasebandConnections(cConnections:longint; pConnections:PBASEBAND_CONNECTION; pcConnectionsReturned:PLongint):longint; external BtdrtDll name 'BthGetBasebandConnections';
  177. function BthGetBasebandConnectionsEx(dwApiVersion:DWORD;
  178. cConnections:longint;
  179. pConnections:PBASEBAND_CONNECTION_EX;
  180. pcConnectionsReturned:PLongint):longint; external BtdrtDll name 'BthGetBasebandConnectionsEx';
  181. function BthGetAddress(_handle:word; pba:PBT_ADDR):longint; external BtdrtDll name 'BthGetAddress';
  182. function BthReadLocalAddr(pba:PBT_ADDR):longint; external BtdrtDll name 'BthReadLocalAddr';
  183. function BthGetHardwareStatus(pistatus:PLongint):longint; external BtdrtDll name 'BthGetHardwareStatus';
  184. function BthReadLocalVersion(phci_version:LPBYTE;
  185. phci_revision:LPWORD;
  186. plmp_version:LPBYTE;
  187. plmp_subversion:LPWORD;
  188. pmanufacturer:LPWORD;
  189. plmp_features:LPBYTE):longint; external BtdrtDll name 'BthReadLocalVersion';
  190. function BthReadRemoteVersion(pba:PBT_ADDR;
  191. plmp_version:LPBYTE;
  192. plmp_subversion:LPWORD;
  193. pmanufacturer:LPWORD;
  194. plmp_features:LPBYTE):longint; external BtdrtDll name 'BthReadRemoteVersion';
  195. function BthPerformInquiry(LAP:LongWord;
  196. _length:byte;
  197. num_responses:byte;
  198. cBuffer:LongWord;
  199. pcDiscoveredDevices:LPDWORD;
  200. InquiryList:PBthInquiryResult):longint; external BtdrtDll name 'BthPerformInquiry';
  201. function BthCancelInquiry:longint; external BtdrtDll name 'BthCancelInquiry';
  202. function BthRemoteNameQuery(pba:PBT_ADDR; cBuffer:LongWord; pcRequired:LPDWORD; szString:PWCHAR):longint; external BtdrtDll name 'BthRemoteNameQuery';
  203. function BthTerminateIdleConnections:longint; external BtdrtDll name 'BthTerminateIdleConnections';
  204. function BthSetInquiryFilter(pba:PBT_ADDR):longint; external BtdrtDll name 'BthSetInquiryFilter';
  205. function BthSetCODInquiryFilter(cod:LongWord; codMask:LongWord):longint; external BtdrtDll name 'BthSetCODInquiryFilter';
  206. function BthClearInquiryFilter:longint; external BtdrtDll name 'BthClearInquiryFilter';
  207. function BthSwitchRole(pbt:PBT_ADDR; usRole:USHORT):longint; external BtdrtDll name 'BthSwitchRole';
  208. function BthGetRole(pbt:PBT_ADDR; pusRole:PUSHORT):longint; external BtdrtDll name 'BthGetRole';
  209. function BthReadRSSI(pbt:PBT_ADDR; pbRSSI:LPBYTE):longint; external BtdrtDll name 'BthReadRSSI';
  210. //
  211. // Security manager APIs
  212. //
  213. function BthSetPIN(pba:PBT_ADDR; cPinLength:longint; ppin:LPBYTE):longint; external BtdrtDll name 'BthSetPIN';
  214. function BthRevokePIN(pba:PBT_ADDR):longint; external BtdrtDll name 'BthRevokePIN';
  215. type
  216. TBthLinkKey = packed array[0..15] of byte;
  217. PBthLinkKey = ^TBthLinkKey;
  218. function BthSetLinkKey(pba:PBT_ADDR; key:TBthLinkKey):longint; external BtdrtDll name 'BthSetLinkKey';
  219. function BthGetLinkKey(pba:PBT_ADDR; key:TBthLinkKey):longint; external BtdrtDll name 'BthGetLinkKey';
  220. function BthRevokeLinkKey(pba:PBT_ADDR):longint; external BtdrtDll name 'BthRevokeLinkKey';
  221. function BthAuthenticate(pba:PBT_ADDR):longint; external BtdrtDll name 'BthAuthenticate';
  222. function BthSetEncryption(pba:PBT_ADDR; fOn:longint):longint; external BtdrtDll name 'BthSetEncryption';
  223. function BthSetSecurityUI(_hEvent:HANDLE; dwStoreTimeout:DWORD; dwProcTimeout:DWORD):longint; external BtdrtDll name 'BthSetSecurityUI';
  224. function BthGetPINRequest(pbt:PBT_ADDR):longint; external BtdrtDll name 'BthGetPINRequest';
  225. function BthRefusePINRequest(pbt:PBT_ADDR):longint; external BtdrtDll name 'BthRefusePINRequest';
  226. function BthAnswerPairRequest(pba:PBT_ADDR; cPinLength:longint; ppin:LPBYTE):longint; external BtdrtDll name 'BthAnswerPairRequest';
  227. function BthPairRequest(pba:PBT_ADDR; cPinLength:longint; ppin:LPBYTE):longint; external BtdrtDll name 'BthAnswerPairRequest';
  228. //
  229. // Connection APIs
  230. //
  231. function BthCreateACLConnection(pbt:PBT_ADDR; _phandle:LPWORD):longint; external BtdrtDll name 'BthCreateACLConnection';
  232. function BthCreateSCOConnection(pbt:PBT_ADDR; _phandle:LPWORD):longint; external BtdrtDll name 'BthCreateSCOConnection';
  233. function BthCloseConnection(_handle:word):longint; external BtdrtDll name 'BthCloseConnection';
  234. function BthAcceptSCOConnections(fAccept:BOOL):longint; external BtdrtDll name 'BthAcceptSCOConnections';
  235. function BthWritePageScanActivity(pageScanInterval:word; pageScanWindow:word):longint; external BtdrtDll name 'BthWritePageScanActivity';
  236. function BthWriteInquiryScanActivity(inquiryScanInterval:word; inquiryScanWindow:word):longint; external BtdrtDll name 'BthWriteInquiryScanActivity';
  237. function BthReadPageScanActivity(pPageScanInterval:LPWORD; pPageScanWindow:LPWORD):longint; external BtdrtDll name 'BthReadPageScanActivity';
  238. function BthReadInquiryScanActivity(pInquiryScanInterval:LPWORD; pInquiryScanWindow:LPWORD):longint; external BtdrtDll name 'BthReadInquiryScanActivity';
  239. function BthWritePageScanType(pageScanType:byte):longint; external BtdrtDll name 'BthWritePageScanType';
  240. function BthWriteInquiryScanType(inquiryScanType:byte):longint; external BtdrtDll name 'BthWriteInquiryScanType';
  241. function BthReadPageScanType(pPageScanType:LPBYTE):longint; external BtdrtDll name 'BthReadPageScanType';
  242. function BthReadInquiryScanType(pInquiryScanType:LPBYTE):longint; external BtdrtDll name 'BthReadInquiryScanType';
  243. function BthCreateSynchronousConnection(pbt:PBT_ADDR;
  244. pHandle:LPWORD;
  245. txBandwidth:LongWord;
  246. rxBandwidth:LongWord;
  247. maxLatency:word;
  248. voiceSetting:word;
  249. retransmit:byte):longint; external BtdrtDll name 'BthCreateSynchronousConnection';
  250. function BthAcceptSynchronousConnections(fAccept:BOOL):longint; external BtdrtDll name 'BthAcceptSynchronousConnections';
  251. //
  252. // SDP Name Service APIs
  253. //
  254. type
  255. {
  256. SdpAttributeRange = _SdpAttributeRange;
  257. SdpQueryUuid = _SdpQueryUuid;
  258. }
  259. _WSAQuerySetW = TWSAQuerySetW;
  260. _WSAESETSERVICEOP = TWSAeSetServiceOp;
  261. WSAESETSERVICEOP = _WSAESETSERVICEOP;
  262. function BthNsSetService(pSet:LPWSAQUERYSET; op:WSAESETSERVICEOP; dwFlags:DWORD):longint; external BtdrtDll name 'BthNsSetService';
  263. function BthNsLookupServiceBegin(pQuerySet:LPWSAQUERYSET; dwFlags:DWORD; lphLookup:LPHANDLE):longint; external BtdrtDll name 'BthNsLookupServiceBegin';
  264. function BthNsLookupServiceNext(hLookup:HANDLE; dwFlags:DWORD; lpdwBufferLength:LPDWORD; pResults:LPWSAQUERYSET):longint; external BtdrtDll name 'BthNsLookupServiceNext';
  265. function BthNsLookupServiceEnd(hLookup:HANDLE):longint; external BtdrtDll name 'BthNsLookupServiceEnd';
  266. //
  267. // RFCOMM Apis
  268. //
  269. const
  270. RFCOMM_PORT_FLAGS_REMOTE_DCB = $00000001;
  271. RFCOMM_PORT_FLAGS_KEEP_DCD = $00000002;
  272. RFCOMM_PORT_FLAGS_AUTHENTICATE = $00000004;
  273. RFCOMM_PORT_FLAGS_ENCRYPT = $00000008;
  274. {$IFNDEF __bt_ddi_H__}
  275. //
  276. // Attention: also defined in bt_ddi.h! Keep in sync!
  277. //
  278. // channel:
  279. // RFCOMM_CHANNEL_ALL accept connection on all channels (default upper layer)
  280. // RFCOMM_CHANNEL_CLIENT_ONLY do not accept connections at all (client only)
  281. // ...or channel to restrict connections on
  282. //
  283. const
  284. RFCOMM_CHANNEL_ALL = $00;
  285. RFCOMM_CHANNEL_MULTIPLE = $fe;
  286. RFCOMM_CHANNEL_CLIENT_ONLY = $ff;
  287. {$ENDIF __bt_ddi_H__}
  288. type
  289. _portemu_port_params = record
  290. channel:longint;
  291. flocal:longint;
  292. device:BT_ADDR;
  293. imtu:longint;
  294. iminmtu:longint;
  295. imaxmtu:longint;
  296. isendquota:longint;
  297. irecvquota:longint;
  298. uuidService:GUID;
  299. uiportflags:LongWord;
  300. end;
  301. PORTEMUPortParams = _portemu_port_params;
  302. // Bluetooth serial IOCTLs are cross-defined in pegdser.h to reserve spot there.
  303. const
  304. IOCTL_BLUETOOTH_GET_RFCOMM_CHANNEL = (FILE_DEVICE_SERIAL_PORT shl 16) or
  305. (FILE_ANY_ACCESS shl 14) or
  306. (24 shl 2) or
  307. METHOD_BUFFERED;
  308. // #define IOCTL_BLUETOOTH_GET_RFCOMM_CHANNEL CTL_CODE(FILE_DEVICE_SERIAL_PORT,24,METHOD_BUFFERED,FILE_ANY_ACCESS)
  309. IOCTL_BLUETOOTH_GET_PEER_DEVICE = (FILE_DEVICE_SERIAL_PORT shl 16) or
  310. (FILE_ANY_ACCESS shl 14) or
  311. (25 shl 2) or
  312. METHOD_BUFFERED;
  313. // #define IOCTL_BLUETOOTH_GET_PEER_DEVICE CTL_CODE(FILE_DEVICE_SERIAL_PORT,25,METHOD_BUFFERED,FILE_ANY_ACCESS)
  314. //
  315. // Bluetooth notification system
  316. //
  317. function RequestBluetoothNotifications(
  318. dwClass:DWORD; // class of notifications to register for
  319. hMsgQ:HANDLE // message queue created by caller
  320. ):HANDLE; external BtdrtDll name 'RequestBluetoothNotifications';
  321. function StopBluetoothNotifications(
  322. h:HANDLE // Handle returned from RequestBluetoothNotifications
  323. ):BOOL; external BtdrtDll name 'StopBluetoothNotifications';
  324. type
  325. _BTEVENT = record
  326. dwEventId:DWORD; // Event ID
  327. dwReserved:DWORD; // Reserved
  328. baEventData:array[0..63] of byte; // Event Data
  329. end;
  330. BTEVENT = _BTEVENT;
  331. PBTEVENT = ^_BTEVENT;
  332. //
  333. // Class of events to notify connections going up/down
  334. // and other connection-related changes (role, mode).
  335. //
  336. const
  337. BTE_CLASS_CONNECTIONS = 1;
  338. BTE_CONNECTION = 100;
  339. BTE_DISCONNECTION = 101;
  340. BTE_ROLE_SWITCH = 102;
  341. BTE_MODE_CHANGE = 103;
  342. BTE_PAGE_TIMEOUT = 104;
  343. type
  344. BT_CONNECT_EVENT = record
  345. dwSize:DWORD; // To keep track of version
  346. hConnection:USHORT; // Baseband connection handle
  347. bta:BT_ADDR; // Address of remote device
  348. ucLinkType:UCHAR; // Link Type (ACL/SCO)
  349. ucEncryptMode:UCHAR; // Encryption mode
  350. end;
  351. PBT_CONNECT_EVENT = ^BT_CONNECT_EVENT;
  352. type
  353. BT_DISCONNECT_EVENT = record
  354. dwSize:DWORD; // To keep track of version
  355. hConnection:USHORT; // Baseband connection handle
  356. ucReason:UCHAR; // Reason for disconnection
  357. end;
  358. PBT_DISCONNECT_EVENT = ^BT_DISCONNECT_EVENT;
  359. type
  360. BT_ROLE_SWITCH_EVENT = record
  361. dwSize:DWORD; // To keep track of version
  362. bta:BT_ADDR; // Address of remote device
  363. _flags:UINT;
  364. {
  365. UINT fRole : 1; // New Role (master/slave)
  366. }
  367. end;
  368. PBT_ROLE_SWITCH_EVENT = ^BT_ROLE_SWITCH_EVENT;
  369. type
  370. BT_MODE_CHANGE_EVENT = record
  371. dwSize:DWORD; // To keep track of version
  372. hConnection:USHORT; // Baseband connection handle
  373. bta:BT_ADDR; // Address of remote device
  374. bMode:byte; // Power mode (sniff, etc)
  375. usInterval:USHORT; // Power mode interval
  376. end;
  377. PBT_MODE_CHANGE_EVENT = ^BT_MODE_CHANGE_EVENT;
  378. //
  379. // Class of events to notify changes in pairing.
  380. //
  381. const
  382. BTE_CLASS_PAIRING = 2;
  383. BTE_KEY_NOTIFY = 200;
  384. BTE_KEY_REVOKED = 201;
  385. type
  386. BT_LINK_KEY_EVENT = record
  387. dwSize:DWORD; // To keep track of version
  388. bta:BT_ADDR; // Address of remote device
  389. link_key:array[0..15] of UCHAR; // Link key data
  390. key_type:UCHAR; // Link key type
  391. end;
  392. PBT_LINK_KEY_EVENT = ^BT_LINK_KEY_EVENT;
  393. //
  394. // Class of events to notify changes specific to the
  395. // local device (cod, name)
  396. //
  397. const
  398. BTE_CLASS_DEVICE = 4;
  399. BTE_LOCAL_NAME = 300;
  400. BTE_COD = 301;
  401. //
  402. // Class of events to notify change of state of the
  403. // core stack.
  404. //
  405. const
  406. BTE_CLASS_STACK = 8;
  407. BTE_STACK_UP = 400;
  408. BTE_STACK_DOWN = 401;
  409. //
  410. // Class of events to notify change of state of AVDTP
  411. //
  412. const
  413. BTE_CLASS_AVDTP = 16;
  414. BTE_AVDTP_STATE = 500;
  415. BT_AVDTP_STATE_DISCONNECTED = 0;
  416. BT_AVDTP_STATE_SUSPENDED = 1;
  417. BT_AVDTP_STATE_STREAMING = 2;
  418. type
  419. BT_AVDTP_STATE_CHANGE = record
  420. dwSize:DWORD; // To keep track of version
  421. bta:BT_ADDR; // Address of remote device
  422. dwState:DWORD; // New state of the AVDTP stream
  423. end;
  424. PBT_AVDTP_STATE_CHANGE = ^BT_AVDTP_STATE_CHANGE;
  425. //
  426. // Class of events to notify change of PAN state
  427. //
  428. const
  429. BTE_CLASS_PAN = 32;
  430. BTE_PAN_CONNECTIONS = 600;
  431. type
  432. BT_PAN_NUM_CONNECTIONS = record
  433. dwSize:DWORD; // To keep track of version
  434. NumConnections:DWORD; // Number of peers connected
  435. end;
  436. PBT_PAN_NUM_CONNECTIONS = ^BT_PAN_NUM_CONNECTIONS;
  437. //
  438. // PAN APIs
  439. //
  440. function BthActivatePAN(fActivate:BOOL):longint; external BtdrtDll name 'BthActivatePAN';
  441. function rfRegisterDevice(lpszType:LPCWSTR; dwIndex:DWORD; lpszLib:LPCWSTR; dwInfo:DWORD):HANDLE; external KernelDLL name 'RegisterDevice'; // index 14F
  442. function rfDeregisterDevice(hDevice:HANDLE):BOOL; external KernelDLL name 'DeregisterDevice';
  443. function rfCreateFile(lpFileName:LPCTSTR;
  444. dwDesiredAccess:DWORD;
  445. dwShareMode:DWORD;
  446. lpSecurityAttributes:LPSECURITY_ATTRIBUTES;
  447. dwCreationDisposition:DWORD;
  448. dwFlagsAndAttributes:DWORD;
  449. hTemplateFile:HANDLE):HANDLE; external KernelDLL name 'CreateFileW';
  450. function rfReadFile(_hFile:HANDLE; // handle to file
  451. lpBuffer:LPVOID; // data buffer
  452. nNumberOfBytesToRead:DWORD; // number of bytes to read
  453. lpNumberOfBytesRead:LPDWORD; // number of bytes read
  454. lpOverlapped:LPOVERLAPPED // overlapped buffer
  455. ):BOOL; external KernelDLL name 'ReadFile'; // index F4
  456. function rfWriteFile(_hFile:HANDLE; // handle to file
  457. lpBuffer:LPCVOID; // data buffer
  458. nNumberOfBytesToWrite:DWORD; // number of bytes to write
  459. lpNumberOfBytesWritten:LPDWORD; // number of bytes written
  460. lpOverlapped:LPOVERLAPPED // overlapped buffer
  461. ):BOOL; external KernelDLL name 'WriteFile';
  462. function rfCloseHandle(_hFile:HANDLE):BOOL; external KernelDLL name 'CloseHandle';
  463. implementation
  464. end.