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.

No timeout during failed attempt to connect

Expert 1635 points

Hi,


I have just found that after discovering a peripheral if I turned it off immediately before starting connecting from the central, there is no timeout coming out from the process started (successfully) by GAPCentralRole_EstablishLink().  Is there some setup I am missing or that use case was not implemented?

Thank you,

Pibe

  • Also, if after a while I turned the peripheral back on the link succeeds, evidencing the central has kept asking for connecting all time. Let's suppose there is no timeout implemented and the app has to take care of it (conceptually wrong!), if so how do the app tells the stack to stop trying to link to the disappeared device? I mean, there is a "TerminateLink()" that take a handle as an argument but at that point there was no handle assigned to the link that was never established!
    Pibe
  • Hello Pibe,

    Please see the description for GAPCentralRole_TerminateLink in the SW Developer's Guide (SWRU393). Specifically, using a connHandle 0xFFFE: cancel the current link establishment request.

    Best wishes
  • That will do it. Thanks!
  • Unfortunately, after trying:

    GAPCentralRole_TerminateLink( GAP_CONNHANDLE_INIT );

    I have to report that it does not cancel the ongoing linking process. If more than a minute after this request is issued (and having everything working as expected, including a "Linking cancelled" debugging message on screen) I turn the peripheral on again, then the connection is established immediately, proving the process had not been aborted.

    I checked the value returned by the function and it is 0x02 (INVALIDPARAMETER ?).

    Pibe

  • Where are you calling GAPCentralRole_TerminateLink from? A task or callback function? Try calling it from the same task / context as where you establish the connection.

    Best wishes
  • Yes, that was it.  It was supposed to be that way but I discovered I had the names of the handlers passed to the timeout clock and the event's switched (their names were very similar).  Now I can confirm the 0xFFFE parameter works as stated. Thank you.

    Still, I think the timeout should be implemented in the linking process itself, leaving the option for the app to decide for how long it is willing to wait.

    Thanks again,

    Pibe