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.

BTLE reason for being disconnected

Other Parts Discussed in Thread: CC2540

Hi :)

I have a CC2540 based device and in general the BTLE connection is extremely stable when my device is on the table for testing. But if I put it on my body I tend to get some sporadic disconnections now and then... Most likely a hardware issue, ESD, whatever...

But is it possible in the device software to get more information about why a disconnection event occured?

Thanks :)

  • Hi Jens,

    When the device is disconnected, the device should send a disconnection complete event with a error code indicating reason for the disconnection. The error codes are defined in Volume 2, Part D (pg. 585) of the 4.0 Core Specs.

    Let me know if you have further questions.

  • Hi Zahid and thanks a lot,

    I was more interested in an error code to deal with in my application code inside 2540. It  would then be possible for me to log that for further investigation. Is it possible to get the same error code in my code? Is that exposed in the BTLE stack? Or maybe you can point me to a place where I can put a breakpoint?

    Thanks a lot :)

  • Hi Jens,

    In peripheral.c, you can figure out the reason for the disconnection by checking the value of pPkt->reason:

        case GAP_LINK_TERMINATED_EVENT:
          {

           ...

    // Go to WAITING state, and then start advertising
            if( pPkt->reason == LL_SUPERVISION_TIMEOUT_TERM )
            {
              gapRole_state = GAPROLE_WAITING_AFTER_TIMEOUT;
            }
            else
            {
              gapRole_state = GAPROLE_WAITING;
            }

    This snippet is from SimpleBLEPeripheral V1.4 stack.

  • Thanks a lot Zahid - just what I needed :)

    Update: I have created a new post: http://e2e.ti.com/support/low_power_rf/f/538/t/313255.aspx

    If possible I would be happy if you could look at that too :D