BthSetPIN (Compact 2013)
3/26/2014
This function stores the personal identification number (PIN) for the Bluetooth device.
Syntax
int BthSetPIN(
BT_ADDR *pba,
int cPinLength,
unsigned char *ppin
);
Parameters
- pba
[in] Pointer to the address that identifies the remote device.
- cPinLength
[in] Length of PIN pointed to by ppin. PIN length must be 1 through 16 characters.
- ppin
[in] Pointer to the PIN.
Return Value
The following table shows the possible return values.
Value |
Description |
---|---|
ERROR_SUCCESS |
Success. |
ERROR_INVALID_PARAMETER |
The PIN length is incorrect. |
ERROR_SERVICE_NOT_ACTIVE |
The Bluetooth stack is not present. |
Other standard HRESULT error codes may be returned as appropriate.
Remarks
This function stores the PIN for the Bluetooth device identified in pba. An active connection to the device is not required. The PIN is stored in the registry until BthRevokePIN is called. The authentication mechanism retrieves the PIN from the registry as needed.
Typically, for UI-based devices, you would set the PIN for the duration of authentication, and then revoke it after authentication is complete.
Note that the PIN is different from the passkey supplied by the user during Secure Simple Pairing.
Note
To preserve Microsoft Win32 compatibility, consider using the Winsock equivalent of this function. To do so, set the optname parameter in the setsockopt function to SO_BTH_SET_PIN.
Requirements
Header |
bt_api.h |
Library |
Btdrt.lib |
See Also
Reference
Bluetooth API Security Management Functions
Bluetooth API Management Functions
BthRevokePIN