This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC2640R2L: I needed to know if it is possible to have 4 digits instead of 6 in the bluetooth pairing password

Part Number: CC2640R2L
Other Parts Discussed in Thread: CC2640, , UNIFLASH

I needed to know if it is possible to have 4 digits instead of 6 in the bluetooth pairing password.

When I send the android to pair with the CC2640 it opens a field where I can type the password, but it recommends the password 0000 or 1234, to avoid user confusion I would like to standardize the initial password 1234.

Is it possible to do that?

I'm using the CC2640R2L in the "simple_peripheral" example

  • Hi,

    Thank you for reaching out to us. The passcode functionality is handled by the SimplePeripheral_processPasscode() function in the simple_peripheral.c file. This function by default uses a pre-set password which is stored in the B_APP_DEFAULT_PASSCODE define. This function may be changed to use a different define or to have hardcoded values. 

    static void SimplePeripheral_processPasscode(uint8_t uiOutputs)
    {
      // This app uses a default passcode. A real-life scenario would handle all
      // pairing scenarios and likely generate this randomly.
      uint32_t passcode = B_APP_DEFAULT_PASSCODE;
    
      // Display passcode to user
      if (uiOutputs != 0)
      {
        Display_print1(dispHandle, 4, 0, "Passcode: %d", passcode);
      }
    
      uint16_t connectionHandle;
      GAPRole_GetParameter(GAPROLE_CONNHANDLE, &connectionHandle);
    
      // Send passcode response
      GAPBondMgr_PasscodeRsp(connectionHandle, SUCCESS, passcode);
    }

    In a real-life use-case, this function should be modified to use something other than a default password and will likely implement a randomly generated password.

    Best Regards,

    Jan

  • Hello, thank you for taking your time to help me.
    I had already tested it by changing the B_APP_DEFAULT_PASSCODE to 1234, but when pairing it shows an incorrect password message

    Here is the example of my code:

    simple_peripheral.c

    bcomdef.h

    Android

  • Hi,

    Can you try printing the passcode (by uncommenting out the display_printf line( to ensure we are updating the passcode correctly? 

    Best Regards,

    Jan

  • In the case of my project I had to deactivate the Display, but I did a test by putting the fixed value directly in the "GAPBondMgr_PasscodeRsp" function and the same problem occurs

  • Hi,

    Understood, can you run this program in debug view and set a break point at the GAPRole_GetParameter(), stepping into the GAPRole_GetParameter() function and verifying what passcode is being used and compared? Do you have access to a Bluetooth LE sniffer? If so, then I think getting a packet capture of what is happening over the air may be helpful here.

    Best Regards,

    Jan

  • Doing a test here, a doubt arose, this SimplePeripheral_processPasscode() function is executed the moment it requests the pairing, even before writing the password on Android.

    dbug part 1:

    dbug part 2:

    dbug part 3: gapbondmgr.c

  • Hi Gabriel,

    Was that test done using a previously bonded device? Can you try mass erasing the CC2640R2 through Uniflash and erasing any bonds you may have on the central device before trying again?

    Best Regards,

    Jan