IVT BlueSoleil Bluetooth APIread.pudn.com › downloads161 › ebook › 728784 › 蓝牙模...

41
BlueSoleil BlueSoleil TM TM Bluetooth API for Windows Reference Manual Nov 1st, 2004 IVT CORPORATION 5/F, Fa Zhan Plaza No. 12, Shang Di Xin Xi Zhong Road, Hai Dian District, Beijing, 100085, P. R. China © Copyright 2004, IVT Corporation BTP-SW-U4-1-1All specifications are subject to change without notice.Page 1 of 42

Transcript of IVT BlueSoleil Bluetooth APIread.pudn.com › downloads161 › ebook › 728784 › 蓝牙模...

Page 1: IVT BlueSoleil Bluetooth APIread.pudn.com › downloads161 › ebook › 728784 › 蓝牙模 …  · Web viewBluetooth API for Windows. Reference Manual. Nov 1st, 2004 . IVT CORPORATION.

BlueSoleilBlueSoleilTMTM

Bluetooth API for WindowsReference Manual

Nov 1st, 2004

IVT CORPORATION

5/F, Fa Zhan PlazaNo. 12, Shang Di Xin Xi Zhong Road,

Hai Dian District,Beijing, 100085,

P. R. China

Tel: +86 10 82898225Fax: +86 10 62963059

www.ivtcorporation.comwww.bluesoleil.com

[email protected]

© Copyright 2004, IVT CorporationBTP-SW-U4-1-1 All specifications are subject to change without notice. Page 1 of 36

Page 2: IVT BlueSoleil Bluetooth APIread.pudn.com › downloads161 › ebook › 728784 › 蓝牙模 …  · Web viewBluetooth API for Windows. Reference Manual. Nov 1st, 2004 . IVT CORPORATION.

BlueSoleil Bluetooth API Reference Manual

Revision HistoryVersion Date Comments

0.60 November 1, 2004 Initial version.

0.65 November 29, 2004 Changed mask constants for Get/SetRemoteDeviceInfo

Changed callback events and callback function prototypes

Added BT_StartBluetooth, BT_StopBluetooth, BT_CancelInquiry

0.70 December 10, 2004 Changed GENERAL_SERVICE_INFO

Changed BT_PairDevice

Added BT_GetConnectInfo

0.75 December 14, 2004 Added BT_GetVersion

0.76 March 10, 2005 Updated btfunc.dll internal implementation to be compatible with Windows Installer installation

0.79 March 15, 2005 Added new inquiry mode INQUIRY_GENERAL_REFRESH mode for BT_InquireDevices

Added new functions BT_GetConfiguration and BT_SetConfiguration

0.81 June 23, 2005

Add BT_GetBtSpecVersion

0.82 July 6, 2005 Add BT_EnumConnections

Change parameter requirements for BT_GetConnectInfo

July 17, 2005

Add new API error return code BTSTATUS_DEVICE_NOT_EXIST for BT_ GetRemoteDeviceInfo

Change parameter requirements for BT_ConnectService with CLS_DIALUP_NET

Add event flag ("Global\\BluesoleilStarted")

0.83 October 13, 2005 Add support of disconnecting PAN incoming connections by BT_DisconnectService.

Copyright © 2004, IVT Corporation, http://www.ivtcorporation.comAll specifications are preliminary and subject to change without notice.

2

Page 3: IVT BlueSoleil Bluetooth APIread.pudn.com › downloads161 › ebook › 728784 › 蓝牙模 …  · Web viewBluetooth API for Windows. Reference Manual. Nov 1st, 2004 . IVT CORPORATION.

BlueSoleil Bluetooth API Reference Manual

Contents1 Introduction..........................................................................................................................12 System Requirements..........................................................................................................13 Development Guide.............................................................................................................14 Data Structure Reference....................................................................................................2

4.1 BLUETOOTH_DEVICE_INFO......................................................................................24.2 BLUETOOTH_DEVICE_INFO_EX...............................................................................34.3 SPP_CLIENT_PARAM.................................................................................................44.4 DUN_CLIENT_PARAM.................................................................................................54.5 OPP_CLIENT_PARAM.................................................................................................54.6 SYNC_CLIENT_PARAM..............................................................................................64.7 GENERAL_SERVICE_INFO........................................................................................74.8 SPPEX_SERVICE_INFO..............................................................................................74.9 GENERAL_CONNECT_INFO......................................................................................8

5 Function Reference..............................................................................................................85.1 BT_InitializeLibrary........................................................................................................85.2 BT_UninitializeLibrary...................................................................................................95.3 BT_IsBlueSoleilStarted.................................................................................................95.4 BT_IsBluetoothReady.................................................................................................105.5 BT_StartBluetooth.......................................................................................................105.6 BT_StopBluetooth.......................................................................................................115.7 BT_GetLocalDeviceInfo..............................................................................................115.8 BT_SetLocalDeviceInfo..............................................................................................125.9 BT_GetRemoteDeviceInfo..........................................................................................135.10 BT_SetRemoteDeviceInfo.......................................................................................145.11 BT_PairDevice.........................................................................................................155.12 BT_UnpairDevice....................................................................................................165.13 BT_ConnectService.................................................................................................165.14 BT_DisconnectService............................................................................................185.15 BT_InquireDevices..................................................................................................195.16 BT_CancelInquiry....................................................................................................205.17 BT_BrowseServices................................................................................................205.18 BT_GetConnectInfo.................................................................................................215.19 BT_StartSPPExService...........................................................................................235.20 BT_StopSPPExService...........................................................................................235.21 BT_SearchSPPExServices.....................................................................................245.22 BT_ConnectSPPExService.....................................................................................255.23 BT_DisconnectSPPExService.................................................................................265.24 BT_RegisterCallback...............................................................................................265.25 BT_UnregisterCallback............................................................................................295.26 BT_GetVersion........................................................................................................305.27 BT_GetBtSpecVersion............................................................................................305.28 BT_EnumConnections.............................................................................................31

Copyright © 2004, IVT Corporation, http://www.ivtcorporation.comAll specifications are preliminary and subject to change without notice.

3

Page 4: IVT BlueSoleil Bluetooth APIread.pudn.com › downloads161 › ebook › 728784 › 蓝牙模 …  · Web viewBluetooth API for Windows. Reference Manual. Nov 1st, 2004 . IVT CORPORATION.

BlueSoleil Bluetooth API Reference Manual

1 IntroductionThis document describes APIs exported by IVT BlueSoleil™ for Windows. These APIs are available after BlueSoleil is installed on a computer with MS Windows. With these APIs, applications can perform standard Bluetooth operations, including inquiring surrounding Bluetooth devices, authenticating a remote Bluetooth device, connecting to a service on a Bluetooth device, starting/stopping a service of BlueSoleil, etc.NOTE: These APIs are tested under Microsoft Visual C++ 6.0 currently.

2 System RequirementsTo develop software based on BlueSoleil Bluetooth APIs, following hardware and software are required:

Windows 98 SE / ME / 2000 / XP BlueSoleil version 1.6.0 or above A Bluetooth radio device (Bluetooth USB dongle or CF cards) compatible with

BlueSoleil

3 Development GuideFour files are provided for developers to compile, link and run applications: a DLL file btfunc.dll, a library file btfunc.lib and two header file bt_ui.h, bt_def.h.

btfunc.dllThis is the Bluetooth APIs implementation. It is installed to Windows system directory when BlueSoleil is installed.

btfunc.lib This is the Bluetooth API function address library. It can be linked with developer’s program.

bt_ui.h This is the header file that defines constants, structures and API prototypes.

bt_def.h This is a header file that contains constants for Class of Device and other Bluetooth definitions.

IMPORTANT NOTES:1. For future upgrade, an API version is assigned to "bt_ui.h" and "btfunc.lib"

when they are formally released. The latest revision number of this document is the API version to the concomitant “bt_ui.h” and ”btfunc.lib”.

2. As new APIs may be added or API behaviors may be changed in future, it is strongly recommended that user application uses LoadLibrary(“btfunc.dll”) and GetProcAddress() to locate API addresses dynamically and calls BT_GetVersion() to make sure the installed BlueSoleil supports the APIs that user application requires; User application should always uses the “btfunc.dll” that installed to Windows system directory by BlueSoleil

Copyright © 2004, IVT Corporation, http://www.ivtcorporation.comAll specifications are preliminary and subject to change without notice.

1

Page 5: IVT BlueSoleil Bluetooth APIread.pudn.com › downloads161 › ebook › 728784 › 蓝牙模 …  · Web viewBluetooth API for Windows. Reference Manual. Nov 1st, 2004 . IVT CORPORATION.

BlueSoleil Bluetooth API Reference Manual

installation, the “btfunc.dll” that comes along with this document is only for development convenience purpose.

3. Make sure to call BT_InitializeLibrary and get a TRUE return value before calling any other APIs except BT_IsBlueSoleilStarted, BT_IsBluetoothReady and BT_GetVersion.

4. Make sure to call BT_UninitializeLibrary to free resources before user application exits.

5. Bytes order of parameters, including Bluetooth Device Address, Bluetooth Device Class, pin code and link key, is in the order of what they are normally returned from HCI event.

6. When BlueSoleil is started/stopped, a global system event object ("Global\\BluesoleilStarted") is set/rest; and a global system event ("Global\\BluesoleilStopping") is reset/set. When Bluetooth is started/stopped, a global system event object ("Global\\BluesoleilBluetoothStarted") is set/reset. User applications can detect the running status of BlueSoleil by monitoring on these events, but it is recommended that user applications use BT_IsBlueSoleilStarted and BT_IsBluetoothReady instead. If these events are used, they must be created as manual-reset and user applications should not set/reset these events.

7. Typical API Calling Sequence:1) BT_InitializeLibrary2) BT_RegisterCallback3) BT_InquireDevices4) BT_PairDevice5) BT_BrowseServices6) BT_ConnectService7) BT_DisconnectService8) BT_UninitializeLibrary

8. When a connection is established (by BT_ConnectService or other APIs), it may be released because user releases it from the remote device or from BlueSoleil's UI, or because Bluetooth hardware does not function. Client applications should register callbacks for appropriate events to monitor the status of connection, and re-connect to the remote device when necessary.

4 Data Structure Reference

4.1 BLUETOOTH_DEVICE_INFO

The BLUETOOTH_DEVICE_INFO structure provides information about a Bluetooth device.

typedef struct _BLUETOOTH_DEVICE_INFO {DWORD dwSize;

Copyright © 2004, IVT Corporation, http://www.ivtcorporation.comAll specifications are preliminary and subject to change without notice.

2

Page 6: IVT BlueSoleil Bluetooth APIread.pudn.com › downloads161 › ebook › 728784 › 蓝牙模 …  · Web viewBluetooth API for Windows. Reference Manual. Nov 1st, 2004 . IVT CORPORATION.

BlueSoleil Bluetooth API Reference Manual

BYTE address[DEVICE_ADDRESS_LENGTH];BYTE classOfDevice[DEVICE_CLASS_LENGTH];CHAR szName[MAX_DEVICE_NAME_LENGTH];BOOL bPaired;

} BLUETOOTH_DEVICE_INFO, *PBLUETOOTH_DEVICE_INFO;

MembersdwSize

Size of the structure, in bytes.address

Address of the device.classOfDevice

Class of the device.szName

A null-terminated string specifying the Bluetooth device name.bPaired

Specifies whether the device is paired, authenticated or bonded. All authenticated devices are remembered.

4.2 BLUETOOTH_DEVICE_INFO_EX

The BLUETOOTH_DEVICE_INFO_EX structure provides detailed information of a Bluetooth device.

typedef struct _BLUETOOTH_DEVICE_INFO_EX {DWORD dwSize;BYTE address[DEVICE_ADDRESS_LENGTH];BYTE classOfDevice[DEVICE_CLASS_LENGTH];CHAR szName[MAX_DEVICE_NAME_LENGTH];BOOL bPaired;UCHAR ucLmpVersion;WORD wManuName;WORD wLmpSubversion;BYTE reserved[16];WORD wClockOffset;BOOL bConnected;DWORD dwDataRecvBytes;DWORD dwDataSentBytes;CHAR cSignalStrength;

} BLUETOOTH_DEVICE_INFO_EX, *PBLUETOOTH_DEVICE_INFO_EX;

MembersdwSize

Copyright © 2004, IVT Corporation, http://www.ivtcorporation.comAll specifications are preliminary and subject to change without notice.

3

Page 7: IVT BlueSoleil Bluetooth APIread.pudn.com › downloads161 › ebook › 728784 › 蓝牙模 …  · Web viewBluetooth API for Windows. Reference Manual. Nov 1st, 2004 . IVT CORPORATION.

BlueSoleil Bluetooth API Reference Manual

Size of the structure, in bytes.address

Address of the device.classOfDevice

Class of the device.szName

A null-terminated string specifying the Bluetooth device name.bPaired

Specifies whether the device is paired (bonded).ucLmpVersion

Bluetooth Assigned Number for LMP version.wManuName

Bluetooth Assigned Number for manufacture.wLmpSubversion

LMP subversion of the device.reserved

Reserved.bConnected

Specifies whether the device is connected.dwDataRecvBytes

Total data received in bytes between local device and the remote device, valid only when the device is connected.

dwDataSentBytesTotal data sent in bytes between local device and the remote device, valid only when the device is connected.

ucSignalStrengthBluetooth radio signal strength of the remote device, valid only when the device is connected.

4.3 SPP_CLIENT_PARAM

The SPP_CLIENT_PARAM structure contains SPP profile connection parameters for function BT_ConnectService (with service class CLS_SERIAL_PORT).

typedef struct _SPP_CLIENT_PARAM {DWORD dwSize;UCHAR ucComIndex;

} SPP_CLIENT_PARAM,*PSPP_CLIENT_PARAM;

MembersdwSize

Size of the structure, in bytes.ucComIndex

Copyright © 2004, IVT Corporation, http://www.ivtcorporation.comAll specifications are preliminary and subject to change without notice.

4

Page 8: IVT BlueSoleil Bluetooth APIread.pudn.com › downloads161 › ebook › 728784 › 蓝牙模 …  · Web viewBluetooth API for Windows. Reference Manual. Nov 1st, 2004 . IVT CORPORATION.

BlueSoleil Bluetooth API Reference Manual

Receives the COM port number bound to the Bluetooth connection if BT_ConnectService returns successfully.

4.4 DUN_CLIENT_PARAM

The DUN_CLIENT_PARAM structure contains DUN profile connection parameters for function BT_ConnectService (with service class CLS_DIALUP_NET).

typedef struct _DUN_CLIENT_PARAM {DWORD dwSize;WORD wShortcutFlags;BOOL bAutoDial;CHAR szUserName[DUN_MAX_NAME_LENGTH];CHAR password[DUN_MAX_PASSWORD_LENGTH]; CHAR dialNumber[DUN_MAX_DIAL_NUMBER_LENGTH];

}DUN_CLIENT_PARAM,*PDUN_CLIENT_PARAM;

MembersdwSize

Size of the structure, in bytes.wShortcutFlags

Specifies which item is to be set for a desktop shortcut. This parameter can be any combination of the following values:Value MeaningDUN_SET_USER_NAME Set DUN dial up user name by szUserName.DUN_SET_PASSWORD Set DUN dial up user password by password.DUN_SET_DIAL_NUMBER Set DUN dial up number by dialNumber

If applications do not want to create a desktop shortcut, wShortcutFlags must be set to DUN_SET_NONE.

bAutoDialSpecifies whether to dial automatically without prompting the user to enter additional dial up information.

szUserNameDUN dial up user name.

passwordDUN dial up user password.

dialNumberDUN dial up number.

4.5 OPP_CLIENT_PARAM

The OPP_CLIENT_PARAM contains OPP profile connection parameters for function BT_ConnectService (with service class CLS_OBEX_OBJ_PUSH).

Copyright © 2004, IVT Corporation, http://www.ivtcorporation.comAll specifications are preliminary and subject to change without notice.

5

Page 9: IVT BlueSoleil Bluetooth APIread.pudn.com › downloads161 › ebook › 728784 › 蓝牙模 …  · Web viewBluetooth API for Windows. Reference Manual. Nov 1st, 2004 . IVT CORPORATION.

BlueSoleil Bluetooth API Reference Manual

typedef struct _OPP_CLIENT_PARAM {DWORD dwSize;WORD wCmdFlags;CHAR szObjectPath[MAX_PATH];

}OPP_CLIENT_PARAM,*POPP_CLIENT_PARAM;

MembersdwSize

Size of the structure, in bytes.wCmdFlags

Specifies which command is to be executed when connected to the OPP service. This parameter can be one of the following values:Value MeaningOPP_COMMAND_PUSH Push a file to the remote deviceOPP_COMMAND_PULL Pull the owner card from the remote device

szObjectPathSpecifies the object’s full path. This parameter is ignored if wCmdFlags is OPP_COMMAND_PULL.

4.6 SYNC_CLIENT_PARAM

The SYNC_CLIENT_PARAM contains SYNC profile connection parameters for function BT_ConnectService (with service class CLS_IRMC_SYNC).

typedef struct _SYNC_CLIENT_PARAM{DWORD dwSize;BOOL bShowSyncDlg;UCHAR ucSyncType;

}SYNC_CLIENT_PARAM,*PSYNC_CLIENT_PARAM;

MembersdwSize

Size of the structure, in bytes.bShowSyncDlg

Indicates whether to show a synchronization dialog and let user control the synchronization operation. If bShowSyncDlg is FALSE, the synchronization dialog will not be shown and the object types specified by ucSyncType will be automatically be synchronized when connected to the service.

ucSyncTypeSpecifies which object type is to be synchronized when connected to the SYNC service, in case bShowSyncDlg is set to FALSE. This parameter can be any combination of the following values:

Copyright © 2004, IVT Corporation, http://www.ivtcorporation.comAll specifications are preliminary and subject to change without notice.

6

Page 10: IVT BlueSoleil Bluetooth APIread.pudn.com › downloads161 › ebook › 728784 › 蓝牙模 …  · Web viewBluetooth API for Windows. Reference Manual. Nov 1st, 2004 . IVT CORPORATION.

BlueSoleil Bluetooth API Reference Manual

Value MeaningSYNC_VCARD vCard format objectsSYNC_VCAL vCal format objectsSYNC_VNOTE vNote format objectsSYNC_VMESSAGE vMsg format objects

4.7 GENERAL_SERVICE_INFO

The GENERAL_SERVICE_INFO structure contains information about a general service. Typically this structure is used by BT_BrowseServices and BT_SearchServices.

typedef struct _GENERAL_SERVICE_INFO {DWORD dwSize;DWORD dwServiceHandle;WORD wServiceClassUuid16;CHAR szServiceName[MAX_SERVICE_NAME_LENGTH];

} GENERAL_SERVICE_INFO, *PGENERAL_SERVICE_INFO;

MembersdwSize

Size of the structure, in bytes.dwServiceHandle

Service handle for SDP.wServiceClassUuid16

16bits service class of the service.szServiceName

A NULL-terminated string specifying the name of the service.

4.8 SPPEX_SERVICE_INFO

The SPPEX_SERVICE_INFO structure contains information about an extended serial port service, which has a 128bits-GUID. This structure is used by BT_SearchSPPExService, BT_ConnectSPPExService, BT_DisconnectSPPExService, BT_StartSPPExService and BT_StopSPPExService.

typedef struct _SPPEX_SERVICE_INFO {DWORD dwSize;DWORD dwSDAPRecordHanlde;UUID serviceClassUuid128;CHAR szServiceName[MAX_SERVICE_NAME_LENGTH];UCHAR ucServiceChannel;UCHAR ucComIndex;

Copyright © 2004, IVT Corporation, http://www.ivtcorporation.comAll specifications are preliminary and subject to change without notice.

7

Page 11: IVT BlueSoleil Bluetooth APIread.pudn.com › downloads161 › ebook › 728784 › 蓝牙模 …  · Web viewBluetooth API for Windows. Reference Manual. Nov 1st, 2004 . IVT CORPORATION.

BlueSoleil Bluetooth API Reference Manual

} SPPEX_SERVICE_INFO,*PSPPEX_SERVICE_INFO;

MembersdwSize

Size of the structure, in bytes.dwSDAPRecordHanlde

Handle to the SDAP record of the service.serviceClassUuid128

128bits-GUID of the service.szServiceName

Service name, in UTF8 format.ucServiceChannel

Service channel.ucComIndex

COM port number associated with the service.

4.9 GENERAL_CONNECT_INFO

The GENERAL_CONNECT_INFO structure contains general information for an active connection. Typically this structure is used by BT_EnumConnections.

typedef struct _GENERAL_CONNECT_INFO {DWORD dwHandle;BOOL bIsOutgoing;WORD wServiceClasss;BYTE remoteBdAddr[DEVICE_ADDRESS_LENGTH];

} GENERAL_CONNECT_INFO,*PGENERAL_CONNECT_INFO;

MembersdwHandle

Handle to the connection. bIsOutgoing

Indicates whether the connection is initiated by local device..wServiceClasss

16bits UUID of the service associated with the connection.remoteBdAddr

Bluetooth address of the remote device.

Copyright © 2004, IVT Corporation, http://www.ivtcorporation.comAll specifications are preliminary and subject to change without notice.

8

Page 12: IVT BlueSoleil Bluetooth APIread.pudn.com › downloads161 › ebook › 728784 › 蓝牙模 …  · Web viewBluetooth API for Windows. Reference Manual. Nov 1st, 2004 . IVT CORPORATION.

BlueSoleil Bluetooth API Reference Manual

5 Function Reference

5.1 BT_InitializeLibrary

This function initializes context for subsequent Bluetooth function calls.

BOOL BT_InitializeLibrary(); Parameters

None.

Return ValuesTRUE indicates success. FALSE indicates failure.

RemarksThis function MUST be called and the return value MUST be TRUE before any other functions (except BT_IsBlueSoleilStarted, BT_IsBluetoothReady and BT_GetVersion.) can be called.This function checks whether BlueSoleil is started and Bluetooth is working; if not, it will try to launch BlueSoleil and wait up to 30 seconds until BlueSoleil is started and Bluetooth is working.Each successful calling to BT_InitializeLibrary must be balanced by a corresponding call to BT_UninitializeLibrary after subsequent Bluetooth function calls are finished.This function is highly recommended to be called only once for successful initialization in an application.

5.2 BT_UninitializeLibrary

This function un-initializes the context created by BT_InitializeLibrary.

void BT_UninitializeLibrary ();

ParametersNone.

Return ValuesNone.

RemarksAn application must call BT_UninitializeLibrary once for each successful call it has made to BT_InitializeLibrary.

Copyright © 2004, IVT Corporation, http://www.ivtcorporation.comAll specifications are preliminary and subject to change without notice.

9

Page 13: IVT BlueSoleil Bluetooth APIread.pudn.com › downloads161 › ebook › 728784 › 蓝牙模 …  · Web viewBluetooth API for Windows. Reference Manual. Nov 1st, 2004 . IVT CORPORATION.

BlueSoleil Bluetooth API Reference Manual

5.3 BT_IsBlueSoleilStarted

This function checks whether BlueSoleil is started.

BOOL BT_IsBlueSoleilStarted(/* [in] */ DWORD dwSeconds );

ParametersdwSeconds

[in] The time (in seconds) to wait before function returns if BlueSoleil is not started

Return ValuesTURE if BlueSoleil is started; otherwise FALSE.

RemarksNone.

5.4 BT_IsBluetoothReady

This function checks whether Bluetooth is working.

BOOL BT_IsBluetoothReady (/* [in] */ DWORD dwSeconds );

ParametersdwSeconds

[in] The time (in seconds) to wait before function returns if Bluetooth is not started

Return ValuesTURE if Bluetooth is started; otherwise FALSE.

RemarksNormally, Bluetooth is started when local Bluetooth device is inserted to user’s computer. Bluetooth is stopped when local Bluetooth device is removed.

5.5 BT_StartBluetooth

This function starts the Buletooth stack of BlueSoleil. Normally this function is called when the Bluetooth stack is shutdown deliberately by calling BT_StopBluetooth(), and later needs to be re-started.

DWORD BT_StartBluetooth();

Copyright © 2004, IVT Corporation, http://www.ivtcorporation.comAll specifications are preliminary and subject to change without notice.

10

Page 14: IVT BlueSoleil Bluetooth APIread.pudn.com › downloads161 › ebook › 728784 › 蓝牙模 …  · Web viewBluetooth API for Windows. Reference Manual. Nov 1st, 2004 . IVT CORPORATION.

BlueSoleil Bluetooth API Reference Manual

ParametersNone.

Return ValuesBTSTATUS_SUCCESS if the function succeeds.BTSTATUS_SYSTEM_ERROR if system error(s) occurs.BTSTATUS_FAIL if the function fails for other reasons.

RemarksBlueSoleil automatically shutdowns it’s Bluetooth stack when it detects that Bluetooth device does not function properly.

5.6 BT_StopBluetooth

This function stops the Buletooth stack of BlueSoleil. Normally this function is called to make the Bluetooth device available for other applications.

DWORD BT_StopBluetooth(BOOL bSwitch2HidMode);

ParametersbSwitch2HidMode

[in] Specifies whether to switch Bluetooth device from HCI mode to HID mode.

Return ValuesBTSTATUS_SUCCESS if the function succeeds.BTSTATUS_SYSTEM_ERROR if system error(s) occurs.BTSTATUS_BT_NOT_READY if Bluetooth is not started.BTSTATUS_FAIL if the function fails for other reasons.

RemarksWhen BlueSoleil detects that a Bluetooth device is plug, BlueSoleil will restarts its Bluetooth stack automatically.

5.7 BT_GetLocalDeviceInfo

This function gets information about local Bluetooth radio device.

DWORD BT_GetLocalDeviceInfo (/* [in] */ DWORD dwMask,/* [out] */ PBLUETOOTH_DEVICE_INFO_EX pDevInfo

);

Copyright © 2004, IVT Corporation, http://www.ivtcorporation.comAll specifications are preliminary and subject to change without notice.

11

Page 15: IVT BlueSoleil Bluetooth APIread.pudn.com › downloads161 › ebook › 728784 › 蓝牙模 …  · Web viewBluetooth API for Windows. Reference Manual. Nov 1st, 2004 . IVT CORPORATION.

BlueSoleil Bluetooth API Reference Manual

ParametersdwMask

[in] Specifies what information should be output. This parameter can be any combination of the following values:Value MeaningMASK_DEVICE_NAME Get the device name.MASK_DEVICE_CLASS Get the device class.MASK_DEVICE_ADDRESS Get the device address.

MASK_LPM_VERSIONGet LPM version, manufacture number and LPM sub version.

pDevInfo[in/out] Pointer to a structure of type BLUETOOTH_DEVICE_INFO _EX .

Return ValuesBTSTATUS_SUCCESS if the function succeeds.BTSTATUS_PARAMETER_ERROR if parameter(s) is (/are) not correctBTSTATUS_SYSTEM_ERROR if system error(s) occurs.BTSTATUS_BT_NOT_READY if Bluetooth is not started.BTSTATUS_FAIL if the function fails for other reasons.

RemarksNone.

5.8 BT_SetLocalDeviceInfo

This function gets information about local device.

DWORD BT_SetLocalDeviceInfo (/* [in] */ DWORD dwMask,/* [out] */ PBLUETOOTH_DEVICE_INFO pDevInfo

);

ParametersdwMask

[in] Specifies what information should be set. This parameter can be any combination of the following values:Value MeaningMASK_DEVICE_NAME Set the device name.MASK_DEVICE_CLASS Set the device class.

pDevInfo

Copyright © 2004, IVT Corporation, http://www.ivtcorporation.comAll specifications are preliminary and subject to change without notice.

12

Page 16: IVT BlueSoleil Bluetooth APIread.pudn.com › downloads161 › ebook › 728784 › 蓝牙模 …  · Web viewBluetooth API for Windows. Reference Manual. Nov 1st, 2004 . IVT CORPORATION.

BlueSoleil Bluetooth API Reference Manual

[in/out] Pointer to a structure of type BLUETOOTH_DEVICE_INFO.

Return ValuesBTSTATUS_SUCCESS if the function succeeds.BTSTATUS_PARAMETER_ERROR if parameter(s) is (/are) not correctBTSTATUS_SYSTEM_ERROR if system error(s) occurs.BTSTATUS_BT_NOT_READY if Bluetooth is not started.BTSTATUS_FAIL if the function fails for other reasons.

RemarksNone.

5.9 BT_GetRemoteDeviceInfo

This function gets information of a specified remote Bluetooth device.

DWORD BT_GetRemoteDeviceInfo (/* [in] */ DWORD dwMask,/* [in] [out] */ PBLUETOOTH_DEVICE_INFO_EX pDevInfo

);

ParametersdwMask

[in] Specifies what information should be output. This parameter can be any combination of the following values:Value MeaningMASK_DEVICE_NAME Get the device name.MASK_DEVICE_CLASS Get the device class.MASK_PAIR_STATUS Get the pairing status with the device.MASK_CONNECT_STATUS Get the connection status with the device.

MASK_LPM_VERSION

Get LPM version, LPM sub version, and manufacture number. These values are available only when the remote device is connected.

MASK_GET_DATA_COUNT

Get the sent/received data count between local device and the remote device. This value is available only when the remote device is connected.

MASK_CLOCK_OFFSETGet clock offset of the device. This value is available only when the remote device is connected.

MASK_SIGNAL_STRENGTH Get the signal strength of the device. This

Copyright © 2004, IVT Corporation, http://www.ivtcorporation.comAll specifications are preliminary and subject to change without notice.

13

Page 17: IVT BlueSoleil Bluetooth APIread.pudn.com › downloads161 › ebook › 728784 › 蓝牙模 …  · Web viewBluetooth API for Windows. Reference Manual. Nov 1st, 2004 . IVT CORPORATION.

BlueSoleil Bluetooth API Reference Manual

value is available only when the remote device is connected.

pDevInfo[in/out] Pointer to a structure of type BLUETOOTH_DEVICE_INFO _EX , member address must be initialized to specify the remote device.

Return ValuesBTSTATUS_SUCCESS if the function succeeds.BTSTATUS_PARAMETER_ERROR if parameter(s) is (/are) not correct.BTSTATUS_DEVICE_NOT_EXIST the specified device is not found in BlueSoleil’s database.BTSTATUS_SYSTEM_ERROR if system error(s) occurs.BTSTATUS_BT_NOT_READY if Bluetooth is not started.BTSTATUS_FAIL if the function fails for other reasons.

RemarksIf BT_GetRemoteDeviceInfo fails to get any one of the specified items, BTSTATUS_FAIL is returned. The remote device is required to be connected with BlueSoleil for getting ucLmpVersion, wManuName, wLmpSubversion, wClockOffset, dwDataRecvBytes dwDataSentBytes and cSignalStrength.

Normally content of device name is from BlueSoleil’s history database. If device name is empty, BlueSoleil tries to get the device name from remote device.

5.10BT_SetRemoteDeviceInfo

This function adds a device’s information to BlueSoleil’s database. If the device address specified already exists, BlueSoleil modifies the corresponding information.

DWORD BT_SetRemoteDeviceInfo (/* [in] */ DWORD dwMask,/* [in] [out] */ PBLUETOOTH_DEVICE_INFO_EX pDevInfo

);

ParametersdwMask

[in] Specifies what information should be set. This parameter can be any combination of the following values:Value MeaningMASK_DEVICE_NAME Set the device name.MASK_DEVICE_CLASS Set the device class.

Copyright © 2004, IVT Corporation, http://www.ivtcorporation.comAll specifications are preliminary and subject to change without notice.

14

Page 18: IVT BlueSoleil Bluetooth APIread.pudn.com › downloads161 › ebook › 728784 › 蓝牙模 …  · Web viewBluetooth API for Windows. Reference Manual. Nov 1st, 2004 . IVT CORPORATION.

BlueSoleil Bluetooth API Reference Manual

MASK_CLOCK_OFFSETSet clock offset of the device, used for setting up ACL connection.

pDevInfo[in/out] Pointer to a structure of type BLUETOOTH_DEVICE_INFO _EX , member address must be initialized.

Return ValuesBTSTATUS_SUCCESS if the function succeeds.BTSTATUS_PARAMETER_ERROR if parameter(s) is (/are) not correctBTSTATUS_SYSTEM_ERROR if system error(s) occurs.BTSTATUS_BT_NOT_READY if Bluetooth is not started.BTSTATUS_FAIL if the function fails for other reasons.

RemarksNone.

5.11BT_PairDevice

This function starts pairing with a remote device.

DWORD BT_PairDevice(/* [in] */ PBLUETOOTH_DEVICE_INFO pDevInfo,/* [in] */ WORD wPinCodeLen,/* [in] */ BYTE* lpPinCode,/* [in] */ BOOL bKeepOldkeyOnFail,/* [in] */ BOOL bShowPincode

);

ParameterspDevInfo

[in] Pointer to a structure of type BLUETOOTH_DEVICE_INFO containing the record of the Bluetooth device to be paired.

wPinCodeLen[in] Specifies the length of the buffer pointed by lpPinCode. If bShowPincode is TRUE, wPinCodeLen must be greater then 0. If wPinCodeLen is 0 and BlueSoleil is not paired with the device yet, BT_PairDevice invokes BlueSoleil’s pair mechanism, prompts the user to enter a pin code, or uses the default pin code if set.

lpPinCode[in] Pointer to a buffer containing the pin code. lpPinCode can be set to NULL if wPinCodeLen is 0.

Copyright © 2004, IVT Corporation, http://www.ivtcorporation.comAll specifications are preliminary and subject to change without notice.

15

Page 19: IVT BlueSoleil Bluetooth APIread.pudn.com › downloads161 › ebook › 728784 › 蓝牙模 …  · Web viewBluetooth API for Windows. Reference Manual. Nov 1st, 2004 . IVT CORPORATION.

BlueSoleil Bluetooth API Reference Manual

bKeepOldKeyOnFail[in] Specifies whether to keep the old stored link key (if there is any) if pairing with the device fails. If bKeepOldkeyOnFail is FALSE, Delete Stored Link Key HCI command will be issued before the pair procedure; If bKeepOldkeyOnFail is TRUE, BT_PairDevice will:

i) Search for the link key in BlueSoleil’s database;ii) If the link key can not be found in BlueSoleil’s database, issue Read Stored Link Key HCI command to retrieve the link key;iii) If the link key is successfully retrieved in step i) or ii), store it;iv) Issue Delete Stored Link Key HCI command and start the pair procedure;v) On fail of the pair procedure, if a link key is available in step iii), issue Write Stored Link Key HCI command to restore the link key.

bShowPincode[in] Specifies whether to show the pin code (specified by lpPinCode) using BlueSoleil’s GUI. If bShowPincode is TRUE, wPinCodeLen must be greater then 0.

Return ValuesBTSTATUS_SUCCESS if BlueSoleil successfully pairs with the device;BTSTATUS_ALREADY_PAIRED if BlueSoleil is already paired with the device and bKeepOldKeyOnFail is FALSE;BTSTATUS_AUTHENTICATE_FAILED if authentication fails.BTSTATUS_BT_BUSY if the remote device is connected, or Bluetooth is busy.BTSTATUS_PARAMETER_ERROR if parameter(s) is (/are) not correct BTSTATUS_SYSTEM_ERROR if system error(s) occurs.BTSTATUS_BT_NOT_READY if Bluetooth is not started.BTSTATUS_FAIL if the function fails for other reasons.

Remarks

To get extended error information for BTSTATUS_FAIL, register a callback function for EVENT_ERROR. Not all failures of BTSTATUS_FAIL generate an error event.

5.12BT_UnpairDevice

This function removes the pair relationship with a remote device.

DWORD BT_UnpairDevice(/* [in] */ BYTE* lpBdAddr);

ParameterslpBdAddr

Copyright © 2004, IVT Corporation, http://www.ivtcorporation.comAll specifications are preliminary and subject to change without notice.

16

Page 20: IVT BlueSoleil Bluetooth APIread.pudn.com › downloads161 › ebook › 728784 › 蓝牙模 …  · Web viewBluetooth API for Windows. Reference Manual. Nov 1st, 2004 . IVT CORPORATION.

BlueSoleil Bluetooth API Reference Manual

[in] Pointer to a 6-bytes buffer containing the device address.

Return ValuesBTSTATUS_SUCCESS if the function succeeds.BTSTATUS_PARAMETER_ERROR if parameter(s) is (/are) not correctBTSTATUS_SYSTEM_ERROR if system error(s) occurs.BTSTATUS_BT_NOT_READY if Bluetooth is not started.BTSTATUS_FAIL if the function fails for other reasons.

RemarksNone.

5.13BT_ConnectService

This function connects to a service on the remote device,

DWORD BT_ConnectService(/* [in] */ PBLUETOOTH_DEVICE_INFO pDevInfo, /* [in] */ PGENERAL_SERVICE_INFO pServiceInfo,/* [in, out] */ BYTE* lpParam,/* [out] */ DWORD* lpConnectionHandle

);

ParameterspDevInfo

[in] Pointer to a structure of type BLUETOOTH_DEVICE_INFO containing the record of the Bluetooth device.

pServiceInfo[in] Pointer to a structure of type GENERAL_SERVICE_INFO containing the service information. BlueSoleil searches services specified by member dwServiceClass, if member dwServiceHandle is NULL, BlueSoleil connects to the first service if any is found, otherwise BlueSoleil connects to the service that matches dwServiceHandle.

lpParam[in,out] Pointer to a buffer containing additional connecting parameters. The structure of buffer depends on wServiceClass member of GENERAL_SERVICE_INFO pointed by pServiceInfo. Not every service class has a connecting parameter data structure, for those that do not have corresponding parameter data structures, lpParam must be set to NULL.Service Class Buffer StuctureCLS_SERIAL_PORT SPP_CLIENT_PARAM [out]CLS_DIALUP_NET DUN_CLIENT_PARAM [in]/NULL

Copyright © 2004, IVT Corporation, http://www.ivtcorporation.comAll specifications are preliminary and subject to change without notice.

17

Page 21: IVT BlueSoleil Bluetooth APIread.pudn.com › downloads161 › ebook › 728784 › 蓝牙模 …  · Web viewBluetooth API for Windows. Reference Manual. Nov 1st, 2004 . IVT CORPORATION.

BlueSoleil Bluetooth API Reference Manual

CLS_IRMC_SYNC SYNC_CLIENT_PARAM [in]CLS_OBEX_OBJ_PUSH OPP_CLIENT_PARAM [in]

dwConnectionHandle[out] Pointer to a variable that receives the connection handle if BT_ConnectService returns successfully. To disconnect from the service, applications should call BT_DisconnectService with this handle as the input parameter.

Return ValuesBTSTATUS_SUCCESS if BlueSoleil successfully connects to the service on the device.BTSTATUS_CONNECTION_EXIST if the connection to the service is already established.BTSTATUS_SERVICE_NOT_EXIST if the specified service can not be found or the remote device can not be connected.BTSTATUS_BT_BUSY if Bluetooth is busy with browsing services or connecting to a device.BTSTATUS_PARAMETER_ERROR if parameter(s) is (/are) not correctBTSTATUS_SYSTEM_ERROR if system error(s) occurs.BTSTATUS_BT_NOT_READY if Bluetooth is not started.BTSTATUS_FAIL if fails for any other reasons.

RemarksBT_ConnectService returns after the connection process is completed, during the process, connection status or other events will be notified if callback functions for these events are registered.

To get extended error information for BTSTATUS_FAIL, register a callback function for EVENT_ERROR. Not all failures of BTSTATUS_FAIL generate an error event.

CLS_DIALUP_NET:If lpParam is NULL, BlueSoleil makes the Bluetooth connection only and does not dail up. User application is responsible to do dial up operations on the COM port associated with the connection. To get the COM port associated with the connection, call BT_GetConnectInfo.

5.14BT_DisconnectService

This function disconnects from a service on a remote device.

DWORD BT_DisconnectService (/* [in] */ DWORD dwConnectionHandle);

Copyright © 2004, IVT Corporation, http://www.ivtcorporation.comAll specifications are preliminary and subject to change without notice.

18

Page 22: IVT BlueSoleil Bluetooth APIread.pudn.com › downloads161 › ebook › 728784 › 蓝牙模 …  · Web viewBluetooth API for Windows. Reference Manual. Nov 1st, 2004 . IVT CORPORATION.

BlueSoleil Bluetooth API Reference Manual

ParametersdwConnectionHandle

[in] Specifies the handle of the connection output by BT_ConnectService or reported by callback.

Return ValuesBTSTATUS_SUCCESS if the function succeeds.BTSTATUS_CONNECTION_NOT_EXIST if the connection does not exist or is released.BTSTATUS_PARAMETER_ERROR if parameter(s) is (/are) not correctBTSTATUS_SYSTEM_ERROR if system error(s) occurs.BTSTATUS_BT_NOT_READY if Bluetooth is not started.BTSTATUS_FAIL if the function fails for other reasons.

RemarksFor incoming connections that are initiated by remote device, BT_DisconnectService only supports PAN profile.

5.15BT_InquireDevices

This function inquires nearby Bluetooth devices or gets paired devices from BlueSoleil’s history records.

DWORD BT_InquireDevices(/* [in] */ UCHAR ucInqMode,/* [in] */ UCHAR ucInqTimeLen,/* [in, out] */ DWORD* lpDevsListLength,/* [out] */ PBLUETOOTH_DEVICE_INFO pDevsList,

);

ParametersucInqMode

[in] Specifies the inquiry mode:Value MeaningINQUIRY_GENERAL Inquires using general-discovery modeINQUIRY_LIMITED Inquires using limited-discovery mode

INQUIRY_PAIREDGets paired devices from history list without performing Bluetooth inquiry.

INQUIRY_GENERAL_REFRESH Inquires using general-discovery mode, clears devices in memory before performing the inquiry.

Copyright © 2004, IVT Corporation, http://www.ivtcorporation.comAll specifications are preliminary and subject to change without notice.

19

Page 23: IVT BlueSoleil Bluetooth APIread.pudn.com › downloads161 › ebook › 728784 › 蓝牙模 …  · Web viewBluetooth API for Windows. Reference Manual. Nov 1st, 2004 . IVT CORPORATION.

BlueSoleil Bluetooth API Reference Manual

ucInqTimeLen[in] Maximum amount of time before the inquiry is halted.Range: 0x01 – 0x30Time = N * 1.28 secRange: 1.28 – 61.44 Sec.

lpDevsListLength[in,out] Pointer to a variable that specifies the length of the buffer pointed by lpDevsList, after the function returns, the variable receives the length of data copied to the buffer.If value (*lpDevsListLength) is zero, the function returns immediately after Bluetooth inquiry is started, inquiry results will be reported if callback function for EVENT_INQUIRY_DEVICE_REPORT is registered.

lpDevsList[out] Pointer to a BLUETOOTH_DEVICE_INFO array buffer that receives the device information. This parameter can be NULL if (*lpDevsListLength) is zero..

Return ValuesBTSTATUS_SUCCESS if the function succeeds.BTSTATUS_PARAMETER_ERROR if parameter(s) is error.BTSTATUS_SYSTEM_ERROR if system error(s) occurs.BTSTATUS_BT_NOT_READY if Bluetooth is not started.BTSTATUS_FAIL if the function fails for other reasons.

RemarksIf value (*lpDevsListLength) is not zero, the function is synchronous, when it returns successfully, the number of BLUETOOTH_DEVICE_INFO in the lpDevsList buffer can be calculated by expression: (*lpDevsListLength)/sizeof(BLUETOOTH_DEVICE_INFO).

If a callback function for EVENT_INQUIRY_DEVICE_REPORT is registered, inquiry results will be reported regardless of value (*lpDevsListLength).

5.16BT_CancelInquiry

This function cancels the ongoing inquiry of device and query of device names.

DWORD BT_CancelInquiry ();

ParametersNone.

Return Values

Copyright © 2004, IVT Corporation, http://www.ivtcorporation.comAll specifications are preliminary and subject to change without notice.

20

Page 24: IVT BlueSoleil Bluetooth APIread.pudn.com › downloads161 › ebook › 728784 › 蓝牙模 …  · Web viewBluetooth API for Windows. Reference Manual. Nov 1st, 2004 . IVT CORPORATION.

BlueSoleil Bluetooth API Reference Manual

BTSTATUS_SUCCESS if the function succeeds.BTSTATUS_SYSTEM_ERROR if system error(s) occurs.BTSTATUS_BT_NOT_READY if Bluetooth is not started.BTSTATUS_FAIL if the function fails for other reasons.

RemarksIf BT_InquireDevices is called in synchronous mode, calling BT_CancelInquiry from a thread separate from the one waiting for BT_InquireDevices will cancel the inquiry and make BT_InquireDevices return immediately.

5.17BT_BrowseServices

This function browses all services or searches a specified service on a remote device.

DWORD BT_BrowseServices(/* [in] */ PBLUETOOTH_DEVICE_INFO pDevInfo,/* [in] */ BOOL bBrowseAllServices,/* [in][out] */ DWORD* lpServiceClassListLength,/* [in][out] */ PGENERAL_SERVICE_INFO pSeriveClassList

);

ParameterspDevInfo

[in] Pointer to a structure of type BLUETOOTH_DEVICE_INFO containing the record of the device.

bBrowseAllServices[in] Specifies whether to browse all services supported by the device.

lpServiceClassListLength[in/out] Pointer to a variable that specifies the length (in bytes) of the buffer pointed by lpSeriveClassList, after the function returns, this variable contains the length of data copied to the buffer.

pSeriveClassList[in/out] Pointer to a GENERAL_ SERVICE_INFO array buffer that receives the services found on the device. If bBrowseAllServices is FALSE, the first element of the array specifies the service class to search, and the variable pointed by lpServiceClassListLength must not be less than 1*sizeof(GENERAL_ SERVICE_INFO).

Return ValuesBTSTATUS_SUCCESS if the function succeeds.BTSTATUS_SERVICE_NOT_EXIST if no service is found.BTSTATUS_PARAMETER_ERROR if parameter(s) is (/are) not correctBTSTATUS_SYSTEM_ERROR if system error(s) occurs.

Copyright © 2004, IVT Corporation, http://www.ivtcorporation.comAll specifications are preliminary and subject to change without notice.

21

Page 25: IVT BlueSoleil Bluetooth APIread.pudn.com › downloads161 › ebook › 728784 › 蓝牙模 …  · Web viewBluetooth API for Windows. Reference Manual. Nov 1st, 2004 . IVT CORPORATION.

BlueSoleil Bluetooth API Reference Manual

BTSTATUS_BT_NOT_READY if Bluetooth is not started.BTSTATUS_FAIL if the function fails for other reasons.

RemarksWhen the function returns successfully, the number of class in the lpServiceClassList buffer can be calculated by expression:(*lpServiceClassListLength)/sizeof(GENERAL_ SERVICE_INFO).

To get extended error information for BTSTATUS_FAIL, register a callback function for EVENT_ERROR. Not all failures of BTSTATUS_FAIL generate an error event.

5.18BT_GetConnectInfo

This function gets the information related to a connection handle.

DWORD BT_GetConnectInfo (/* [in] */ DWORD dwHandle,/* [out] */ BOOL* lpIsOutgoing,/* [out] */ WORD* lpServiceClasss,/* [out] */BYTE* lpRemoteBdAddr,/* [in][out] */ lpConnInfoLen,/* [out] */ lpConnInfo

);

ParametersdwHandle

[in] Handle to the connection. By registering a callback function for EVENT_CONNECTION_STATUS, connection handles are reported to applications when connections are established.

lpIsOutgoing[out] Pointer to a variable that receives the value specifying the connection direction. lpIsOutgoing can NOT be NULL.

lpServiceClass[out] Pointer to a variable that receives the service class related to the connection. lpServiceClass can NOT be NULL.

lpRemoteBdAddr[out] Pointer to a 6-bytes buffer receives the remote device address related to connection. lpRemoteBdAddr can NOT be NULL.

lpConnInfoLen[in/out] Pointer to a variable that specifies the length (in bytes) of the buffer pointed by lpConnInfo, after the function returns, this variable contains the length of data copied to the buffer. lpConnInfoLen can NOT be NULL.

Copyright © 2004, IVT Corporation, http://www.ivtcorporation.comAll specifications are preliminary and subject to change without notice.

22

Page 26: IVT BlueSoleil Bluetooth APIread.pudn.com › downloads161 › ebook › 728784 › 蓝牙模 …  · Web viewBluetooth API for Windows. Reference Manual. Nov 1st, 2004 . IVT CORPORATION.

BlueSoleil Bluetooth API Reference Manual

lpConnInfo[out] Pointer to a data buffer that receives the additional information to the connection handle. The structure of the data buffer depends on the service class related to the connection:Service Class Buffer StuctureCLS_SERIAL_PORT SPP_CONNECT_INFO(SPP_CLIENT_PARAM)CLS_DIALUP_NET SPP_CONNECT_INFO(SPP_CLIENT_PARAM)CLS_FAX SPP_CONNECT_INFO(SPP_CLIENT_PARAM)

lpConnInfo can be NULL if *lpConnInfoLen is 0.Return Values

BTSTATUS_SUCCESS if the function succeeds.BTSTATUS_PARAMETER_ERROR if parameter(s) is (/are) not correctBTSTATUS_SYSTEM_ERROR if system error(s) occurs.BTSTATUS_BT_NOT_READY if Bluetooth is not started.BTSTATUS_FAIL if the function fails for other reasons.

RemarksNone.

5.19BT_StartSPPExService

This function starts a specific SPP service which has a 128bits-GUID.

DWORD BT_StartSPPExService (/* [in][out] */ PSPPEX_SERVICE_INFO pServiceInfo,/* [out] */ DWORD* lpServerHandle

);

ParameterspServiceInfo

[in/out] Pointer to a structure of type SPPEX_SERVICE_INFO, serviceClassUuid128 member must be initialized, after the function returns successfully, dwSDAPRecordHandle member contains the handle to the SDAP record of the service, ucServiceChannel member contains the service channel.

lpServerHandle[out] Pointer to a variable that receives the server handle if BT_StartSPPExService succeeds. In order to stop the service, applications should call BT_StopSPPExService taking the output lpServerHandle as an input parameter.

Return ValuesBTSTATUS_SUCCESS if the function succeeds.

Copyright © 2004, IVT Corporation, http://www.ivtcorporation.comAll specifications are preliminary and subject to change without notice.

23

Page 27: IVT BlueSoleil Bluetooth APIread.pudn.com › downloads161 › ebook › 728784 › 蓝牙模 …  · Web viewBluetooth API for Windows. Reference Manual. Nov 1st, 2004 . IVT CORPORATION.

BlueSoleil Bluetooth API Reference Manual

BTSTATUS_PARAMETER_ERROR if parameter(s) is error.BTSTATUS_SYSTEM_ERROR if system error(s) occurs.BTSTATUS_BT_NOT_READY if Bluetooth is not started.BTSTATUS_FAIL if the function fails for other reasons.

RemarksTo be notified when a remote device connects to the started SPP service, register a callback function for EVENT_SPPEX_CONNECTION_STATUS.

5.20BT_StopSPPExService

This function stops a specific SPP service which has a 128bits-GUID.

DWORD BT_StopSPPExService(/* [in] */ DWORD dwServerHandle);

ParametersdwServerHandle

[in] Handle to the service output by BT_StartSPPExService.

Return ValuesBTSTATUS_SUCCESS if the function succeeds.BTSTATUS_PARAMETER_ERROR if parameter(s) is error.BTSTATUS_SYSTEM_ERROR if system error(s) occurs.BTSTATUS_BT_NOT_READY if Bluetooth is not started.BTSTATUS_FAIL if the function fails for other reasons.

RemarksNone.

5.21BT_SearchSPPExServices

This function searches extended SPP services which have a 128bits-GUID on a remote device..

DWORD BT_SearchSPPExServices (/* [in] */ PBLUETOOTH_DEVICE_INFO pDevInfo,/* [in][out] */ DWORD* lpServiceClassListLength,/* [in][out] */ PSPPEX_SERVICE_INFO pSeriveClassList

);

ParameterspDevInfo

Copyright © 2004, IVT Corporation, http://www.ivtcorporation.comAll specifications are preliminary and subject to change without notice.

24

Page 28: IVT BlueSoleil Bluetooth APIread.pudn.com › downloads161 › ebook › 728784 › 蓝牙模 …  · Web viewBluetooth API for Windows. Reference Manual. Nov 1st, 2004 . IVT CORPORATION.

BlueSoleil Bluetooth API Reference Manual

[in] Pointer to a structure of type BLUETOOTH_DEVICE_INFO containing the record of the device.

lpServiceClassListLength[in/out] Pointer to a variable that specifies the length (in bytes) of the buffer pointed by lpSeriveClassList, and must be greater than 1*sizeof(SPPEX_ SERVICE_INFO). After the function returns, this variable contains the length of data copied to the buffer.

pSeriveClassList[in/out] lpSeriveClassList is a pointer to a SPPEX_ SERVICE_INFO array buffer that receives the services found on the device. The array must have at least one element and the first element specifies the 128bits-GUID to search.

Return ValuesBTSTATUS_SUCCESS if the function succeeds.BTSTATUS_SERVICE_NOT_EXIST if the service is not found.BTSTATUS_PARAMETER_ERROR if parameter(s) is error.BTSTATUS_SYSTEM_ERROR if system error(s) occurs.BTSTATUS_BT_NOT_READY if Bluetooth is not started.BTSTATUS_FAIL if the function fails for other reasons.

RemarksWhen the function returns successfully, the number of class in the lpServiceClassList buffer can be calculated by expression:(*lpServiceClassListLength)/sizeof(SPPEX_ SERVICE_INFO).

To get extended error information for BTSTATUS_FAIL, Register a callback function for EVENT_ERROR. Not all failures of BTSTATUS_FAIL generate an error event

5.22BT_ConnectSPPExService

This function connects to a RFCOMM-based service with 128bits-GUID on a remote device.

DWORD BT_ConnectSPPExService (/* [in] */ PBLUETOOTH_DEVICE_INFO pDevInfo,/* [in][out] */ PSPPEX_SERVICE_INFO pServiceInfo,/* [out] */ DWORD* lpConnectionHandle

);

ParameterspDevInfo

[in] Pointer to a structure of type BLUETOOTH_DEVICE_INFO containing the record of the device.

Copyright © 2004, IVT Corporation, http://www.ivtcorporation.comAll specifications are preliminary and subject to change without notice.

25

Page 29: IVT BlueSoleil Bluetooth APIread.pudn.com › downloads161 › ebook › 728784 › 蓝牙模 …  · Web viewBluetooth API for Windows. Reference Manual. Nov 1st, 2004 . IVT CORPORATION.

BlueSoleil Bluetooth API Reference Manual

pServiceInfo[in/out] Pointer to a structure of type SPPEX_SERVICE_INFO, serviceClassUuid128 member must be initialized. BlueSoleil connects to the first service if any is found. After the function returns successfully, dwSDAPRecordHandle member contains the handle to the SDAP record of the service, szServiceName member contains the name of the service, ucServiceChannel member contains the service channel, ucComIndex contains the COM port number associated with the connection.

lpConnectionHandle[out] Pointer to a variable that receives the connection handle if BT_ConnectSPPExService succeeds. To disconnect from the service, call BT_DisconnectSPPExService with the output lpConnectionHandle as an input parameter.

Return ValuesBTSTATUS_SUCCESS if the function succeeds.BTSTATUS_PARAMETER_ERROR if parameter(s) is (/are) not correctBTSTATUS_SYSTEM_ERROR if system error(s) occurs.BTSTATUS_BT_NOT_READY if Bluetooth is not started.BTSTATUS_FAIL if the function fails for other reasons.

RemarksTo get extended error information for BTSTATUS_FAIL, Register a callback function for EVENT_ERROR. Not all failures of BTSTATUS_FAIL generate an error event.

5.23BT_DisconnectSPPExService

This function disconnects from a specific SPP service which has a 128bits-GUID.

DWORD BT_DisconnectSPPExService(/* [in] */ DWORD dwConnectionHandle

);

ParametersdwConnectionHandle

[in] The connection handle output by BT_ConnectSPPExService.

Return ValuesBTSTATUS_SUCCESS if the function succeeds.BTSTATUS_CONNECTION_NOT_EXIST if the connection does not exist or is released.BTSTATUS_PARAMETER_ERROR if parameter(s) is (/are) not correctBTSTATUS_SYSTEM_ERROR if system error(s) occurs.

Copyright © 2004, IVT Corporation, http://www.ivtcorporation.comAll specifications are preliminary and subject to change without notice.

26

Page 30: IVT BlueSoleil Bluetooth APIread.pudn.com › downloads161 › ebook › 728784 › 蓝牙模 …  · Web viewBluetooth API for Windows. Reference Manual. Nov 1st, 2004 . IVT CORPORATION.

BlueSoleil Bluetooth API Reference Manual

BTSTATUS_BT_NOT_READY if Bluetooth is not started.BTSTATUS_FAIL if the function fails for other reasons.

RemarksNone.

5.24BT_RegisterCallback

This function registers an application-defined callback function for a Bluetooth event.

DWORD BT_RegisterCallback(/* [in] */ UCHAR ucEvent,/* [in] */ LPVOID pfnCbkFun

);

ParametersucEvent

[in] Specifies which event applications want to be notified. ucEvent can be one of the following value.

Value Meaning

EVENT_CONNECTION_STATUSGeneral connection status is changed.

EVENT_DUN_RAS_CALLBACK RAS connection error occurs.EVENT_ERROR An error occurs.

EVENT_INQUIRY_DEVICE_REPORTA remote Bluetooth device is found during Bluetooth inquiry.

EVENT_SPPEX_CONNECTION_STATUS

Specific SPP connection status is changed.

EVENT_BLUETOOTH_STATUS Bluetooth is started or stopped

pfnCbkFun[in] Pointer to the callback function that will be called when the event occurs. Prototypes of the callback functions are:

EVENT_CONNECTION_STATUS:typedef void (*PCALLBACK_CONNECTION_STATE_CHANGED)

(WORD wServiceClass, BYTE* lpBdAddr, UCHAR ucStatus, DWROD dwConnetionHandle);Parameters:

wServiceClass[in] Specifies the class of the service associated with the connection.

Copyright © 2004, IVT Corporation, http://www.ivtcorporation.comAll specifications are preliminary and subject to change without notice.

27

Page 31: IVT BlueSoleil Bluetooth APIread.pudn.com › downloads161 › ebook › 728784 › 蓝牙模 …  · Web viewBluetooth API for Windows. Reference Manual. Nov 1st, 2004 . IVT CORPORATION.

BlueSoleil Bluetooth API Reference Manual

lpBdAddr[in] Pointer to a 6-bytes buffer containing the address of the remote device associated with the connection.

ucStatus[in] Indicates the current connection status:

Value MeaningSTATUS_INCOMING_CONNECT An incoming connection is established.STATUS_INCOMING_DISCONNECT An incoming connection is released.STATUS_OUTCOMING_CONNECT An outgoing connection is established.STATUS_OUTCOMING_DISCONNECT An outgoing connection is released.

dwConnetionHandle[in] Handle to the connection.

EVENT_DUN_RAS_CALLBACK:typedef void (*PCALLBACK_RAS_CONNECTION_STATE)(UCHAR ucStrLen, CHAR* szErrorString, DWORD dwError);

EVENT_ERRORtypedef void (*PCALLBACK_ERROR) (DWORD dwErrorCode);Parameters:

dwErrorCode:[in] Error code. Values 0x01-0xff have the same meaning corresponding to HCI error values defined in Bluetooth Specification.

EVENT_INQUIRY_DEVICE_REPORT:typedef void (*PCALLBACK_INQUIRY_DEVICE) (PBLUETOOTH_DEVICE_INFO pDevInfo);Parameters:

pDevInfo[in] Pointer to a structure of type BLUETOOTH_DEVICE_INFO containing the record of the device. Content of member szName is from BlueSoleil’s history database. If member address and classOfDevice contain all zeros, it indicates that the inquiry completes, though BlueSoleil may continue to query device names.

RemarksA device with the same device address may be reported more than one 1 time, client applications are expected to filter duplicated devices.

EVENT_SPPEX_CONNECTION_STATUS:typedef void (*PCALLBACK_SPPEX_CONNECTION_STATUS) (DWORD dwServerHandle, BYTE* lpBdAddr, UCHAR ucStatus, DWORD dwConnetionHandle);

Copyright © 2004, IVT Corporation, http://www.ivtcorporation.comAll specifications are preliminary and subject to change without notice.

28

Page 32: IVT BlueSoleil Bluetooth APIread.pudn.com › downloads161 › ebook › 728784 › 蓝牙模 …  · Web viewBluetooth API for Windows. Reference Manual. Nov 1st, 2004 . IVT CORPORATION.

BlueSoleil Bluetooth API Reference Manual

Parameters:dwServerHandle

[in] The handle to the specific SPP service. By comparing to the handle returned by BT_StartSPPExService, dwServerHandle can be used to retrieve related service information, e.g. COM port associated to the service.

lpBdAddr[in] Pointer to a 6-bytes buffer containing the address of the remote device associated with the connection. The address is invalid if ucStatus is STATUS_INCOMING_DISCONNECT.

ucStatus[in] Connection status:

Value MeaningSTATUS_INCOMING_CONNECT An incoming connection is established.STATUS_INCOMING_DISCONNECT An incoming connection is released.

dwConnetionHandle[in] Reserved.

EVENT_BLUETOOTH_STATUS:typedef void (*PCALLBACK_BLUETOOTH_STATUS) (UCHAR ucStatus);Parameters:

ucStatus[in] Indicates the current status of Bluetooth, this parameter is one of the following value:

Value MeaningSTATUS_BLUETOOTH_STARTED Bluetooth is started.STATUS_BLUETOOTH_STOPED Bluetooth is stoped.

Return ValuesBTSTATUS_SUCCESS if the function succeeds.BTSTATUS_PARAMETER_ERROR if parameter(s) is (/are) not correctBTSTATUS_BT_NOT_READY if Bluetooth is not started.BTSTATUS_SYSTEM_ERROR if system error(s) occurs.BTSTATUS_FAIL if the function fails for other reasons.

RemarksIf BlueSoleil exits, all registered events will be discarded, the associated callbacks will not work after BlueSoleil is restarted. To keep callbacks working, an application must call BT_UninitializeLibrary when it detects BlueSoleil exits, and call BT_InitializeLibrary and BT_RegisterCallback again after BlueSoleil is restarted.

Copyright © 2004, IVT Corporation, http://www.ivtcorporation.comAll specifications are preliminary and subject to change without notice.

29

Page 33: IVT BlueSoleil Bluetooth APIread.pudn.com › downloads161 › ebook › 728784 › 蓝牙模 …  · Web viewBluetooth API for Windows. Reference Manual. Nov 1st, 2004 . IVT CORPORATION.

BlueSoleil Bluetooth API Reference Manual

It is recommended that, the Bluetooth APIs defined in this document should not be called in the users’ callback functions registered by BT_RegisterCallback to prevent any potential deadlock in codes.

5.25BT_UnregisterCallback

This function un-registers an application-defined callback function for a Bluetooth event.

DWORD BT_UnregisterCallback (/* [in] */ UCHAR ucEvent);

ParametersucEvent

[in] Specifies which event applications want to remove from previous register by BT_RegisterCallback.

Return ValuesBTSTATUS_SUCCESS if the function succeeds.BTSTATUS_PARAMETER_ERROR if parameter(s) is (/are) not correctBTSTATUS_BT_NOT_READY if Bluetooth is not started.BTSTATUS_SYSTEM_ERROR if system error(s) occurs.BTSTATUS_FAIL if the function fails for other reasons.

RemarksNone.

5.26BT_GetVersion

This function returns the version number of current API series.

DWORD BT_GetVersion();

ParametersNone.

Return ValuesA DWORD value that contains the major and minor version numbers of the current API series.

RemarksThe low order word contains the version number of the current API series. The low-order byte of this word specifies the major version number. The high-order byte specifies the minor version (revision) number.

Copyright © 2004, IVT Corporation, http://www.ivtcorporation.comAll specifications are preliminary and subject to change without notice.

30

Page 34: IVT BlueSoleil Bluetooth APIread.pudn.com › downloads161 › ebook › 728784 › 蓝牙模 …  · Web viewBluetooth API for Windows. Reference Manual. Nov 1st, 2004 . IVT CORPORATION.

BlueSoleil Bluetooth API Reference Manual

5.27BT_GetBtSpecVersion

This function returns BT specification version number (1.1/1.2) that BlueSoleil stack conforms to.

DWORD BT_GetBtSpecVersion (/* [out] */ DWORD* lpBtSpecVersion);

ParameterslpBtSpecVersion

Pointer to a variable that receives t version number.

Return ValuesBTSTATUS_SUCCESS if the function succeeds.BTSTATUS_PARAMETER_ERROR if parameter(s) is (/are) not correctBTSTATUS_SYSTEM_ERROR if system error(s) occurs.BTSTATUS_FAIL if the function fails for other reasons.

RemarksIf this function returns successfully, the low order word of (*lpBtSpecVersion) contains the version number. The low-order byte of this word specifies the major version number. The high-order byte specifies the minor version number.

5.28BT_EnumConnections

This function enumerates all active connections in BlueSoleil.

DWORD BT_EnumConnection(/* [in, out] */ DWORD *lpBufferLen/* [out] */ PGENERAL_CONNECT_INFO lpBuffer

);

ParameterslpBufferLen

[in/out] Pointer to a variable containing the size (in bytes) of the buffer pointed to by pBuffer. On return, the variable receives the length of data copied to the buffer.

lpBuffer[out] Pointer to a GENERAL_CONNECT_INFO array buffer that receives the active connection information.

Return ValuesBTSTATUS_SUCCESS if the function succeeds.

Copyright © 2004, IVT Corporation, http://www.ivtcorporation.comAll specifications are preliminary and subject to change without notice.

31

Page 35: IVT BlueSoleil Bluetooth APIread.pudn.com › downloads161 › ebook › 728784 › 蓝牙模 …  · Web viewBluetooth API for Windows. Reference Manual. Nov 1st, 2004 . IVT CORPORATION.

BlueSoleil Bluetooth API Reference Manual

BTSTATUS_PARAMETER_ERROR if parameter(s) is (/are) not correctBTSTATUS_SYSTEM_ERROR if system error(s) occurs.BTSTATUS_BT_NOT_READY if Bluetooth is not started.BTSTATUS_FAIL if the function fails for other reasons.

RemarksWhen the function returns successfully, the number of handles in the lpBuffer buffer can be calculated by expression:(*lpBufferLen)/sizeof(GENERAL_CONNECT_INFO).

To get extended information for a connection handle, call BT_GetConnectInfo.

Copyright © 2004, IVT Corporation, http://www.ivtcorporation.comAll specifications are preliminary and subject to change without notice.

32