cancel
Showing results for 
Search instead for 
Did you mean: 

How to pair a Device to a X-Nucleo-BNRG2A1with Nucleo Board running BlueNRG sample App

ANauz.1
Senior

Hello,

I have two X-Nucleo-BNRG2A1 demo board, with Nucleo Board, working fine with the SampleApplication of the X-CUBE-BLE2.

The two module pair correctly, one being the Master, sending message to the slave.

I would like now to use another device to connect to the X-Nucleo-BNRG2A1. I can see the bluetooth one the other device, but when trying to connect, it ask for a Key.

What is the Key, or how to read it? Is there a way to enable Key free connection?

Thank you

1 ACCEPTED SOLUTION

Accepted Solutions
ANauz.1
Senior

Hello,

Here is the solution:

To change the authentification to use Pin code, add the following in the module initialisation:

    ret =  aci_gap_clear_security_db();
    if (ret != BLE_STATUS_SUCCESS)
    {
        PRINT_DBG( "aci_gap_clear_security_db failed: 0x%02x\r\n",
                   ret);
        return ret;
    }
 
    uint8_t Bonding_Mode = 0; /* No Bonding */
    uint8_t MITM_Mode = 0; /* MITM prottttection not required */
    uint8_t SC_Support = 0; /* SC IS NOT Supported */
    uint8_t KeyPress_Notification_Support = 0; /* Keypress not supported */
    uint8_t Min_Encryption_Key_Size = 0x07; /* Minimum encryption key size */
    uint8_t Max_Encryption_Key_Size = 0x10; /* Minimum encryption key size */
    uint8_t Use_Fixed_Pin = 0; /* Use Fixed Pin for pairing */
    uint32_t Fixed_Pin = 0x0001E240; /* Pin 1234546 */
    uint8_t Identity_Address_Type = 0; /* Public Identity Adddress */
 
    ret = aci_gap_set_authentication_requirement( Bonding_Mode,
                                                       MITM_Mode,
                                                       SC_Support,
                                                       KeyPress_Notification_Support,
                                                       Min_Encryption_Key_Size,
                                                       Max_Encryption_Key_Size,
                                                       Use_Fixed_Pin,
                                                       Fixed_Pin,
                                                       Identity_Address_Type );
 
    if (ret != BLE_STATUS_SUCCESS)
    {
        PRINT_DBG( "aci_gap_clear_security_db failed: 0x%02x\r\n",
                   ret);
        return ret;
    }

View solution in original post

1 REPLY 1
ANauz.1
Senior

Hello,

Here is the solution:

To change the authentification to use Pin code, add the following in the module initialisation:

    ret =  aci_gap_clear_security_db();
    if (ret != BLE_STATUS_SUCCESS)
    {
        PRINT_DBG( "aci_gap_clear_security_db failed: 0x%02x\r\n",
                   ret);
        return ret;
    }
 
    uint8_t Bonding_Mode = 0; /* No Bonding */
    uint8_t MITM_Mode = 0; /* MITM prottttection not required */
    uint8_t SC_Support = 0; /* SC IS NOT Supported */
    uint8_t KeyPress_Notification_Support = 0; /* Keypress not supported */
    uint8_t Min_Encryption_Key_Size = 0x07; /* Minimum encryption key size */
    uint8_t Max_Encryption_Key_Size = 0x10; /* Minimum encryption key size */
    uint8_t Use_Fixed_Pin = 0; /* Use Fixed Pin for pairing */
    uint32_t Fixed_Pin = 0x0001E240; /* Pin 1234546 */
    uint8_t Identity_Address_Type = 0; /* Public Identity Adddress */
 
    ret = aci_gap_set_authentication_requirement( Bonding_Mode,
                                                       MITM_Mode,
                                                       SC_Support,
                                                       KeyPress_Notification_Support,
                                                       Min_Encryption_Key_Size,
                                                       Max_Encryption_Key_Size,
                                                       Use_Fixed_Pin,
                                                       Fixed_Pin,
                                                       Identity_Address_Type );
 
    if (ret != BLE_STATUS_SUCCESS)
    {
        PRINT_DBG( "aci_gap_clear_security_db failed: 0x%02x\r\n",
                   ret);
        return ret;
    }