' ########################################################################################
' Microsoft Windows
' File: bthdef.inc
' Contents: Bluetooth common structures and definitions
' Copyright (c) 2011 Jos? Roca
' Portions Copyright (c) Microsoft Corporation.
' All Rights Reserved.
' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
' EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
' MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
' ########################################################################################
#IF NOT %DEF(PBX_bthdef_PBI)
#DEFINE PBX_bthdef_PBI
%EQUATE `BTHDEF_INC = 1
'//
'// Bluetooth 2.1 support added in KB942567
'//
'#if (NTDDI_VERSION > NTDDI_VISTASP1 || \
' (NTDDI_VERSION == NTDDI_VISTASP1 && defined(VISTA_KB942567)))
' #define BTH_MAJORVERSION 2
' #define BTH_MINORVERSION 1
'#elif(NTDDI_VERSION >= NTDDI_WINXPSP2)
' #define BTH_MAJORVERSION 2
' #define BTH_MINORVERSION 0
'#endif // >= SP1+KB942567
#IF NOT %DEF(%GUID_DEFS_ONLY)
 #IF NOT %DEF(%NO_BTHSDPDEF_INC)
 #INCLUDE ONCE "Legacy/Devices/bthsdpdef.inc"
 #ENDIF ' // NO_BTHSDPDEF_INC
#ENDIF ' // GUID_DEFS_ONLY
'#if _MSC_VER >= 1200
'#pragma warning(push)
'#endif
'#pragma warning(disable:4201) // nameless struct/union
'#if (NTDDI_VERSION >= NTDDI_WINXPSP2)
#IF NOT %DEF(%NO_GUID_DEFS)
$GUID_BTHPORT_DEVICE_INTERFACE = GUID$("{0850302A-B344-4fda-9BE9-90576B8D46F0}")
$GUID_BLUETOOTH_RADIO_IN_RANGE = GUID$("{EA3B5B82-26EE-450E-B0D8-D26FE30A3869}")
$GUID_BLUETOOTH_RADIO_OUT_OF_RANGE = GUID$("{E28867C9-C2AA-4CED-B969-4570866037C4}")
'$GUID_BLUETOOTH_PIN_REQUEST = GUID$("{BD198B7C-24AB-4B9A-8C0D-A8EA8349AA16}") ' // Removed in Windows 7 SDK
$GUID_BLUETOOTH_L2CAP_EVENT = GUID$("{7EAE4030-B709-4AA8-AC55-E953829C9DAA}")
$GUID_BLUETOOTH_HCI_EVENT = GUID$("{FC240062-1541-49BE-B463-84C4DCD7BF7F}")
'//
'// Support added in KB942567
'//
'#if (NTDDI_VERSION > NTDDI_VISTASP1 || \
' (NTDDI_VERSION == NTDDI_VISTASP1 && defined(VISTA_KB942567)))
$GUID_BLUETOOTH_AUTHENTICATION_REQUEST = GUID$("{5DC9136D-996C-46DB-84F5-32C0A3F47352}")
$GUID_BLUETOOTH_KEYPRESS_EVENT = GUID$("{D668DFCD-0F4E-4EFC-BFE0-392EEEC5109C}")
$GUID_BLUETOOTH_HCI_VENDOR_EVENT = GUID$("{547247E6-45BB-4C33-AF8C-C00EFE15A71D}")
'#endif // >= SP1+KB942567
'//
'// Bluetooth base UUID for service discovery
'//
$Bluetooth_Base_UUID = GUID$("{00000000-0000-1000-8000-00805F9B34FB}")
'//
'// UUID for the root of the browse group list
'//
$SDP_PROTOCOL_UUID = GUID$("{00000001-0000-1000-8000-00805F9B34FB}")
$UDP_PROTOCOL_UUID = GUID$("{00000002-0000-1000-8000-00805F9B34FB}")
$RFCOMM_PROTOCOL_UUID = GUID$("{00000003-0000-1000-8000-00805F9B34FB}")
$TCP_PROTOCOL_UUID = GUID$("{00000004-0000-1000-8000-00805F9B34FB}")
$TCSBIN_PROTOCOL_UUID = GUID$("{00000005-0000-1000-8000-00805F9B34FB}")
$TCSAT_PROTOCOL_UUID = GUID$("{00000006-0000-1000-8000-00805F9B34FB}")
$OBEX_PROTOCOL_UUID = GUID$("{00000008-0000-1000-8000-00805F9B34FB}")
$IP_PROTOCOL_UUID = GUID$("{00000009-0000-1000-8000-00805F9B34FB}")
$FTP_PROTOCOL_UUID = GUID$("{0000000A-0000-1000-8000-00805F9B34FB}")
$HTTP_PROTOCOL_UUID = GUID$("{0000000C-0000-1000-8000-00805F9B34FB}")
$WSP_PROTOCOL_UUID = GUID$("{0000000E-0000-1000-8000-00805F9B34FB}")
$UPNP_PROTOCOL_UUID = GUID$("{00000010-0000-1000-8000-00805F9B34FB}")
$HID_PROTOCOL_UUID = GUID$("{00000011-0000-1000-8000-00805F9B34FB}")
$HCCC_PROTOCOL_UUID = GUID$("{00000012-0000-1000-8000-00805F9B34FB}")
$HCDC_PROTOCOL_UUID = GUID$("{00000014-0000-1000-8000-00805F9B34FB}")
$HN_PROTOCOL_UUID = GUID$("{00000016-0000-1000-8000-00805F9B34FB}")
$AVCTP_PROTOCOL_UUID = GUID$("{00000017-0000-1000-8000-00805F9B34FB}")
$AVDTP_PROTOCOL_UUID = GUID$("{00000019-0000-1000-8000-00805F9B34FB}")
$CMPT_PROTOCOL_UUID = GUID$("{0000001B-0000-1000-8000-00805F9B34FB}")
$UDI_C_PLANE_PROTOCOL_UUID = GUID$("{0000001D-0000-1000-8000-00805F9B34FB}")
$L2CAP_PROTOCOL_UUID = GUID$("{00000100-0000-1000-8000-00805F9B34FB}")
%EQUATE `SDP_PROTOCOL_UUID16 = &H0001
%EQUATE `UDP_PROTOCOL_UUID16 = &H0002
%EQUATE `RFCOMM_PROTOCOL_UUID16 = &H0003
%EQUATE `TCP_PROTOCOL_UUID16 = &H0004
%EQUATE `TCSBIN_PROTOCOL_UUID16 = &H0005
%EQUATE `TCSAT_PROTOCOL_UUID16 = &H0006
%EQUATE `OBEX_PROTOCOL_UUID16 = &H0008
%EQUATE `IP_PROTOCOL_UUID16 = &H0009
%EQUATE `FTP_PROTOCOL_UUID16 = &H000A
%EQUATE `HTTP_PROTOCOL_UUID16 = &H000C
%EQUATE `WSP_PROTOCOL_UUID16 = &H000E
%EQUATE `BNEP_PROTOCOL_UUID16 = &H000F
%EQUATE `UPNP_PROTOCOL_UUID16 = &H0010
%EQUATE `HID_PROTOCOL_UUID16 = &H0011
%EQUATE `HCCC_PROTOCOL_UUID16 = &H0012
%EQUATE `HCDC_PROTOCOL_UUID16 = &H0014
%EQUATE `HCN_PROTOCOL_UUID16 = &H0016
%EQUATE `AVCTP_PROTOCOL_UUID16 = &H0017
%EQUATE `AVDTP_PROTOCOL_UUID16 = &H0019
%EQUATE `CMPT_PROTOCOL_UUID16 = &H001B
%EQUATE `UDI_C_PLANE_PROTOCOL_UUID16 = &H001D
%EQUATE `L2CAP_PROTOCOL_UUID16 = &H0100
$ServiceDiscoveryServerServiceClassID_UUID = GUID$("{00001001-0000-1000-8000-00805F9B34FB}")
$PublicBrowseGroupServiceClass_UUID = GUID$("{00001002-0000-1000-8000-00805F9B34FB}")
$SerialPortServiceClass_UUID = GUID$("{00001101-0000-1000-8000-00805F9B34FB}")
$LANAccessUsingPPPServiceClass_UUID = GUID$("{00001102-0000-1000-8000-00805F9B34FB}")
$DialupNetworkingServiceClass_UUID = GUID$("{00001103-0000-1000-8000-00805F9B34FB}")
$IrMCSyncServiceClass_UUID = GUID$("{00001104-0000-1000-8000-00805F9B34FB}")
$OBEXObjectPushServiceClass_UUID = GUID$("{00001105-0000-1000-8000-00805F9B34FB}")
$OBEXFileTransferServiceClass_UUID = GUID$("{00001106-0000-1000-8000-00805F9B34FB}")
$IrMCSyncCommandServiceClass_UUID = GUID$("{00001107-0000-1000-8000-00805F9B34FB}")
$HeadsetServiceClass_UUID = GUID$("{00001108-0000-1000-8000-00805F9B34FB}")
$CordlessTelephonyServiceClass_UUID = GUID$("{00001109-0000-1000-8000-00805F9B34FB}")
$AudioSourceServiceClass_UUID = GUID$("{0000110A-0000-1000-8000-00805F9B34FB}")
$AudioSinkServiceClass_UUID = GUID$("{0000110B-0000-1000-8000-00805F9B34FB}")
$AVRemoteControlTargetServiceClass_UUID = GUID$("{0000110C-0000-1000-8000-00805F9B34FB}")
$AdvancedAudioDistributionServiceClass_UUID = GUID$("{0000110D-0000-1000-8000-00805F9B34FB}")
$AVRemoteControlServiceClass_UUID = GUID$("{0000110E-0000-1000-8000-00805F9B34FB}")
'$VideoConferencingServiceClass_UUID = GUID$("{0000110F-0000-1000-8000-00805F9B34FB}") ' // Name changed to AVRemoteControlControllerServiceClass_UUID in Windows 7 SDK
$AVRemoteControlControllerServiceClass_UUID = GUID$("{0000110F-0000-1000-8000-00805F9B34FB}")
$IntercomServiceClass_UUID = GUID$("{00001110-0000-1000-8000-00805F9B34FB}")
$FaxServiceClass_UUID = GUID$("{00001111-0000-1000-8000-00805F9B34FB}")
$HeadsetAudioGatewayServiceClass_UUID = GUID$("{00001112-0000-1000-8000-00805F9B34FB}")
$WAPServiceClass_UUID = GUID$("{00001113-0000-1000-8000-00805F9B34FB}")
$WAPClientServiceClass_UUID = GUID$("{00001114-0000-1000-8000-00805F9B34FB}")
$PANUServiceClass_UUID = GUID$("{00001115-0000-1000-8000-00805F9B34FB}")
$NAPServiceClass_UUID = GUID$("{00001116-0000-1000-8000-00805F9B34FB}")
$GNServiceClass_UUID = GUID$("{00001117-0000-1000-8000-00805F9B34FB}")
$DirectPrintingServiceClass_UUID = GUID$("{00001118-0000-1000-8000-00805F9B34FB}")
$ReferencePrintingServiceClass_UUID = GUID$("{00001119-0000-1000-8000-00805F9B34FB}")
$ImagingServiceClass_UUID = GUID$("{0000111A-0000-1000-8000-00805F9B34FB}")
$ImagingResponderServiceClass_UUID = GUID$("{0000111B-0000-1000-8000-00805F9B34FB}")
$ImagingAutomaticArchiveServiceClass_UUID = GUID$("{0000111C-0000-1000-8000-00805F9B34FB}")
$ImagingReferenceObjectsServiceClass_UUID = GUID$("{0000111D-0000-1000-8000-00805F9B34FB}")
$HandsfreeServiceClass_UUID = GUID$("{0000111E-0000-1000-8000-00805F9B34FB}")
$HandsfreeAudioGatewayServiceClass_UUID = GUID$("{0000111F-0000-1000-8000-00805F9B34FB}")
$DirectPrintingReferenceObjectsServiceClass_UUID = GUID$("{00001120-0000-1000-8000-00805F9B34FB}")
$ReflectedUIServiceClass_UUID = GUID$("{00001121-0000-1000-8000-00805F9B34FB}")
$BasicPringingServiceClass_UUID = GUID$("{00001122-0000-1000-8000-00805F9B34FB}")
$PrintingStatusServiceClass_UUID = GUID$("{00001123-0000-1000-8000-00805F9B34FB}")
$HumanInterfaceDeviceServiceClass_UUID = GUID$("{00001124-0000-1000-8000-00805F9B34FB}")
$HardcopyCableReplacementServiceClass_UUID = GUID$("{00001125-0000-1000-8000-00805F9B34FB}")
$HCRPrintServiceClass_UUID = GUID$("{00001126-0000-1000-8000-00805F9B34FB}")
$HCRScanServiceClass_UUID = GUID$("{00001127-0000-1000-8000-00805F9B34FB}")
$CommonISDNAccessServiceClass_UUID = GUID$("{00001128-0000-1000-8000-00805F9B34FB}")
$VideoConferencingGWServiceClass_UUID = GUID$("{00001129-0000-1000-8000-00805F9B34FB}")
$UDIMTServiceClass_UUID = GUID$("{0000112A-0000-1000-8000-00805F9B34FB}")
$UDITAServiceClass_UUID = GUID$("{0000112B-0000-1000-8000-00805F9B34FB}")
$AudioVideoServiceClass_UUID = GUID$("{0000112C-0000-1000-8000-00805F9B34FB}")
$SimAccessServiceClass_UUID = GUID$("{0000112D-0000-1000-8000-00805F9B34FB}")
$PhonebookAccessPceServiceClass_UUID = GUID$("{0000112E-0000-1000-8000-00805F9B34FB}")
$PhonebookAccessPseServiceClass_UUID = GUID$("{0000112F-0000-1000-8000-00805F9B34FB}")
$PnPInformationServiceClass_UUID = GUID$("{00001200-0000-1000-8000-00805F9B34FB}")
$GenericNetworkingServiceClass_UUID = GUID$("{00001201-0000-1000-8000-00805F9B34FB}")
$GenericFileTransferServiceClass_UUID = GUID$("{00001202-0000-1000-8000-00805F9B34FB}")
$GenericAudioServiceClass_UUID = GUID$("{00001203-0000-1000-8000-00805F9B34FB}")
$GenericTelephonyServiceClass_UUID = GUID$("{00001204-0000-1000-8000-00805F9B34FB}")
$UPnpServiceClass_UUID = GUID$("{00001205-0000-1000-8000-00805F9B34FB}")
$UPnpIpServiceClass_UUID = GUID$("{00001206-0000-1000-8000-00805F9B34FB}")
$ESdpUpnpIpPanServiceClass_UUID = GUID$("{00001300-0000-1000-8000-00805F9B34FB}")
$ESdpUpnpIpLapServiceClass_UUID = GUID$("{00001301-0000-1000-8000-00805F9B34FB}")
$ESdpUpnpL2capServiceClass_UUID = GUID$("{00001302-0000-1000-8000-00805F9B34FB}")
$VideoSourceServiceClass_UUID = GUID$("{00001303-0000-1000-8000-00805F9B34FB}")
$VideoSinkServiceClass_UUID = GUID$("{00001304-0000-1000-8000-00805F9B34FB}")
$VideoDistributionServiceClass_UUID = GUID$("{00001305-0000-1000-8000-00805F9B34FB}")
%EQUATE `ServiceDiscoveryServerServiceClassID_UUID16 = &H1000
%EQUATE `BrowseGroupDescriptorServiceClassID_UUID16 = &H1001
%EQUATE `PublicBrowseGroupServiceClassID_UUID16 = &H1002
%EQUATE `SerialPortServiceClassID_UUID16 = &H1101
%EQUATE `LANAccessUsingPPPServiceClassID_UUID16 = &H1102
%EQUATE `DialupNetworkingServiceClassID_UUID16 = &H1103
%EQUATE `IrMCSyncServiceClassID_UUID16 = &H1104
%EQUATE `OBEXObjectPushServiceClassID_UUID16 = &H1105
%EQUATE `OBEXFileTransferServiceClassID_UUID16 = &H1106
%EQUATE `IrMcSyncCommandServiceClassID_UUID16 = &H1107
%EQUATE `HeadsetServiceClassID_UUID16 = &H1108
%EQUATE `CordlessServiceClassID_UUID16 = &H1109
%EQUATE `AudioSourceServiceClassID_UUID16 = &H110A
%EQUATE `AudioSinkSourceServiceClassID_UUID16 = &H110B
%EQUATE `AVRemoteControlTargetServiceClassID_UUID16 = &H110C
%EQUATE `AdvancedAudioDistributionServiceClassID_UUID16 = &H110D
%EQUATE `AVRemoteControlServiceClassID_UUID16 = &H110E
'%VideoConferencingServiceClassID_UUID16 = &H110F ' // Name changed to AVRemoteControlControllerServiceClass_UUID16 in Windows 7 SDK
%EQUATE `AVRemoteControlControllerServiceClass_UUID16 = &H110F
%EQUATE `IntercomServiceClassID_UUID16 = &H1110
%EQUATE `FaxServiceClassID_UUID16 = &H1111
%EQUATE `HeadsetAudioGatewayServiceClassID_UUID16 = &H1112
%EQUATE `WAPServiceClassID_UUID16 = &H1113
%EQUATE `WAPClientServiceClassID_UUID16 = &H1114
%EQUATE `PANUServiceClassID_UUID16 = &H1115
%EQUATE `NAPServiceClassID_UUID16 = &H1116
%EQUATE `GNServiceClassID_UUID16 = &H1117
%EQUATE `DirectPrintingServiceClassID_UUID16 = &H1118
%EQUATE `ReferencePrintingServiceClassID_UUID16 = &H1119
%EQUATE `ImagingServiceClassID_UUID16 = &H111A
%EQUATE `ImagingResponderServiceClassID_UUID16 = &H111B
%EQUATE `ImagingAutomaticArchiveServiceClassID_UUID16 = &H111C
%EQUATE `ImagingReferenceObjectsServiceClassID_UUID16 = &H111D
%EQUATE `HandsfreeServiceClassID_UUID16 = &H111E
%EQUATE `HandsfreeAudioGatewayServiceClassID_UUID16 = &H111F
%EQUATE `DirectPrintingReferenceObjectsServiceClassID_UUID16 = &H1120
%EQUATE `ReflectsUIServiceClassID_UUID16 = &H1121
%EQUATE `BasicPrintingServiceClassID_UUID16 = &H1122
%EQUATE `PrintingStatusServiceClassID_UUID16 = &H1123
%EQUATE `HumanInterfaceDeviceServiceClassID_UUID16 = &H1124
%EQUATE `HardcopyCableReplacementServiceClassID_UUID16 = &H1125
%EQUATE `HCRPrintServiceClassID_UUID16 = &H1126
%EQUATE `HCRScanServiceClassID_UUID16 = &H1127
%EQUATE `CommonISDNAccessServiceClass_UUID16 = &H1128
%EQUATE `VideoConferencingGWServiceClass_UUID16 = &H1129
%EQUATE `UDIMTServiceClass_UUID16 = &H112A
%EQUATE `UDITAServiceClass_UUID16 = &H112B
%EQUATE `AudioVideoServiceClass_UUID16 = &H112C
%EQUATE `PnPInformationServiceClassID_UUID16 = &H1200
%EQUATE `GenericNetworkingServiceClassID_UUID16 = &H1201
%EQUATE `GenericFileTransferServiceClassID_UUID16 = &H1202
%EQUATE `GenericAudioServiceClassID_UUID16 = &H1203
%EQUATE `GenericTelephonyServiceClassID_UUID16 = &H1204
'//
'// The SIG renamed the uuid for VideoConferencingServiceClass
'//
$VideoConferencingServiceClass_UUID = $AVRemoteControlControllerServiceClass_UUID
%EQUATE `VideoConferencingServiceClassID_UUID16 = %AVRemoteControlControllerServiceClass_UUID16
#ENDIF ' // NO_GUID_DEFS
#IF NOT %DEF(%GUID_DEFS_ONLY)
'//
'// max length of device friendly name.
'//
%EQUATE `BTH_MAX_NAME_SIZE = 248
%EQUATE `BTH_MAX_PIN_SIZE = 16
%EQUATE `BTH_LINK_KEY_LENGTH = 16
%EQUATE `BTH_MFG_ERICSSON = 0
%EQUATE `BTH_MFG_NOKIA = 1
%EQUATE `BTH_MFG_INTEL = 2
%EQUATE `BTH_MFG_IBM = 3
%EQUATE `BTH_MFG_TOSHIBA = 4
%EQUATE `BTH_MFG_3COM = 5
%EQUATE `BTH_MFG_MICROSOFT = 6
%EQUATE `BTH_MFG_LUCENT = 7
%EQUATE `BTH_MFG_MOTOROLA = 8
%EQUATE `BTH_MFG_INFINEON = 9
%EQUATE `BTH_MFG_CSR = 10
%EQUATE `BTH_MFG_SILICONWAVE = 11
%EQUATE `BTH_MFG_DIGIANSWER = 12
%EQUATE `BTH_MFG_TI = 13
%EQUATE `BTH_MFG_PARTHUS = 14
%EQUATE `BTH_MFG_BROADCOM = 15
%EQUATE `BTH_MFG_MITEL = 16
%EQUATE `BTH_MFG_WIDCOMM = 17
%EQUATE `BTH_MFG_ZEEVO = 18
%EQUATE `BTH_MFG_ATMEL = 19
%EQUATE `BTH_MFG_MITSIBUSHI = 20
%EQUATE `BTH_MFG_RTX_TELECOM = 21
%EQUATE `BTH_MFG_KC_TECHNOLOGY = 22
%EQUATE `BTH_MFG_NEWLOGIC = 23
%EQUATE `BTH_MFG_TRANSILICA = 24
%EQUATE `BTH_MFG_ROHDE_SCHWARZ = 25
%EQUATE `BTH_MFG_TTPCOM = 26
%EQUATE `BTH_MFG_SIGNIA = 27
%EQUATE `BTH_MFG_CONEXANT = 28
%EQUATE `BTH_MFG_QUALCOMM = 29
%EQUATE `BTH_MFG_INVENTEL = 30
%EQUATE `BTH_MFG_AVM_BERLIN = 31
%EQUATE `BTH_MFG_BANDSPEED = 32
%EQUATE `BTH_MFG_MANSELLA = 33
%EQUATE `BTH_MFG_NEC = 34
%EQUATE `BTH_MFG_WAVEPLUS_TECHNOLOGY_CO = 35
%EQUATE `BTH_MFG_ALCATEL = 36
%EQUATE `BTH_MFG_PHILIPS_SEMICONDUCTOR = 37
%EQUATE `BTH_MFG_C_TECHNOLOGIES = 38
%EQUATE `BTH_MFG_OPEN_INTERFACE = 39
%EQUATE `BTH_MFG_RF_MICRO_DEVICES = 40
%EQUATE `BTH_MFG_HITACHI = 41
%EQUATE `BTH_MFG_SYMBOL_TECHNOLOGIES = 42
%EQUATE `BTH_MFG_TENOVIS = 43
%EQUATE `BTH_MFG_MACRONIX_INTERNATIONAL = 44
%EQUATE `BTH_MFG_INTERNAL_USE = 65535
'typedef ULONGLONG BTH_ADDR, *PBTH_ADDR;
'typedef ULONG BTH_COD, *PBTH_COD;
'typedef ULONG BTH_LAP, *PBTH_LAP;
%EQUATE `BTH_ADDR_NULL = &H0000000000000000&& ' ULONGLONG
%EQUATE `NAP_MASK = &HFFFF00000000&& ' ULONGLONG
%EQUATE `SAP_MASK = &H0000FFFFFFFF&& ' ULONGLONG
%EQUATE `NAP_BIT_OFFSET = 8 * 4
%EQUATE `SAP_BIT_OFFSET = 0
'#define GET_NAP(_bth_addr) ((USHORT) (((_bth_addr) & NAP_MASK) >> NAP_BIT_OFFSET))
FUNCTION GET_NAP (BYVAL bth_addr_ AS QUAD) AS WORD
 LOCAL qtmp AS QUAD
 qtmp = bth_addr_ AND %NAP_MASK
 SHIFT RIGHT qtmp, %NAP_BIT_OFFSET
 FUNCTION = qtmp
END FUNCTION
'#define GET_SAP(_bth_addr) ((ULONG) (((_bth_addr) & SAP_MASK) >> SAP_BIT_OFFSET))
FUNCTION GET_SAP (BYVAL bth_addr_ AS QUAD) AS DWORD
 LOCAL qtmp AS QUAD
 qtmp = bth_addr_ AND %SAP_MASK
 SHIFT RIGHT qtmp, %SAP_BIT_OFFSET
 FUNCTION = qtmp
END FUNCTION
'#define SET_NAP(_nap) (((ULONGLONG) ((USHORT) (_nap))) << NAP_BIT_OFFSET)
FUNCTION SET_NAP (BYVAL nap_ AS QUAD) AS QUAD
 SHIFT LEFT nap_, %NAP_BIT_OFFSET
 FUNCTION = nap_
END FUNCTION
'#define SET_SAP(_sap) (((ULONGLONG) ((ULONG) (_sap))) << SAP_BIT_OFFSET)
FUNCTION SET_SAP (BYVAL sap_ AS QUAD) AS QUAD
 SHIFT LEFT sap_, %SAP_BIT_OFFSET
 FUNCTION = sap_
END FUNCTION
'#define SET_NAP_SAP(_nap, _sap) (SET_NAP(_nap) | SET_SAP(_sap))
FUNCTION SET_NAP_SAP (BYVAL nap_ AS QUAD, BYVAL sap_ AS QUAD) AS QUAD
 FUNCTION = SET_NAP(nap_) OR SET_SAP(sap_)
END FUNCTION
%EQUATE `COD_FORMAT_BIT_OFFSET = 0
%EQUATE `COD_MINOR_BIT_OFFSET = 2
%EQUATE `COD_MAJOR_BIT_OFFSET = 8 * 1
%EQUATE `COD_SERVICE_BIT_OFFSET = 8 * 1 + 5
%EQUATE `COD_FORMAT_MASK = &H000003
%EQUATE `COD_MINOR_MASK = &H0000FC
%EQUATE `COD_MAJOR_MASK = &H001F00
%EQUATE `COD_SERVICE_MASK = &HFFE000
'#define GET_COD_FORMAT(_cod) ( (_cod) & COD_FORMAT_MASK >> COD_FORMAT_BIT_OFFSET)
FUNCTION GET_COD_FORMAT (BYVAL cod_ AS DWORD) AS DWORD
 LOCAL dwtmp AS DWORD
 dwtmp = cod_ AND %COD_FORMAT_MASK
 SHIFT RIGHT dwtmp, %COD_FORMAT_BIT_OFFSET
 FUNCTION = dwtmp
END FUNCTION
'#define GET_COD_MINOR(_cod) (((_cod) & COD_MINOR_MASK) >> COD_MINOR_BIT_OFFSET)
FUNCTION GET_COD_MINOR (BYVAL cod_ AS DWORD) AS DWORD
 LOCAL dwtmp AS DWORD
 dwtmp = cod_ AND %COD_MINOR_MASK
 SHIFT RIGHT dwtmp, %COD_MINOR_BIT_OFFSET
 FUNCTION = dwtmp
END FUNCTION
'#define GET_COD_MAJOR(_cod) (((_cod) & COD_MAJOR_MASK) >> COD_MAJOR_BIT_OFFSET)
FUNCTION GET_COD_MAJOR (BYVAL cod_ AS DWORD) AS DWORD
 LOCAL dwtmp AS DWORD
 dwtmp = cod_ AND %COD_MAJOR_MASK
 SHIFT RIGHT dwtmp, %COD_MAJOR_BIT_OFFSET
 FUNCTION = dwtmp
END FUNCTION
'#define GET_COD_SERVICE(_cod) (((_cod) & COD_SERVICE_MASK) >> COD_SERVICE_BIT_OFFSET)
FUNCTION GET_COD_SERVICE (BYVAL cod_ AS DWORD) AS DWORD
 LOCAL dwtmp AS DWORD
 dwtmp = cod_ AND %COD_SERVICE_MASK
 SHIFT RIGHT dwtmp, %COD_SERVICE_BIT_OFFSET
 FUNCTION = dwtmp
END FUNCTION
'#define SET_COD_MINOR(_cod, _minor) (_cod) = ((_cod) & ~COD_MINOR_MASK) | ((_minor) << COD_MINOR_BIT_OFFSET)
FUNCTION SET_COD_MINOR (BYVAL cod_ AS DWORD, BYVAL minor_ AS DWORD) AS DWORD
 cod_ = (cod_ AND NOT %COD_MINOR_MASK)
 SHIFT LEFT minor_, %COD_MINOR_BIT_OFFSET
 FUNCTION = cod_ OR minor_
END FUNCTION
'#define SET_COD_MAJOR(_cod, _major) (_cod) = ((_cod) & ~COD_MAJOR_MASK) | ((_major) << COD_MAJOR_BIT_OFFSET)
FUNCTION SET_COD_MAJOR (BYVAL cod_ AS DWORD, BYVAL major_ AS DWORD) AS DWORD
 cod_ = (cod_ AND NOT %COD_MAJOR_MASK)
 SHIFT LEFT major_, %COD_MAJOR_BIT_OFFSET
 FUNCTION = cod_ OR major_
END FUNCTION
'#define SET_COD_SERVICE(_cod, _service) (_cod) = ((_cod) & ~COD_SERVICE_MASK) | ((_service) << COD_SERVICE_BIT_OFFSET)
FUNCTION SET_COD_SERVICE (BYVAL cod_ AS DWORD, BYVAL service_ AS DWORD) AS DWORD
 cod_ = (cod_ AND NOT %COD_SERVICE_MASK)
 SHIFT LEFT service_, %COD_SERVICE_BIT_OFFSET
 FUNCTION = cod_ OR service_
END FUNCTION
%EQUATE `COD_VERSION = &H0
%EQUATE `COD_SERVICE_LIMITED = &H0001
%EQUATE `COD_SERVICE_POSITIONING = &H0008
%EQUATE `COD_SERVICE_NETWORKING = &H0010
%EQUATE `COD_SERVICE_RENDERING = &H0020
%EQUATE `COD_SERVICE_CAPTURING = &H0040
%EQUATE `COD_SERVICE_OBJECT_XFER = &H0080
%EQUATE `COD_SERVICE_AUDIO = &H0100
%EQUATE `COD_SERVICE_TELEPHONY = &H0200
%EQUATE `COD_SERVICE_INFORMATION = &H0400
%EQUATE `COD_SERVICE_VALID_MASK = %COD_SERVICE_LIMITED OR %COD_SERVICE_POSITIONING OR %COD_SERVICE_NETWORKING OR %COD_SERVICE_RENDERING OR %COD_SERVICE_CAPTURING OR %COD_SERVICE_OBJECT_XFER OR %COD_SERVICE_AUDIO OR %COD_SERVICE_TELEPHONY OR %COD_SERVICE_INFORMATION
%EQUATE `OD_SERVICE_MAX_COUNT = 9
'//
'// Major class codes
'//
%EQUATE `COD_MAJOR_MISCELLANEOUS = &H00
%EQUATE `COD_MAJOR_COMPUTER = &H01
%EQUATE `COD_MAJOR_PHONE = &H02
%EQUATE `COD_MAJOR_LAN_ACCESS = &H03
%EQUATE `COD_MAJOR_AUDIO = &H04
%EQUATE `COD_MAJOR_PERIPHERAL = &H05
%EQUATE `COD_MAJOR_IMAGING = &H06
%EQUATE `COD_MAJOR_UNCLASSIFIED = &H1F
'//
'// Minor class codes specific to each major class
'//
%EQUATE `COD_COMPUTER_MINOR_UNCLASSIFIED = &H00
%EQUATE `COD_COMPUTER_MINOR_DESKTOP = &H01
%EQUATE `COD_COMPUTER_MINOR_SERVER = &H02
%EQUATE `COD_COMPUTER_MINOR_LAPTOP = &H03
%EQUATE `COD_COMPUTER_MINOR_HANDHELD = &H04
%EQUATE `COD_COMPUTER_MINOR_PALM = &H05
%EQUATE `COD_COMPUTER_MINOR_WEARABLE = &H06
%EQUATE `COD_PHONE_MINOR_UNCLASSIFIED = &H00
%EQUATE `COD_PHONE_MINOR_CELLULAR = &H01
%EQUATE `COD_PHONE_MINOR_CORDLESS = &H02
%EQUATE `COD_PHONE_MINOR_SMART = &H03
%EQUATE `COD_PHONE_MINOR_WIRED_MODEM = &H04
%EQUATE `COD_AUDIO_MINOR_UNCLASSIFIED = &H00
%EQUATE `COD_AUDIO_MINOR_HEADSET = &H01
%EQUATE `COD_AUDIO_MINOR_HANDS_FREE = &H02
%EQUATE `COD_AUDIO_MINOR_HEADSET_HANDS_FREE = &H03
%EQUATE `COD_AUDIO_MINOR_MICROPHONE = &H04
%EQUATE `COD_AUDIO_MINOR_LOUDSPEAKER = &H05
%EQUATE `COD_AUDIO_MINOR_HEADPHONES = &H06
%EQUATE `COD_AUDIO_MINOR_PORTABLE_AUDIO = &H07
%EQUATE `COD_AUDIO_MINOR_CAR_AUDIO = &H08
%EQUATE `COD_AUDIO_MINOR_SET_TOP_BOX = &H09
%EQUATE `COD_AUDIO_MINOR_HIFI_AUDIO = &H0A
%EQUATE `COD_AUDIO_MINOR_VCR = &H0B
%EQUATE `COD_AUDIO_MINOR_VIDEO_CAMERA = &H0C
%EQUATE `COD_AUDIO_MINOR_CAMCORDER = &H0D
%EQUATE `COD_AUDIO_MINOR_VIDEO_MONITOR = &H0E
%EQUATE `COD_AUDIO_MINOR_VIDEO_DISPLAY_LOUDSPEAKER = &H0F
%EQUATE `COD_AUDIO_MINOR_VIDEO_DISPLAY_CONFERENCING = &H10
'// %COD_AUDIO_MINOR_RESERVED = &H11
%EQUATE `COD_AUDIO_MINOR_GAMING_TOY = &H12
%EQUATE `COD_PERIPHERAL_MINOR_KEYBOARD_MASK = &H10
%EQUATE `COD_PERIPHERAL_MINOR_POINTER_MASK = &H20
%EQUATE `COD_PERIPHERAL_MINOR_NO_CATEGORY = &H00
%EQUATE `COD_PERIPHERAL_MINOR_JOYSTICK = &H01
%EQUATE `COD_PERIPHERAL_MINOR_GAMEPAD = &H02
%EQUATE `COD_PERIPHERAL_MINOR_REMOTE_CONTROL = &H03
%EQUATE `COD_PERIPHERAL_MINOR_SENSING = &H04
%EQUATE `COD_IMAGING_MINOR_DISPLAY_MASK = &H04
%EQUATE `COD_IMAGING_MINOR_CAMERA_MASK = &H08
%EQUATE `COD_IMAGING_MINOR_SCANNER_MASK = &H10
%EQUATE `COD_IMAGING_MINOR_PRINTER_MASK = &H20
'//
'// Cannot use GET_COD_MINOR for this b/c it is embedded in a different manner
'// than the rest of the major classes
'//
%EQUATE `COD_LAN_ACCESS_BIT_OFFSET = 5
%EQUATE `COD_LAN_MINOR_MASK = &H00001C
%EQUATE `COD_LAN_ACCESS_MASK = &H0000E0
'#define GET_COD_LAN_MINOR(_cod) (((_cod) & COD_LAN_MINOR_MASK) >> COD_MINOR_BIT_OFFSET)
FUNCTION GET_COD_LAN_MINOR (BYVAL cod_ AS DWORD) AS DWORD
 cod_ = (cod_ AND %COD_LAN_MINOR_MASK)
 SHIFT RIGHT cod_, %COD_MINOR_BIT_OFFSET
 FUNCTION = cod_
END FUNCTION
'#define GET_COD_LAN_ACCESS(_cod) (((_cod) & COD_LAN_ACCESS_MASK) >> COD_LAN_ACCESS_BIT_OFFSET)
FUNCTION GET_COD_LAN_ACCESS (BYVAL cod_ AS DWORD) AS DWORD
 cod_ = (cod_ AND %COD_LAN_ACCESS_MASK)
 SHIFT RIGHT cod_, %COD_LAN_ACCESS_BIT_OFFSET
 FUNCTION = cod_
END FUNCTION
'//
'// LAN access percent usage subcodes
'//
%EQUATE `COD_LAN_MINOR_UNCLASSIFIED = &H00
%EQUATE `COD_LAN_ACCESS_0_USED = &H00
%EQUATE `COD_LAN_ACCESS_17_USED = &H01
%EQUATE `COD_LAN_ACCESS_33_USED = &H02
%EQUATE `COD_LAN_ACCESS_50_USED = &H03
%EQUATE `COD_LAN_ACCESS_67_USED = &H04
%EQUATE `COD_LAN_ACCESS_83_USED = &H05
%EQUATE `COD_LAN_ACCESS_99_USED = &H06
%EQUATE `COD_LAN_ACCESS_FULL = &H07
'//
'// Extended Inquiry Response (EIR) defines.
'//
%EQUATE `BTH_EIR_FLAGS_ID = &H01
%EQUATE `BTH_EIR_16_UUIDS_PARTIAL_ID = &H02
%EQUATE `BTH_EIR_16_UUIDS_COMPLETE_ID = &H03
%EQUATE `BTH_EIR_32_UUIDS_PARTIAL_ID = &H04
%EQUATE `BTH_EIR_32_UUIDS_COMPLETE_ID = &H05
%EQUATE `BTH_EIR_128_UUIDS_PARTIAL_ID = &H06
%EQUATE `BTH_EIR_128_UUIDS_COMPLETE_ID = &H07
%EQUATE `BTH_EIR_LOCAL_NAME_PARTIAL_ID = &H08
%EQUATE `BTH_EIR_LOCAL_NAME_COMPLETE_ID = &H09
%EQUATE `BTH_EIR_TX_POWER_LEVEL_ID = &H0A
%EQUATE `BTH_EIR_OOB_OPT_DATA_LEN_ID = &H0B ' // OOB only.
%EQUATE `BTH_EIR_OOB_BD_ADDR_ID = &H0C ' // OOB only.
%EQUATE `BTH_EIR_OOB_COD_ID = &H0D ' // OOB only.
%EQUATE `BTH_EIR_OOB_SP_HASH_ID = &H0E ' // OOB only.
%EQUATE `BTH_EIR_OOB_SP_RANDOMIZER_ID = &H0F ' // OOB only.
%EQUATE `BTH_EIR_MANUFACTURER_ID = &HFF
'//
'// Extended Inquiry Response (EIR) size.
'//
%EQUATE `BTH_EIR_SIZE = 240
'//
'// Used as an initializer of LAP_DATA
'//
MACRO LAP_GIAC_INIT = &H33, &H8B, &H9E ' { 0x33, 0x8B, 0x9E }
MACRO LAP_LIAC_INIT = &H00, &H8B, &H9E ' { 0x00, 0x8B, 0x9E }
'//
'// General Inquiry Access Code.
'//
%EQUATE `LAP_GIAC_VALUE = &H009E8B33
'//
'// Limited Inquiry Access Code.
'//
%EQUATE `LAP_LIAC_VALUE = &H009E8B00
%EQUATE `BTH_ADDR_IAC_FIRST = &H9E8B00
%EQUATE `BTH_ADDR_IAC_LAST = &H9E8B3f
%EQUATE `BTH_ADDR_LIAC = &H9E8B00
%EQUATE `BTH_ADDR_GIAC = &H9E8B33
'typedef UCHAR BTHSTATUS, *PBTHSTATUS;
MACRO BTH_ERROR(btStatus_) = (btStatus_ <> %BTH_ERROR_SUCCESS)
MACRO BTH_SUCCESS(btStatus_) = (btStatus_ = %BTH_ERROR_SUCCESS)
%EQUATE `BTH_ERROR_SUCCESS = &H00
%EQUATE `BTH_ERROR_UNKNOWN_HCI_COMMAND = &H01
%EQUATE `BTH_ERROR_NO_CONNECTION = &H02
%EQUATE `BTH_ERROR_HARDWARE_FAILURE = &H03
%EQUATE `BTH_ERROR_PAGE_TIMEOUT = &H04
%EQUATE `BTH_ERROR_AUTHENTICATION_FAILURE = &H05
%EQUATE `BTH_ERROR_KEY_MISSING = &H06
%EQUATE `BTH_ERROR_MEMORY_FULL = &H07
%EQUATE `BTH_ERROR_CONNECTION_TIMEOUT = &H08
%EQUATE `BTH_ERROR_MAX_NUMBER_OF_CONNECTIONS = &H09
%EQUATE `BTH_ERROR_MAX_NUMBER_OF_SCO_CONNECTIONS = &H0a
%EQUATE `BTH_ERROR_ACL_CONNECTION_ALREADY_EXISTS = &H0b
%EQUATE `BTH_ERROR_COMMAND_DISALLOWED = &H0c
%EQUATE `BTH_ERROR_HOST_REJECTED_LIMITED_RESOURCES = &H0d
%EQUATE `BTH_ERROR_HOST_REJECTED_SECURITY_REASONS = &H0e
%EQUATE `BTH_ERROR_HOST_REJECTED_PERSONAL_DEVICE = &H0f
%EQUATE `BTH_ERROR_HOST_TIMEOUT = &H10
%EQUATE `BTH_ERROR_UNSUPPORTED_FEATURE_OR_PARAMETER = &H11
%EQUATE `BTH_ERROR_INVALID_HCI_PARAMETER = &H12
%EQUATE `BTH_ERROR_REMOTE_USER_ENDED_CONNECTION = &H13
%EQUATE `BTH_ERROR_REMOTE_LOW_RESOURCES = &H14
%EQUATE `BTH_ERROR_REMOTE_POWERING_OFF = &H15
%EQUATE `BTH_ERROR_LOCAL_HOST_TERMINATED_CONNECTION = &H16
%EQUATE `BTH_ERROR_REPEATED_ATTEMPTS = &H17
%EQUATE `BTH_ERROR_PAIRING_NOT_ALLOWED = &H18
%EQUATE `BTH_ERROR_UKNOWN_LMP_PDU = &H19
%EQUATE `BTH_ERROR_UNSUPPORTED_REMOTE_FEATURE = &H1a
%EQUATE `BTH_ERROR_SCO_OFFSET_REJECTED = &H1b
%EQUATE `BTH_ERROR_SCO_INTERVAL_REJECTED = &H1c
%EQUATE `BTH_ERROR_SCO_AIRMODE_REJECTED = &H1d
%EQUATE `BTH_ERROR_INVALID_LMP_PARAMETERS = &H1e
%EQUATE `BTH_ERROR_UNSPECIFIED_ERROR = &H1f
%EQUATE `BTH_ERROR_UNSUPPORTED_LMP_PARM_VALUE = &H20
%EQUATE `BTH_ERROR_ROLE_CHANGE_NOT_ALLOWED = &H21
%EQUATE `BTH_ERROR_LMP_RESPONSE_TIMEOUT = &H22
%EQUATE `BTH_ERROR_LMP_TRANSACTION_COLLISION = &H23
%EQUATE `BTH_ERROR_LMP_PDU_NOT_ALLOWED = &H24
%EQUATE `BTH_ERROR_ENCRYPTION_MODE_NOT_ACCEPTABLE = &H25
%EQUATE `BTH_ERROR_UNIT_KEY_NOT_USED = &H26
%EQUATE `BTH_ERROR_QOS_IS_NOT_SUPPORTED = &H27
%EQUATE `BTH_ERROR_INSTANT_PASSED = &H28
%EQUATE `BTH_ERROR_PAIRING_WITH_UNIT_KEY_NOT_SUPPORTED = &H29
%EQUATE `BTH_ERROR_DIFFERENT_TRANSACTION_COLLISION = &H2a
%EQUATE `BTH_ERROR_QOS_UNACCEPTABLE_PARAMETER = &H2c
%EQUATE `BTH_ERROR_QOS_REJECTED = &H2d
%EQUATE `BTH_ERROR_CHANNEL_CLASSIFICATION_NOT_SUPPORTED = &H2e
%EQUATE `BTH_ERROR_INSUFFICIENT_SECURITY = &H2f
%EQUATE `BTH_ERROR_PARAMETER_OUT_OF_MANDATORY_RANGE = &H30
%EQUATE `BTH_ERROR_ROLE_SWITCH_PENDING = &H32
%EQUATE `BTH_ERROR_RESERVED_SLOT_VIOLATION = &H34
%EQUATE `BTH_ERROR_ROLE_SWITCH_FAILED = &H35
%EQUATE `BTH_ERROR_EXTENDED_INQUIRY_RESPONSE_TOO_LARGE = &H36
%EQUATE `BTH_ERROR_SECURE_SIMPLE_PAIRING_NOT_SUPPORTED_BY_HOST = &H37
%EQUATE `BTH_ERROR_HOST_BUSY_PAIRING = &H38
%EQUATE `BTH_ERROR_UNSPECIFIED = &HFF
'//
'// Min, max, and default L2cap MTU.
'//
%EQUATE `L2CAP_MIN_MTU = 48
%EQUATE `L2CAP_MAX_MTU = &HFFFF
%EQUATE `L2CAP_DEFAULT_MTU = 672
'//
'// Max l2cap signal size (48 - size of signal header (4))
'//
%EQUATE `MAX_L2CAP_PING_DATA_LENGTH = 44
%EQUATE `MAX_L2CAP_INFO_DATA_LENGTH = 44
'//
'// the following structures provide information about
'// discovered remote radios.
'//
%EQUATE `BDIF_ADDRESS = &H00000001
%EQUATE `BDIF_COD = &H00000002
%EQUATE `BDIF_NAME = &H00000004
%EQUATE `BDIF_PAIRED = &H00000008
%EQUATE `BDIF_PERSONAL = &H00000010
%EQUATE `BDIF_CONNECTED = &H00000020
'//
'// Support added in KB942567
'//
'#if (NTDDI_VERSION > NTDDI_VISTASP1 || \
' (NTDDI_VERSION == NTDDI_VISTASP1 && defined(VISTA_KB942567)))
%EQUATE `BDIF_SHORT_NAME = &H00000040
%EQUATE `BDIF_VISIBLE = &H00000080
%EQUATE `BDIF_SSP_SUPPORTED = &H00000100
%EQUATE `BDIF_SSP_PAIRED = &H00000200
%EQUATE `BDIF_SSP_MITM_PROTECTED = &H00000400
%EQUATE `BDIF_RSSI = &H00001000
%EQUATE `BDIF_EIR = &H00002000
'#define BDIF_VALID_FLAGS \
' (BDIF_ADDRESS | BDIF_COD | BDIF_NAME | BDIF_PAIRED | BDIF_PERSONAL | \
' BDIF_CONNECTED | BDIF_SHORT_NAME | BDIF_VISIBLE | BDIF_RSSI | BDIF_EIR | BDIF_SSP_PAIRED | BDIF_SSP_MITM_PROTECTED)
%EQUATE `BDIF_VALID_FLAGS = %BDIF_ADDRESS OR %BDIF_COD OR %BDIF_NAME OR %BDIF_PAIRED OR %BDIF_PERSONAL OR %BDIF_CONNECTED OR %BDIF_SHORT_NAME OR %BDIF_VISIBLE OR %BDIF_RSSI OR %BDIF_EIR OR %BDIF_SSP_PAIRED OR %BDIF_SSP_MITM_PROTECTED
'#else // <= SP1
'#define BDIF_VALID_FLAGS \
' (BDIF_ADDRESS | BDIF_COD | BDIF_NAME | BDIF_PAIRED | BDIF_PERSONAL | \
' BDIF_CONNECTED)
'%BDIF_VALID_FLAGS = %BDIF_ADDRESS OR %BDIF_COD OR %BDIF_NAME OR %BDIF_PAIRED OR %BDIF_PERSONAL OR %BDIF_CONNECTED
'#endif // >= SP1+KB942567
'typedef struct _BTH_DEVICE_INFO {
' //
' // Combination BDIF_Xxx flags
' //
' ULONG flags;
' //
' // Address of remote device.
' //
' BTH_ADDR address;
' //
' // Class Of Device.
' //
' BTH_COD classOfDevice;
' //
' // name of the device
' //
' CHAR name[BTH_MAX_NAME_SIZE];
'} BTH_DEVICE_INFO, *PBTH_DEVICE_INFO;
' // Size = 272 bytes
TYPE BTH_DEVICE_INFO QWORD ' Must be 8 byte aligned
 flags AS DWORD ' ULONG
 address AS QUAD ' BTH_ADDR
 classOfDevice AS DWORD ' BTH_COD
 name AS ASCIIZ * %BTH_MAX_NAME_SIZE ' CHAR - UTF8 encoded
END TYPE
'//
'// Buffer associated with GUID_BLUETOOTH_RADIO_IN_RANGE
'//
'typedef struct _BTH_RADIO_IN_RANGE {
' //
' // Information about the remote radio
' //
' BTH_DEVICE_INFO deviceInfo;
' //
' // The previous flags value for the BTH_DEVICE_INFO. The receiver of this
' // notification can compare the deviceInfo.flags and previousDeviceFlags
' // to determine what has changed about this remote radio.
' //
' // For instance, if BDIF_NAME is set in deviceInfo.flags and not in
' // previousDeviceFlags, the remote radio's has just been retrieved.
' //
' ULONG previousDeviceFlags;
'} BTH_RADIO_IN_RANGE, *PBTH_RADIO_IN_RANGE;
' // Size = 280 bytes
TYPE BTH_RADIO_IN_RANGE QWORD ' Must be 8 byte aligned
 deviceInfo AS BTH_DEVICE_INFO ' BTH_DEVICE_INFO
 previousDeviceFlags AS DWORD ' ULONG
END TYPE
'//
'// Buffer associated with GUID_BLUETOOTH_L2CAP_EVENT
'//
'typedef struct _BTH_L2CAP_EVENT_INFO {
' //
' // Remote radio address which the L2CAP event is associated with
' //
' BTH_ADDR bthAddress;
' //
' // The PSM that is either being connected to or disconnected from
' //
' USHORT psm;
' //
' // If != 0, then the channel has just been established. If == 0, then the
' // channel has been destroyed. Notifications for a destroyed channel will
' // only be sent for channels successfully established.
' //
' UCHAR connected;
' //
' // If != 0, then the local host iniated the l2cap connection. If == 0, then
' // the remote host initated the connection. This field is only valid if
' // connect is != 0.
' //
' UCHAR initiated;
'} BTH_L2CAP_EVENT_INFO, *PBTH_L2CAP_EVENT_INFO;
' // Size = 16 bytes
TYPE BTH_L2CAP_EVENT_INFO ' Must be 8 byte aligned
 bthAddress AS QUAD ' BTH_ADDR
 psm AS WORD ' USHORT
 connected AS BYTE ' UCHAR
 initiated AS BYTE ' UCHAR
 filler_ AS DWORD ' // To keep 8 bytes alignment
END TYPE
%EQUATE `HCI_CONNECTION_TYPE_ACL = 1
%EQUATE `HCI_CONNECTION_TYPE_SCO = 2
'//
'// Fix typos
'//
%EQUATE `HCI_CONNNECTION_TYPE_ACL = %HCI_CONNECTION_TYPE_ACL
%EQUATE `HCI_CONNNECTION_TYPE_SCO = %HCI_CONNECTION_TYPE_SCO
'//
'// Buffer associated with GUID_BLUETOOTH_HCI_EVENT
'//
'typedef struct _BTH_HCI_EVENT_INFO {
' //
'' // Remote radio address which the HCI event is associated with
' //
' BTH_ADDR bthAddress;
' //
' // HCI_CONNNECTION_TYPE_XXX value
' //
' UCHAR connectionType;
' //
' // If != 0, then the underlying connection to the remote radio has just
' // been estrablished. If == 0, then the underlying conneciton has just been
' // destroyed.
' //
' UCHAR connected;
'} BTH_HCI_EVENT_INFO, *PBTH_HCI_EVENT_INFO;
' // Size = 16 bytes
TYPE BTH_HCI_EVENT_INFO ' Must be 8 byte aligned
 bthAddress AS QUAD ' BTH_ADDR
 connectionType AS BYTE ' UCHAR
 connected AS BYTE ' UCHAR
 filler_(5) AS BYTE ' // To keep 8 bytes alignment
END TYPE
'//
'// Support added in KB942567
'//
'#if (NTDDI_VERSION > NTDDI_VISTASP1 || \
' (NTDDI_VERSION == NTDDI_VISTASP1 && defined(VISTA_KB942567)))
'//
'// Buffer associated with GUID_BLUETOOTH_KEYPRESS_EVENT
'//
' enum BTH_KEYPRESS_NOTIFICATION_TYPE
MACRO BTH_KEYPRESS_NOTIFICATION_TYPE_ENUM = LONG
%EQUATE `BTH_KEYPRESS_NOTIFICATION_PASSKEY_STARTED = &H0
%EQUATE `BTH_KEYPRESS_NOTIFICATION_PASSKEY_DIGIT_ENTERED = &H1
%EQUATE `BTH_KEYPRESS_NOTIFICATION_PASSKEY_DIGIT_ERASED = &H2
%EQUATE `BTH_KEYPRESS_NOTIFICATION_PASSKEY_CLEARED = &H3
%EQUATE `BTH_KEYPRESS_NOTIFICATION_PASSKEY_ENTRY_COMPLETED = &H4
' // Size = 16 bytes
TYPE BTH_HCI_KEYPRESS_INFO QWORD
 BTH_ADDR AS QUAD ' BTH_ADDR
 ' // HCI_KEYPRESS_XXX value
 NotificationType AS BYTE ' UCHAR
END TYPE
' enum _BTH_AUTH_METHOD
MACRO BTH_AUTH_METHOD_ENUM = LONG
%EQUATE `BTH_AUTH_METHOD_UNDEFINED = &H0
%EQUATE `BTH_AUTH_METHOD_LEGACY = &H1
%EQUATE `BTH_AUTH_METHOD_OOB = &H2
%EQUATE `BTH_AUTH_METHOD_NUMERIC_COMPARISON = &H3
%EQUATE `BTH_AUTH_METHOD_PASSKEY_NOTIFICATION = &H4
%EQUATE `BTH_AUTH_METHOD_PASSKEY = &H5
%EQUATE `BTH_AUTH_METHOD_MAX = %BTH_AUTH_METHOD_PASSKEY
' enum IO_CAPABILITY
MACRO IO_CAPABILITY_ENUM = LONG
%EQUATE `IoCaps_DisplayOnly = &H00
%EQUATE `IoCaps_DisplayYesNo = &H01
%EQUATE `IoCaps_KeyboardOnly = &H02
%EQUATE `IoCaps_NoInputNoOutput = &H03
%EQUATE `IoCaps_Undefined = &Hff
' enum OOB_DATA_PRESENT
MACRO OOB_DATA_PRESENT_ENUM = LONG
%EQUATE `OOBAuthenticationDataNotPresent = &H00
%EQUATE `OOBAuthenticationDataFromRemoteDevicePresent = &H01
' enum AUTHENTICATION_REQUIREMENTS
MACRO AUTHENTICATION_REQUIREMENTS_ENUM = LONG
%EQUATE `MITMProtectionNotRequired = &H00
%EQUATE `MITMProtectionRequired = &H01
%EQUATE `MITMProtectionNotRequiredBonding = &H02
%EQUATE `MITMProtectionRequiredBonding = &H03
%EQUATE `MITMProtectionNotRequiredGeneralBonding = &H04
%EQUATE `MITMProtectionRequiredGeneralBonding = &H05
%EQUATE `MITMProtectionNotDefined = &Hff
'#define IsMITMProtectionRequired(requirements) \
' ((MITMProtectionRequired == requirements) || (MITMProtectionRequiredBonding == requirements) || (MITMProtectionRequiredGeneralBonding == requirements))
MACRO IsMITMProtectionRequired(requirements) = ((%MITMProtectionRequired = requirements) OR (%MITMProtectionRequiredBonding = requirements) OR (%MITMProtectionRequiredGeneralBonding = requirements))
'//
'// Buffer associated with GUID_BLUETOOTH_AUTHENTICATION_REQUEST
'//
'typedef struct _BTH_AUTHENTICATION_REQUEST {
' BTH_DEVICE_INFO deviceInfo;
' BTH_AUTH_METHOD authenticationMethod;
' IO_CAPABILITY IoCapability;
' AUTHENTICATION_REQUIREMENTS AuthenticationRequirements; // max(local,remote)
' ULONG flag; // Reserved
' union{
' ULONG Numeric_Value;
' ULONG Passkey;
' };
'}BTH_AUTHENTICATION_REQUEST, *PBTH_AUTHENTICATION_REQUEST;
UNION BTH_AUTHENTICATION_REQUEST_UNION DWORD
 Numeric_Value AS DWORD ' ULONG
 Passkey AS DWORD ' ULONG
END UNION
' // Size = 296 bytes
TYPE BTH_AUTHENTICATION_REQUEST ' Must be 8 byte aligned
 deviceInfo AS BTH_DEVICE_INFO ' Size = 272 bytes
 authenticationMethod AS LONG ' BTH_AUTH_METHOD - Size = 4 bytes
 IoCapability AS LONG ' IO_CAPABILITY - Size = 4 bytes
 AuthenticationRequirements AS LONG ' AUTHENTICATION_REQUIREMENTS // max(local,remote)
 flag AS DWORD ' ULONG // Reserved
 BTH_AUTHENTICATION_REQUEST_UNION
 filler_ AS DWORD ' // To keep 8 bytes alignment
END TYPE
'#endif // >= SP1+KB942567
'//
'// max length we allow for ServiceName in the remote SDP records
'//
%EQUATE `BTH_MAX_SERVICE_NAME_SIZE = 256
%EQUATE `MAX_UUIDS_IN_QUERY = 12
%EQUATE `BTH_VID_DEFAULT_VALUE = &HFFFF
%EQUATE `SDP_ERROR_INVALID_SDP_VERSION = &H0001
%EQUATE `SDP_ERROR_INVALID_RECORD_HANDLE = &H0002
%EQUATE `SDP_ERROR_INVALID_REQUEST_SYNTAX = &H0003
%EQUATE `SDP_ERROR_INVALID_PDU_SIZE = &H0004
%EQUATE `SDP_ERROR_INVALID_CONTINUATION_STATE = &H0005
%EQUATE `SDP_ERROR_INSUFFICIENT_RESOURCES = &H0006
'//
'// Defined by windows to handle server errors that are not described by the
'// above errors. Start at 0x0100 so we don't go anywhere near the spec
'// defined values.
'//
'//
'// Success, nothing went wrong
'//
%EQUATE `SDP_ERROR_SUCCESS = &H0000 ' SDP_ERROR
'//
'// The SDP PDU or parameters other than the SDP stream response was not correct
'//
%EQUATE `SDP_ERROR_SERVER_INVALID_RESPONSE = &H0100 ' SDP_ERROR
'//
'// The SDP response stream did not parse correctly.
'//
%EQUATE `SDP_ERROR_SERVER_RESPONSE_DID_NOT_PARSE = &H0200 ' SDP_ERROR
'//
'// The SDP response stream was successfully parsed, but did not match the
'// required format for the query.
'//
%EQUATE `SDP_ERROR_SERVER_BAD_FORMAT = &H0300 ' SDP_ERROR
'//
'// SDP was unable to send a continued query back to the server
'//
%EQUATE `SDP_ERROR_COULD_NOT_SEND_CONTINUE = &H0400 ' SDP_ERROR
'//
'// Server sent a response that was too large to fit in the caller's buffer.
'//
%EQUATE `SDP_ERROR_RESPONSE_TOO_LARGE = &H0500 ' SDP_ERROR
%EQUATE `SDP_ATTRIB_RECORD_HANDLE = &H0000
%EQUATE `SDP_ATTRIB_CLASS_ID_LIST = &H0001
%EQUATE `SDP_ATTRIB_RECORD_STATE = &H0002
%EQUATE `SDP_ATTRIB_SERVICE_ID = &H0003
%EQUATE `SDP_ATTRIB_PROTOCOL_DESCRIPTOR_LIST = &H0004
%EQUATE `SDP_ATTRIB_BROWSE_GROUP_LIST = &H0005
%EQUATE `SDP_ATTRIB_LANG_BASE_ATTRIB_ID_LIST = &H0006
%EQUATE `SDP_ATTRIB_INFO_TIME_TO_LIVE = &H0007
%EQUATE `SDP_ATTRIB_AVAILABILITY = &H0008
%EQUATE `SDP_ATTRIB_PROFILE_DESCRIPTOR_LIST = &H0009
%EQUATE `SDP_ATTRIB_DOCUMENTATION_URL = &H000A
%EQUATE `SDP_ATTRIB_CLIENT_EXECUTABLE_URL = &H000B
%EQUATE `SDP_ATTRIB_ICON_URL = &H000C
%EQUATE `SDP_ATTRIB_ADDITIONAL_PROTOCOL_DESCRIPTOR_LIST = &H000D
'//
'// Attribute IDs in the range of 0x000D - 0x01FF are reserved for future use
'//
%EQUATE `SDP_ATTRIB_PROFILE_SPECIFIC = &H0200
%EQUATE `LANG_BASE_LANGUAGE_INDEX = &H0000
%EQUATE `LANG_BASE_ENCODING_INDEX = &H0001
%EQUATE `LANG_BASE_OFFSET_INDEX = &H0002
%EQUATE `LANG_DEFAULT_ID = &H0100
%EQUATE `STRING_NAME_OFFSET = &H0000
%EQUATE `STRING_DESCRIPTION_OFFSET = &H0001
%EQUATE `STRING_PROVIDER_NAME_OFFSET = &H0002
%EQUATE `SDP_ATTRIB_SDP_VERSION_NUMBER_LIST = &H0200
%EQUATE `SDP_ATTRIB_SDP_DATABASE_STATE = &H0201
%EQUATE `SDP_ATTRIB_BROWSE_GROUP_ID = &H0200
%EQUATE `SDP_ATTRIB_CORDLESS_EXTERNAL_NETWORK = &H0301
%EQUATE `SDP_ATTRIB_FAX_CLASS_1_SUPPORT = &H0302
%EQUATE `SDP_ATTRIB_FAX_CLASS_2_0_SUPPORT = &H0303
%EQUATE `SDP_ATTRIB_FAX_CLASS_2_SUPPORT = &H0304
%EQUATE `SDP_ATTRIB_FAX_AUDIO_FEEDBACK_SUPPORT = &H0305
%EQUATE `SDP_ATTRIB_HEADSET_REMOTE_AUDIO_VOLUME_CONTROL = &H0302
%EQUATE `SDP_ATTRIB_LAN_LPSUBNET = &H0200
%EQUATE `SDP_ATTRIB_OBJECT_PUSH_SUPPORTED_FORMATS_LIST = &H0303
%EQUATE `SDP_ATTRIB_SYNCH_SUPPORTED_DATA_STORES_LIST = &H0301
'// this is in the assigned numbers doc, but it does not show up in any profile
%EQUATE `SDP_ATTRIB_SERVICE_VERSION = &H0300
%EQUATE `SDP_ATTRIB_PAN_NETWORK_ADDRESS = &H0306
%EQUATE `SDP_ATTRIB_PAN_WAP_GATEWAY = &H0307
%EQUATE `SDP_ATTRIB_PAN_HOME_PAGE_URL = &H0308
%EQUATE `SDP_ATTRIB_PAN_WAP_STACK_TYPE = &H0309
%EQUATE `SDP_ATTRIB_PAN_SECURITY_DESCRIPTION = &H030A
%EQUATE `SDP_ATTRIB_PAN_NET_ACCESS_TYPE = &H030B
%EQUATE `SDP_ATTRIB_PAN_MAX_NET_ACCESS_RATE = &H030C
%EQUATE `SDP_ATTRIB_IMAGING_SUPPORTED_CAPABILITIES = &H0310
%EQUATE `SDP_ATTRIB_IMAGING_SUPPORTED_FEATURES = &H0311
%EQUATE `SDP_ATTRIB_IMAGING_SUPPORTED_FUNCTIONS = &H0312
%EQUATE `SDP_ATTRIB_IMAGING_TOTAL_DATA_CAPACITY = &H0313
%EQUATE `SDP_ATTRIB_DI_SPECIFICATION_ID = &H0200
%EQUATE `SDP_ATTRIB_DI_VENDOR_ID = &H0201
%EQUATE `SDP_ATTRIB_DI_PRODUCT_ID = &H0202
%EQUATE `SDP_ATTRIB_DI_VERSION = &H0203
%EQUATE `SDP_ATTRIB_DI_PRIMARY_RECORD = &H0204
%EQUATE `SDP_ATTRIB_DI_VENDOR_ID_SOURCE = &H0205
%EQUATE `SDP_ATTRIB_HID_DEVICE_RELEASE_NUMBER = &H0200
%EQUATE `SDP_ATTRIB_HID_PARSER_VERSION = &H0201
%EQUATE `SDP_ATTRIB_HID_DEVICE_SUBCLASS = &H0202
%EQUATE `SDP_ATTRIB_HID_COUNTRY_CODE = &H0203
%EQUATE `SDP_ATTRIB_HID_VIRTUAL_CABLE = &H0204
%EQUATE `SDP_ATTRIB_HID_RECONNECT_INITIATE = &H0205
%EQUATE `SDP_ATTRIB_HID_DESCRIPTOR_LIST = &H0206
%EQUATE `SDP_ATTRIB_HID_LANG_ID_BASE_LIST = &H0207
%EQUATE `SDP_ATTRIB_HID_SDP_DISABLE = &H0208
%EQUATE `SDP_ATTRIB_HID_BATTERY_POWER = &H0209
%EQUATE `SDP_ATTRIB_HID_REMOTE_WAKE = &H020A
'%SDP_ATTRIB_HID_REPORT_LIST = &H020B ' // Name changed in the Windows 7 SDK
%EQUATE `SDP_ATTRIB_HID_PROFILE_VERSION = &H020B
%EQUATE `SDP_ATTRIB_HID_SUPERVISION_TIMEOUT = &H020C
%EQUATE `SDP_ATTRIB_HID_NORMALLY_CONNECTABLE = &H020D
%EQUATE `SDP_ATTRIB_HID_BOOT_DEVICE = &H020E
%EQUATE `SDP_ATTRIB_HID_SSR_HOST_MAX_LATENCY = &H020F
%EQUATE `SDP_ATTRIB_HID_SSR_HOST_MIN_TIMEOUT = &H0210
'//
'// Profile specific values
'//
%EQUATE `CORDLESS_EXTERNAL_NETWORK_PSTN = &H01
%EQUATE `CORDLESS_EXTERNAL_NETWORK_ISDN = &H02
%EQUATE `CORDLESS_EXTERNAL_NETWORK_GSM = &H03
%EQUATE `CORDLESS_EXTERNAL_NETWORK_CDMA = &H04
%EQUATE `CORDLESS_EXTERNAL_NETWORK_ANALOG_CELLULAR = &H05
%EQUATE `CORDLESS_EXTERNAL_NETWORK_PACKET_SWITCHED = &H06
%EQUATE `CORDLESS_EXTERNAL_NETWORK_OTHER = &H07
%EQUATE `OBJECT_PUSH_FORMAT_VCARD_2_1 = &H01
%EQUATE `OBJECT_PUSH_FORMAT_VCARD_3_0 = &H02
%EQUATE `OBJECT_PUSH_FORMAT_VCAL_1_0 = &H03
%EQUATE `OBJECT_PUSH_FORMAT_ICAL_2_0 = &H04
%EQUATE `OBJECT_PUSH_FORMAT_VNOTE = &H05
%EQUATE `OBJECT_PUSH_FORMAT_VMESSAGE = &H06
%EQUATE `OBJECT_PUSH_FORMAT_ANY = &HFF
%EQUATE `SYNCH_DATA_STORE_PHONEBOOK = &H01
%EQUATE `SYNCH_DATA_STORE_CALENDAR = &H03
%EQUATE `SYNCH_DATA_STORE_NOTES = &H05
%EQUATE `SYNCH_DATA_STORE_MESSAGES = &H06
%EQUATE `DI_VENDOR_ID_SOURCE_BLUETOOTH_SIG = &H0001
%EQUATE `DI_VENDOR_ID_SOURCE_USB_IF = &H0002
%EQUATE `PSM_SDP = &H0001
%EQUATE `PSM_RFCOMM = &H0003
%EQUATE `PSM_TCS_BIN = &H0005
%EQUATE `PSM_TCS_BIN_CORDLESS = &H0007
%EQUATE `PSM_BNEP = &H000F
%EQUATE `PSM_HID_CONTROL = &H0011
%EQUATE `PSM_HID_INTERRUPT = &H0013
%EQUATE `PSM_AVCTP = &H0017
%EQUATE `PSM_AVDTP = &H0019
%EQUATE `PSM_UDI_C_PLANE = &H001D
'//
'// Strings
'//
'#define STR_ADDR_FMTA "(%02x:%02x:%02x:%02x:%02x:%02x)"
'#define STR_ADDR_FMTW L"(%02x:%02x:%02x:%02x:%02x:%02x)"
$STR_ADDR_FMTA = "(%02x:%02x:%02x:%02x:%02x:%02x)"
$$STR_ADDR_FMTW = "(%02x:%02x:%02x:%02x:%02x:%02x)"$$
#IF %DEF(%UNICODE)
MACRO STR_ADDR_FMT = $$STR_ADDR_FMTW
#ELSE
MACRO STR_ADDR_FMT = $STR_ADDR_FMTA
#ENDIF
'#define STR_ADDR_SHORT_FMTA "%04x%08x"
'#define STR_ADDR_SHORT_FMTW L"%04x%08x"
$STR_ADDR_SHORT_FMTA = "%04x%08x"
$$STR_ADDR_SHORT_FMTW = "%04x%08x"$$
#IF %DEF(%UNICODE)
MACRO STR_ADDR_SHORT_FMT = $STR_ADDR_SHORT_FMTA
#ELSE
MACRO STR_ADDR_SHORT_FMT = $$STR_ADDR_SHORT_FMTW
#ENDIF
'#define GET_BITS(field,offset,mask) ( ( (field) >> (offset) ) & (mask) )
FUNCTION GET_BITS (BYVAL dwfield AS DWORD, BYVAL dwoffset AS DWORD, BYVAL dwmask AS DWORD) AS DWORD
 SHIFT RIGHT dwfield, dwoffset
 FUNCTION = dwfield AND dwmask
END FUNCTION
'#define GET_BIT(field,offset) ( GET_BITS(field,offset,0x1) )
FUNCTION GET_BIT (BYVAL dwfield AS DWORD, BYVAL dwoffset AS DWORD) AS DWORD
 FUNCTION = GET_BITS(dwfield, dwoffset, &H1)
END FUNCTION
'#define LMP_3_SLOT_PACKETS(x) (GET_BIT(x, 0))
FUNCTION LMP_3_SLOT_PACKETS (BYVAL x AS DWORD) AS DWORD
 FUNCTION = GET_BIT(x, 0)
END FUNCTION
'#define LMP_5_SLOT_PACKETS(x) (GET_BIT(x, 1))
FUNCTION LMP_5_SLOT_PACKETS (BYVAL x AS DWORD) AS DWORD
 FUNCTION = GET_BIT(x, 1)
END FUNCTION
'#define LMP_ENCRYPTION(x) (GET_BIT(x, 2))
FUNCTION LMP_ENCRYPTION (BYVAL x AS DWORD) AS DWORD
 FUNCTION = GET_BIT(x, 2)
END FUNCTION
'#define LMP_SLOT_OFFSET(x) (GET_BIT(x, 3))
FUNCTION LMP_SLOT_OFFSET (BYVAL x AS DWORD) AS DWORD
 FUNCTION = GET_BIT(x, 3)
END FUNCTION
'#define LMP_TIMING_ACCURACY(x) (GET_BIT(x, 4))
FUNCTION LMP_TIMING_ACCURACY (BYVAL x AS DWORD) AS DWORD
 FUNCTION = GET_BIT(x, 4)
END FUNCTION
'#define LMP_SWITCH(x) (GET_BIT(x, 5))
FUNCTION LMP_SWITCH (BYVAL x AS DWORD) AS DWORD
 FUNCTION = GET_BIT(x, 5)
END FUNCTION
'#define LMP_HOLD_MODE(x) (GET_BIT(x, 6))
FUNCTION LMP_HOLD_MODE (BYVAL x AS DWORD) AS DWORD
 FUNCTION = GET_BIT(x, 6)
END FUNCTION
'#define LMP_SNIFF_MODE(x) (GET_BIT(x, 7))
FUNCTION LMP_SNIFF_MODE (BYVAL x AS DWORD) AS DWORD
 FUNCTION = GET_BIT(x, 7)
END FUNCTION
'#define LMP_PARK_MODE(x) (GET_BIT(x, 8))
FUNCTION LMP_PARK_MODE (BYVAL x AS DWORD) AS DWORD
 FUNCTION = GET_BIT(x, 8)
END FUNCTION
'#define LMP_RSSI(x) (GET_BIT(x, 9))
FUNCTION LMP_RSSI(BYVAL x AS DWORD) AS DWORD
 FUNCTION = GET_BIT(x, 9)
END FUNCTION
'#define LMP_CHANNEL_QUALITY_DRIVEN_MODE(x) (GET_BIT(x,10))
FUNCTION LMP_CHANNEL_QUALITY_DRIVEN_MODE (BYVAL x AS DWORD) AS DWORD
 FUNCTION = GET_BIT(x, 10)
END FUNCTION
'#define LMP_SCO_LINK(x) (GET_BIT(x,11))
FUNCTION LMP_SCO_LINK (BYVAL x AS DWORD) AS DWORD
 FUNCTION = GET_BIT(x, 11)
END FUNCTION
'#define LMP_HV2_PACKETS(x) (GET_BIT(x,12))
FUNCTION LMP_HV2_PACKETS (BYVAL x AS DWORD) AS DWORD
 FUNCTION = GET_BIT(x, 12)
END FUNCTION
'#define LMP_HV3_PACKETS(x) (GET_BIT(x,13))
FUNCTION LMP_HV3_PACKETS (BYVAL x AS DWORD) AS DWORD
 FUNCTION = GET_BIT(x, 13)
END FUNCTION
'#define LMP_MU_LAW_LOG(x) (GET_BIT(x,14))
FUNCTION LMP_MU_LAW_LOG (BYVAL x AS DWORD) AS DWORD
 FUNCTION = GET_BIT(x, 14)
END FUNCTION
'#define LMP_A_LAW_LOG(x) (GET_BIT(x,15))
FUNCTION LMP_A_LAW_LOG (BYVAL x AS DWORD) AS DWORD
 FUNCTION = GET_BIT(x, 15)
END FUNCTION
'#define LMP_CVSD(x) (GET_BIT(x,16))
FUNCTION LMP_CVSD (BYVAL x AS DWORD) AS DWORD
 FUNCTION = GET_BIT(x, 16)
END FUNCTION
'#define LMP_PAGING_SCHEME(x) (GET_BIT(x,17))
FUNCTION LMP_PAGING_SCHEME (BYVAL x AS DWORD) AS DWORD
 FUNCTION = GET_BIT(x, 17)
END FUNCTION
'#define LMP_POWER_CONTROL(x) (GET_BIT(x,18))
FUNCTION LMP_POWER_CONTROL (BYVAL x AS DWORD) AS DWORD
 FUNCTION = GET_BIT(x, 18)
END FUNCTION
'#define LMP_TRANSPARENT_SCO_DATA(x) (GET_BIT(x,19))
FUNCTION LMP_TRANSPARENT_SCO_DATA (BYVAL x AS DWORD) AS DWORD
 FUNCTION = GET_BIT(x, 19)
END FUNCTION
'#define LMP_FLOW_CONTROL_LAG(x) (GET_BITS(x,20,0x3))
FUNCTION LMP_FLOW_CONTROL_LAG (BYVAL x AS DWORD) AS DWORD
 FUNCTION = GET_BITS(x, 20, &H3)
END FUNCTION
'#define LMP_BROADCAST_ENCRYPTION(x) (GET_BIT(x,23))
FUNCTION LMP_BROADCAST_ENCRYPTION (BYVAL x AS DWORD) AS DWORD
 FUNCTION = GET_BIT(x, 23)
END FUNCTION
'#define LMP_ENHANCED_DATA_RATE_ACL_2MBPS_MODE(x) (GET_BIT(x,25))
FUNCTION LMP_ENHANCED_DATA_RATE_ACL_2MBPS_MODE (BYVAL x AS DWORD) AS DWORD
 FUNCTION = GET_BIT(x, 25)
END FUNCTION
'#define LMP_ENHANCED_DATA_RATE_ACL_3MBPS_MODE(x) (GET_BIT(x,26))
FUNCTION LMP_ENHANCED_DATA_RATE_ACL_3MBPS_MODE (BYVAL x AS DWORD) AS DWORD
 FUNCTION = GET_BIT(x, 26)
END FUNCTION
'#define LMP_ENHANCED_INQUIRY_SCAN(x) (GET_BIT(x,27))
FUNCTION LMP_ENHANCED_INQUIRY_SCAN (BYVAL x AS DWORD) AS DWORD
 FUNCTION = GET_BIT(x, 27)
END FUNCTION
'#define LMP_INTERLACED_INQUIRY_SCAN(x) (GET_BIT(x,28))
FUNCTION LMP_INTERLACED_INQUIRY_SCAN (BYVAL x AS DWORD) AS DWORD
 FUNCTION = GET_BIT(x, 28)
END FUNCTION
'#define LMP_INTERLACED_PAGE_SCAN(x) (GET_BIT(x,29))
FUNCTION LMP_INTERLACED_PAGE_SCAN (BYVAL x AS DWORD) AS DWORD
 FUNCTION = GET_BIT(x, 29)
END FUNCTION
'#define LMP_RSSI_WITH_INQUIRY_RESULTS(x) (GET_BIT(x,30))
FUNCTION LMP_RSSI_WITH_INQUIRY_RESULTS (BYVAL x AS DWORD) AS DWORD
 FUNCTION = GET_BIT(x, 30)
END FUNCTION
'#define LMP_ESCO_LINK(x) (GET_BIT(x,31))
FUNCTION LMP_ESCO_LINK (BYVAL x AS DWORD) AS DWORD
 FUNCTION = GET_BIT(x, 31)
END FUNCTION
'#define LMP_EV4_PACKETS(x) (GET_BIT(x,32))
FUNCTION LMP_EV4_PACKETS (BYVAL x AS DWORD) AS DWORD
 FUNCTION = GET_BIT(x, 32)
END FUNCTION
'#define LMP_EV5_PACKETS(x) (GET_BIT(x,33))
FUNCTION LMP_EV5_PACKETS (BYVAL x AS DWORD) AS DWORD
 FUNCTION = GET_BIT(x, 33)
END FUNCTION
'#define LMP_AFH_CAPABLE_SLAVE(x) (GET_BIT(x,35))
FUNCTION LMP_AFH_CAPABLE_SLAVE (BYVAL x AS DWORD) AS DWORD
 FUNCTION = GET_BIT(x, 35)
END FUNCTION
'#define LMP_AFH_CLASSIFICATION_SLAVE(x) (GET_BIT(x,36))
FUNCTION LMP_AFH_CLASSIFICATION_SLAVE (BYVAL x AS DWORD) AS DWORD
 FUNCTION = GET_BIT(x, 36)
END FUNCTION
'#define LMP_3SLOT_EDR_ACL_PACKETS(x) (GET_BIT(x,39))
FUNCTION LMP_3SLOT_EDR_ACL_PACKETS (BYVAL x AS DWORD) AS DWORD
 FUNCTION = GET_BIT(x, 39)
END FUNCTION
'#define LMP_5SLOT_EDR_ACL_PACKETS(x) (GET_BIT(x,40))
FUNCTION LMP_5SLOT_EDR_ACL_PACKETS (BYVAL x AS DWORD) AS DWORD
 FUNCTION = GET_BIT(x, 40)
END FUNCTION
'#define LMP_SNIFF_SUBRATING(x) (GET_BIT(x,41))
FUNCTION LMP_SNIFF_SUBRATING (BYVAL x AS DWORD) AS DWORD
 FUNCTION = GET_BIT(x, 41)
END FUNCTION
'#define LMP_PAUSE_ENCRYPTION(x) (GET_BIT(x,42))
FUNCTION LMP_PAUSE_ENCRYPTION (BYVAL x AS DWORD) AS DWORD
 FUNCTION = GET_BIT(x, 42)
END FUNCTION
'#define LMP_AFH_CAPABLE_MASTER(x) (GET_BIT(x,43))
FUNCTION LMP_AFH_CAPABLE_MASTER (BYVAL x AS DWORD) AS DWORD
 FUNCTION = GET_BIT(x, 43)
END FUNCTION
'#define LMP_AFH_CLASSIFICATION_MASTER(x) (GET_BIT(x,44))
FUNCTION LMP_AFH_CLASSIFICATION_MASTER (BYVAL x AS DWORD) AS DWORD
 FUNCTION = GET_BIT(x, 44)
END FUNCTION
'#define LMP_EDR_ESCO_2MBPS_MODE(x) (GET_BIT(x,45))
FUNCTION LMP_EDR_ESCO_2MBPS_MODE (BYVAL x AS DWORD) AS DWORD
 FUNCTION = GET_BIT(x, 45)
END FUNCTION
'#define LMP_EDR_ESCO_3MBPS_MODE(x) (GET_BIT(x,46))
FUNCTION LMP_EDR_ESCO_3MBPS_MODE (BYVAL x AS DWORD) AS DWORD
 FUNCTION = GET_BIT(x, 46)
END FUNCTION
'#define LMP_3SLOT_EDR_ESCO_PACKETS(x) (GET_BIT(x,47))
FUNCTION LMP_3SLOT_EDR_ESCO_PACKETS (BYVAL x AS DWORD) AS DWORD
 FUNCTION = GET_BIT(x, 47)
END FUNCTION
'#define LMP_EXTENDED_INQUIRY_RESPONSE(x) (GET_BIT(x,48))
FUNCTION LMP_EXTENDED_INQUIRY_RESPONSE (BYVAL x AS DWORD) AS DWORD
 FUNCTION = GET_BIT(x, 48)
END FUNCTION
'#define LMP_SECURE_SIMPLE_PAIRING(x) (GET_BIT(x,51))
FUNCTION LMP_SECURE_SIMPLE_PAIRING (BYVAL x AS DWORD) AS DWORD
 FUNCTION = GET_BIT(x, 51)
END FUNCTION
'#define LMP_ENCAPSULATED_PDU(x) (GET_BIT(x,52))
FUNCTION LMP_ENCAPSULATED_PDU (BYVAL x AS DWORD) AS DWORD
 FUNCTION = GET_BIT(x, 52)
END FUNCTION
'#define LMP_ERRONEOUS_DATA_REPORTING(x) (GET_BIT(x,53))
FUNCTION LMP_ERRONEOUS_DATA_REPORTING (BYVAL x AS DWORD) AS DWORD
 FUNCTION = GET_BIT(x, 53)
END FUNCTION
'#define LMP_NON_FLUSHABLE_PACKET_BOUNDARY_FLAG(x) (GET_BIT(x,54))
FUNCTION LMP_NON_FLUSHABLE_PACKET_BOUNDARY_FLAG (BYVAL x AS DWORD) AS DWORD
 FUNCTION = GET_BIT(x, 54)
END FUNCTION
'#define LMP_LINK_SUPERVISION_TIMEOUT_CHANGED_EVENT(x) (GET_BIT(x,56))
FUNCTION LMP_LINK_SUPERVISION_TIMEOUT_CHANGED_EVENT (BYVAL x AS DWORD) AS DWORD
 FUNCTION = GET_BIT(x, 56)
END FUNCTION
'#define LMP_INQUIRY_RESPONSE_TX_POWER_LEVEL(x)(GET_BIT(x,57))
FUNCTION LMP_INQUIRY_RESPONSE_TX_POWER_LEVEL (BYVAL x AS DWORD) AS DWORD
 FUNCTION = GET_BIT(x, 57)
END FUNCTION
'#define LMP_EXTENDED_FEATURES(x) (GET_BIT(x,63))
FUNCTION LMP_EXTENDED_FEATURES (BYVAL x AS DWORD) AS DWORD
 FUNCTION = GET_BIT(x, 63)
END FUNCTION
#ENDIF ' // GUID_DEFS_ONLY
'#endif // (NTDDI_VERSION >= NTDDI_WINXPSP2)
'#if _MSC_VER >= 1200
'#pragma warning(pop)
'#else
'#pragma warning(default:4201)
'#endif
#ENDIF
