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.

pairing/bonding strange behaviour?

Other Parts Discussed in Thread: CC2540

Hello community,

I've got the following situation here:

An IPhone (central) App and a CC2540 in the peripheral role.

The Bond Mgr is setup like that:

  // Setup the GAP Bond Manager
  {
    uint8 pairMode = GAPBOND_PAIRING_MODE_INITIATE;
    uint8 mitm = TRUE;
    uint8 ioCap = GAPBOND_IO_CAP_DISPLAY_ONLY;
    uint8 bonding = TRUE;
    uint8 bondFailAction = GAPBOND_FAIL_TERMINATE_ERASE_BONDS;
    
    GAPBondMgr_SetParameter( GAPBOND_PAIRING_MODE, sizeof ( uint8 ), &pairMode );
    GAPBondMgr_SetParameter( GAPBOND_MITM_PROTECTION, sizeof ( uint8 ), &mitm );
    GAPBondMgr_SetParameter( GAPBOND_IO_CAPABILITIES, sizeof ( uint8 ), &ioCap );
    GAPBondMgr_SetParameter( GAPBOND_BONDING_ENABLED, sizeof ( uint8 ), &bonding );
    GAPBondMgr_SetParameter( GAPBOND_BOND_FAIL_ACTION, sizeof ( uint8 ), &bondFailAction );
  }  

Now when i run my application on the CC2540 and connect to it with the IPhone I get asked for the passcode and after entering it pairing is finished successfull. When I now disconnect on the IPhone and reconnect again I first get GAPBOND_PAIRING_STATE_BONDED message in my pairStateCB function (everything fine until here) but right after that pairStateCB gets called again and I get a SMP_PAIRING_FAILED_UNSPECIFIED message. I can't see why this is happening.

What i want to do in the CB is, if in the pairing process a wrong passcode is entered, the connection should be terminated, but this behaviour interferes with my plans. I have already done a workaround for this problem but I don't like it that much and was wondering if there is another solution to my problem. Maybe the App on the IPhone is faulty (it wasn't developt by me) and sends some wrong commands or something like that?

Best regards

Karl

  • Hi,

    I have also faced same issue.

    It's because once you enter wrong passcode iOS tries to connect with JustWorks method, which means connection without security.There are two ways to tackle this issue:

    1. Once you receive connection state bonded check whether link is authenticated or not.(You can check this with linkDB_Authen function in  "<Installed dir>/Components\ble\host\linkdb.h file.)

    2. Enable authenticated read and write in your characteristics. This will not allow unauthenticated users to read or write from characteristics.

    Hope this will help you.

    Maulik

  • Thanks for your reply, but that's kind of the workaround what i was working with till now.

    When I activate bonding with

    uint8 bonding = TRUE;
    GAPBondMgr_SetParameter( GAPBOND_BONDING_ENABLED, sizeof ( uint8 ), &bonding );

    the callback notifies me with GAPBOND_PAIRING_STATE_BONDED and right after that the passcode callback gets called again, without a prompt at the Iphone, and i get the SMP_PAIRING_FAILED_UNSPECIFIED error code in the pairState callback. Checking with linkDB_Authen() afterwards results in SUCCESS meaning the link is encrypted and authenticated. I can't see why this is happening...

    Best regards

    Karl