BthSetPIN

Other versions of this page are also available for the following:

Windows Mobile Not SupportedWindows Embedded CE Supported

8/28/2008

This function stores the personal identification number (PIN) for the Bluetooth device.

Note

To preserve Win32 compatibility, consider using the Winsock equivalent of this function. To do so, pass SO_BTH_SET_PIN as the optname value in setsockopt.

Syntax

int BthSetPIN(
  BT_ADDR* pba,
  int cPinLength,
  unsigned char* ppin
);

Parameters

  • pba
    [in] Pointer to the Bluetooth address.
  • cPinLength
    [in] PIN length must be between 1 and 16 bytes.
  • ppin
    [in] Pointer to the PIN. The PIN is an ASCII string that is not terminated by \0. Although it can be any binary data, it is typically limited to digits that can be dialed on the phone (0-9) or typed on a computer keyboard (alphanumeric characters).

Return Value

This function returns ERROR_SUCCESS when it completes successfully.

A return value of ERROR_SERVICE_NOT_ACTIVE indicates that the Bluetooth stack is not present.

Other standard error codes may be returned as appropriate.

Remarks

Stores the pin for the Bluetooth device identified in pba. The active connection to the device is not necessary, nor is the presence of the Bluetooth controller. The PIN is persisted in the registry until BthRevokePIN is called.

While the PIN is stored, it is supplied automatically after the PIN request is issued by the authentication mechanism, so the user will not be prompted for it. Typically, for UI-based devices, you would set the PIN for the duration of authentication, and then revoke it after authentication is complete.

Requirements

Header bt_api.h
Library Btdrt.lib
Windows Embedded CE Windows CE .NET 4.2 and later

See Also

Reference

Bluetooth OS Functions
BthRevokePIN

Other Resources

Bluetooth Application Development