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.

CC2640R2F: iPhone Pairing Fail

Part Number: CC2640R2F

Hi,

             I am using CC2640R2F project zero . we are going for the  pairing (GAPBOND_PAIRING_STATE_STARTED ) with random passkey. When in iPhone entering the right passkey getting pzPairStateData_t status success in GAPBOND_PAIRING_STATE_COMPLETE and When entering wrong passkey getting pzPairStateData_t status as fail and disconnection has happening. But without entering the passkey for 30 seconds and giving cancel in iPhone  pzPairStateData_t status has not getting as fail and disconnection is happening. Then again initiating the connection in iPhone, random passkey is not generating and its connecting with the previous random passkey.

SDK version: simplelink_cc2640r2_sdk_3_30_00_20

Thank you.

  • Hi Vignesh,

    I will move this thread to the relevant expert, waiting for his answer I just notice that you're working with a quite old one SDK, you can find a much newer version (5.30) available here. Since a lot of bugs and new features has been released.

    regards,

  • Hi,

    As Guillaume mentioned, there have been numerous improvements in the SDKs released since 3.30. If possible, then I would highly recommend migrating to the latest SDK. Can you clarify if this behavior occurs in an unmodified project zero? If so, then could you quickly test if the behavior is present in the latest SDK?

    Best Regards,

    Jan

  • Hi Jan,

            I have tried and followed the same test cases still getting the result in SDK version : simplelink_cc2640r2_sdk_4_40_00_10 . Already the modules are in field so please suggest a workaround for the SDK  versions of  

    SDK version : simplelink_cc2640r2_sdk_4_40_00_10

    SDK version: simplelink_cc2640r2_sdk_3_30_00_20

    Thank you.

  • Hi,

    Understood, I will test this on my end. To confirm, is this occurring on an unmodified project zero? If not, then can you share the project as an attachment to your E2E reply (or via email if you prefer)?

    Best Regards,

    Jan

  • Hi,

    I did some tests on my end saw the following:

    I used an iPad running iOS version 16.5.1 for my testing.

    I took BLE5 project_zero and added RNG passcode (by referencing the RNG passcode section of the Security Fundamentals SLA). I modified the processPasscode function as shown below:

    static void ProjectZero_processPasscode(pzPasscodeReq_t *pReq)
    {
    //    Log_info2("BondMgr Requested passcode. We are %s passcode %06d",
    //              (uintptr_t)(pReq->uiInputs ? "Sending" : "Displaying"),
    //              B_APP_DEFAULT_PASSCODE);
    //
    //    // Send passcode response.
    //    GAPBondMgr_PasscodeRsp(pReq->connHandle, SUCCESS, B_APP_DEFAULT_PASSCODE);
        uint32_t passcode = 0;
        passcode = Util_GetTRNG();
        passcode %= 1000000;
        Log_info2("BondMgr Requested passcode. We are %s passcode %06d",
                  (IArg)(pReq->uiInputs?"Sending":"Displaying"),
                  passcode);
        // Send passcode response.
        GAPBondMgr_PasscodeRsp(pReq->connHandle, SUCCESS, passcode);
    }

    I also made the string characteristic encrypted using the modifications discussed in the SLA. I also disabled bonding for my testing.

    I flashed a LaunchPad with the modified project zero and was able to connect to the device as shown below:

    Afterwards, to initiate the pairing, I attempted to read the encrypted characteristic. The pairing prompt came up on the iPad and the passcode was provided via UART. I did not press anything on the iPad during the next 30 seconds. After 30 seconds, the procedure timed out with a bleTimeout error, but the connection still held as shown below.

    I was unable to read the encrypted characteristics as expected at this point.

    Can you share how you are generating the random pins? Are you using code similar to that show above? Are you able to share a project that runs on a launchpad that showcases this behavior? Is your project running on a ble5 project zero or a ble4 project zero?

    Best Regards,

    Jan

  • Hi Jan,

            I have shared my code of generating the random pins.

    static void ProjectZero_processPairState(pzPairStateData_t *pPairData)
    {
        uint8_t state = pPairData->state;
        uint8_t status = pPairData->status;
    
        switch (state)
        {
        case GAPBOND_PAIRING_STATE_STARTED:
        {
            uint32_t randomNumber;
            uint8_t tempkey[6];
            Log_info0("Pairing started");
    
            if ((event_alert_flag == 1) && (Pairing_Printflag == 0))
            {
                if (RamFlashData.Secure_Connection == 2)
                {
                    randomNumber = Random_getNumber();
                    randomNumber = randomNumber % 999999;
                    Pass_Key = randomNumber;
                }
                randomNumber = Pass_Key;
                for (int i = 5; i >= 0; i--)
                {
                    tempkey[i] = 0x30 + (randomNumber % 10);
                    randomNumber = randomNumber / 10;
                }
                memcpy(&Pairing_Msg[5], tempkey, 6);
                App_UART_Write(Pairing_Msg, sizeof(Pairing_Msg));
                Pairing_Printflag = 1;
            }
            break;
        }
    
        case GAPBOND_PAIRING_STATE_COMPLETE:
            if (status == SUCCESS)
            {
                Log_info0("Pairing success");
                if (event_alert_flag == 1)
                {
                    App_UART_Write("pass",4);
                }
                Pairing_Printflag = 0;
            }
            else
            {
                Log_info1("Pairing fail: %d", status);
                if (event_alert_flag == 1)
                {
                    App_UART_Write("fail",4);
                }
                Pairing_Printflag = 0;
            }
            break;

  • Hi,

    Got it. I will test this on my end soon. In the meantime, can you confirm if the iOS version you are seeing this behavior occur in is 16.5.1? I want to ensure i use the same device on my end.

    Best Regards,

    Jan

  • Hello Jan,

             Here is the details of the Mobile and IOS Version.

                             iPhone 13 --  Version: 16.5.1

                             iPhone SE --  Version: 16.5.1

    Thank you.

  • Hi,

    Can you share the ProjectZero_processPasscode() function or the equivalent function in your code? I would like to see how the call to the GAPBondMgr_PasscodeRsp() is set up.

    Are you sending the pair request during connection or waiting for an encrypted characteristic to be interacted with? Apple states in their Accessory Design Guidelines, in section 41.9 and 41.10, that pairing should only occur after a read/write is attempted on an encrypted characteristic and not automatically at connection establishment.

    Can you check what the pairMode is set to before it is set in a GAPBondMgr_SetParameter() call? This set up happens in the followings section of the code:

    Best Regards,

    Jan

  • Hi Jan,

           I apologize for taking so long to reply.so here is my code to call  the GAPBondMgr_PasscodeRsp() .

    static void ProjectZero_processPasscode(pzPasscodeReq_t *pReq)
    {
        Log_info2("BondMgr Requested passcode. We are %s passcode %06d",
                  (uintptr_t)(pReq->uiInputs ? "Sending" : "Displaying"),
                  B_APP_DEFAULT_PASSCODE);
    
        GAPBondMgr_PasscodeRsp(pReq->connHandle, SUCCESS, Pass_Key);
    }

    And i am  sending the pair request after connection .

    I have checked the GAPBondMgr_SetParameter() and its an same implementation.

    Thank you.

  • Hi,

    Got it. That is strange that I am unable to see the behavior on my side. Could you send me the compiled .hex or .out file, so I can flash it on a launchpad and try to reproduce your behavior? After, I have reproduced it, then we can work our way to finding a solution. I have added you as a friend on E2E in case you prefer to send me the image through private messages.

    Best Regards,

    Jan