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.

CC2540: Problem with bonding in the cc2540

Part Number: CC2540


Hi to all,

i am developing a device with CC2540 SOC but i have a problem in bonding. my problem is in that manner that at first when i program the cc2540 dongle dev board it works fine but after some times it encounter with problem in pairing and i can't pair to my device any more, pls see the below screen shot:

as you can see in the above screen shot pairing procedure was started and performing well but after that master(cc2540) had sent Sent_Identity_Information request to the peripheral(nrf51822) it seems that it forgot to send Sent_Identity_Address_Information and after sometime(i had set default timeout value to 1sec) connection time outed and then peripheral start to advertise and then cc2540 try to auto connect to it but because bonding did not completed peripheral reject the encryption request. i had described this problem in this forum in  and i  thought that the problem was fixed, but some time ago the problem happen again. in before the default timeout value was 20sec and this caused that first disconnection take too long, but after this delay because the central had sent  Sent_Identity_Address_Information request the pairing procedure completed and after disconnection devices auto connect to  each other. then i changed the default timeout value to 1sec to minimize the delay but after that the problem happen in manner that i described in first of the my question.

i do not have any idea to solve this problem, can any one give me a advice??

  • i had also uploaded dump of the ble connection, this file was captured with nordic sniffer. pls take a look at it.  because the forum do not let me to upload file with pcapng format, i had change the suffix of the file to psd. please change it and then load it in nordic sniffer app.

    first_faild_again(with 1 sec timeout).psd

  • Hi,

    What version of the BLE Stack are you using?

    Do you have a sniff of a successful pairing as well?

    Have you paused your program during the failed pairing process before the timeout to see if the program is in some unknown state and look at the call stack?
  • Hi, thanks for yor response

    Version of the ble stack that i am using is 1.4.2.2.  and when i pause the application before connection timeout, i can see two different behavior. some time when i send request from the PC to the cc2540 to perform pairing IAR show an message that say "possible IDATA stack overflow detected" and in this situation when i pause the app iar show nonsensical values in PC and other registers. i attached screen shot of this situation(unvalid.png). and some time it did not show any error and in this situation when i pause the app iar show valid values for registers and other component, i attached an screen shot from this situation also(valid.png).

    i think this problem is something that is related to the flash and data's that ti ble stack save in the flash, because if this problem happen and i program my firmware to flash, device work well and if i use from device for some time(for example 2 week) the problem happen again and remain until i reprogram the chip. and also i captured an sniff of a successful connection(again change the format to the pcapng and use nordic sniffer).

    thanks

    when_working_good.psd

  • Ok my friend,

    i think that the problem is some thing that is related to the flash. in my app sometimes i try to write some data in the flash of the cc2540 with osal snv library. the function that write the data is something like this:

    void name_list_update( void )
    {
      osal_snv_write(NAME_LIST_SNV_ID, sizeof(bonded_fob_t)*GAP_BONDINGS_MAX, bonded_fob_list);
    }

    this function try to write 80 byte data in the flash storage, and this function will be invoked 30sec after that link stablished. can this function cause the problem?? because i read in this froum that dirty use from the flash storage may cause the problem. and something that i want to imply to that is my application only bond to a peripheral if the request of that had been sent from the computer side app to cc2540. and whenever this request was sent i call the below function to remove all before bonded devices and terminate current link:

    void remove_all_bonded_devices( void )
    {
      uint8 * bonding_addresses;
      uint8 idx;
      uint8 cnt=0;
      GAPBondMgr_GetParameter(GAPBOND_BOND_COUNT,&cnt);
      
      
      bonding_addresses = (uint8 *)osal_mem_alloc(cnt * B_ADDR_LEN);
      GAPBondMgr_GetParameter(GAPBOND_BONDED_LIST,bonding_addresses);
      GAPBondMgr_SetParameter(GAPBOND_ERASE_ALLBONDS,0,NULL); // TODO-DELETE ALL BONDING
      for(uint8 i=0;i<cnt;i++)
      {
        idx = get_idx_by_addr(bonding_addresses + B_ADDR_LEN * i);
        name_list_remove(bonding_addresses + B_ADDR_LEN * i);
        if(is_connected(bonding_addresses + B_ADDR_LEN * i))
        {
          GAPCentralRole_TerminateLink(bridge_devices[idx].connHandle);
        }
      }
      osal_mem_free(bonding_addresses);
      
      //burning timer to update name list in the flash for 30 sec later
      osal_stop_timerEx(task_id, NL_UPDATE_EVT);
      osal_start_timerEx(task_id, NL_UPDATE_EVT,30000);
      
    }

    can calling GAPBondMgr_SetParameter(GAPBOND_ERASE_ALLBONDS,0,NULL); function just before the connection can cause this problem??

    thanks

  • to ti developer guys, there is no one can help me to solve this problem?? this problem will cause failure of my project.
  • Hi Alireza,

    I've not ever seen this issue and it's hard for me to give really detailed feedback as you are clearly trying to make some functions that manage the SNV yourself.

    That said, in your function that you've provided and the description you've given, it sounds like you want to terminate all links and then entirely erase your bond info, is this correct?

    If you wish to this, you can call GAPCentralRole_TerminateLink(0xFFFF), where 0xFFFF is the connHandle and when defined as 0xFFFF it will terminate all connections. Then after that, you can call GAPBondMgr_SetParameter(GAPBOND_ERASE_ALLBONDS,0,NULL) to erase all your bond information. This way, you can be sure that you're not connected to anything which replaces what you seem to be doing in the function you've provided where you are looping through all the idx's to see if something is connected. Does this help in understanding?
  • I'm going to close this post due to inactivity. To reopen this thread, just post a follow up question. Otherwise, after 30-days of inactivity from this post, this thread will lock.