Skip to main content
ANauz.1
Senior
December 4, 2020
Solved

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

  • December 4, 2020
  • 1 reply
  • 645 views

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

    This topic has been closed for replies.
    Best answer by ANauz.1

    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;
     }

    1 reply

    ANauz.1
    ANauz.1AuthorBest answer
    Senior
    December 4, 2020

    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;
     }