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.

Connection Terminated by Local Host (0x13) error

Other Parts Discussed in Thread: CC2541

Hi everyone,

during development with a CC2541 I stumbled over the following error: During a connection to a master the connection is sometimes terminated because of the reason 

Connection Terminated by Local Host (0x13 Bluetooth Low Energy error code) 

It seems as if this is not triggered by any special event in our firmware based on the TI stack. 

Can anyone help?

Does anyone know, under which condition the function hci_DisconnectCmd() is called with the parameter HCI_DISCONNECT_REMOTE_USER_TERM?

Edit: Our application code does neither directly call nor in any other way trigger a disconnect event.

Best regards,

Philipp

Attached you find a screenshot of a Mac packet sniffer.

  • Hi Philipp

    hci_DisconnectCmd() is called from GAP_TerminateLinkReq() which could for example be triggered from an update parameter timeout event (UPDATE_PARAMS_TIMEOUT_EVT).

    So, do you know if you are trying to update connection parameters after the connection has been established? This can for example be done with L2CAP_ConnParamUpdateReq() on a slave device.

    Best Regards

  • Hi,

    tanks your your reply. Indeed, we do request a connection parameter update, which we thought might be a problem. If the timeout occurs, does that mean it is because of a packet lost over the air?

    Also, it turns out that these connection drops occur even before the update request or when the update request is not performed at all.Are there any other "popular" reasons for the GAP_TerminateLinkReq() being called?

    Best  regars, Philipp

  • Hi Philip,

    I could be because of a packet lost over the air. This can be observed by using the TI Sniffer (info here) or any other sniffer for that matter. It could also be the fact that the Master starts the service discovery immediately and can therefore not process the connection parameter update (simply neglects it without response).

    Is it possible for you to obtain a sniffer log capturing "advertisement->Connection->...->Disconnect"?

    Best Regards

  • Hi Nick,

    I will try to get a log of such a disconnection event, but they do not occur very frequently. What makes me wonder is that we also saw this behaviour without requesting a connection parameter update at all. Can for example a very short connection interval (chosen by the master during connection establishment) cause the slave to cancel the connection with code 0x13?

    Best Regards,

    Philipp

  • Hi Philipp,

    Not really. If the inequality LSTO > (1 + Slave Latency) * (Connection Interval * 2) doesn't hold, or the parameters are zero, the link layer will terminate the connection with reason 0x3B. But that happens directly on link establishment or parameter update.

    I can't see anywhere in the code that 0x13 is sent automatically as a termination cause. So please try to provide a log, if convenient using the TI packet sniffer because we are familiar with interpreting the output.

    Best regards,
    Aslak