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.

How to know IRK is received?

Other Parts Discussed in Thread: CC2541

Hi,

I am developing a product on CC2541 to connect with my iPhone app.  

The iPhone app will initiate pairing, bonding, and then send a IRK to CC2541.

I want to write codes on CC2541 to do some post processing after the IRK has been received successfully.

So I wonder if there is any event that can notify me an IRK has been received? (I know there is a bond complete event "GAP_BOND_COMPLETE_EVENT", but I guess it doesn't guarantee an IRK been received.)

Regards,

Jack

  • Hello Jack,

    I have not seen IRK (Identity Resolving Keys) used with the CC254x. After pairing of the devices, a STK (Short-Term Keys) is generated. You can then request bonding of the devices by establishing LTK (Long-Term Keys). The LTK allows for encryption and eliminates the need of having to go through the pairing process again. This is all done in the GAP layer.

    There is a GAP_AuthenticationComplete event that is generated after pairing. This has to be generated before a LTK can be established. The GAP_BondComplete event would be your confirmation That a LTK has been established.

    Thanks,

  • Hi Greenja,

    Thanks a lots for the response.

    In my application, iPhone will send an IRK to CC2541, and CC2541 will save it to flash.  iPhone changes its random address frequently, and the IRK is used to resolve the random address.  In "gapbondmgr.c", there is a function GAPBondMgr_ResolveAddr(), that is used to resolve the random address.

    One possible solution that I think of for checking if IRK is received is like this:

    When receiving a "GAP_AUTHENTICATION_COMPLETE_EVENT" event, check if the packet includes an identity information. The code is something like:

    case GAP_AUTHENTICATION_COMPLETE_EVENT:
    {

         gapAuthCompleteEvent_t *pPkt = (gapAuthCompleteEvent_t *)pMsg;

         if (pPkt->pIdentityInfo != NULL) {

            //IRK is received

         } else {

           //IRK is not received.

         }

    }

    I wonder if the solution sounds correct to you guys?

    If I add the case in gapRole_ProcessGAPMsg() in "peripheral.c", can I catch the event?

    Or I have to add the codes in GAPBondMgr_ProcessGAPMsg() in "gapbondmgr.c"?  (If possible, I don't want to touch the code in bonding manager...)

    Regards,

    Jack

  • Hello Jack,

    Sounds like putting you condition in the case for the event should work.  I have not used the resolve address but I would think you would call it in that case as well.  I don't think it returns a value though to indicate success.

    As far as I know, using a process message would only be necessary if you don't set a global variable.  The Authentication_Complete_Event case would automatically get called each time you establish a connection.  Try the simplest solution or the one you are most comfortable with first.

    Thanks,