PIN Setting During BT Connection - KBA225063

Version 3

    Version: **

     

    Translation - Japanese: BT接続時のPIN設定- KBA225063- Community Translated (JA)

    The Bluetooth PIN can be used to authenticate two Bluetooth devices with each other during the creation of a mutual link key via the pairing procedure. The PIN may be used in the pairing procedure to generate the initial link key. The PIN may be entered on the UI level during the connection with a device that has the ability to enter digits.

    This article explains how to set the PIN using a sample application. A demo code based on SPP[BJ1] is attached with this KBA.

    1. Download the attachment, unzip it, and copy the btm_init.h file to your project. 

    2. Include the header file btm_init.h in the WICED® Studio SDK.

    #include "btm_init.h"

    3. Set the security mode to BTM_SEC_MODE_SERVICE in the application callback function.

    btm_cb.security_mode = 2;

    4. In the application callback function, add the following functions to disable simple pairing and secure connection host support.

    btsnd_hcic_write_simple_pairing_mode( HCI_SP_MODE_UNDEFINED);

    btsnd_hcic_write_secure_conns_support(HCI_SC_MODE_DISABLED);

    5. In BTM_PIN_REQUEST_EVT, reply the pin request with the following function:

    wiced_bt_dev_pin_code_reply(*p_event_data->pin_request.bd_addr, result, 4, &pincode[0]);

    6. Set the PIN in the variable declare part of your code. The code is in ASCII format. For example, the following code sets the PIN Code to “0123”

    uint8_t pincode[4] = { 0x30, 0x31, 0x32, 0x33 };

    See the attachment code for details on the PIN.