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.

CC2640 - Terminating Multi Role Central/Peripheral connections based on handle value

The GAP_LINK_ESTABLISHED_EVENT provides the new connection handle value and indicates if it is for a Central or Peripheral connection so it's relatively easy to keep track of the handles for simultaneous central and peripheral connections. When the time comes to terminate a connection, how do you identify to the stack if the handle is for a Central connection or for a Peripheral connection?  

It is not obvious to me when looking at the Multi Role example code. It appears to only manage central connections but I know it's possible to also terminate a connection as a peripheral.

Thanks.

  • Hi,

    Because GAP_LINK_ESTABLISHED_EVENT provides the new connection handle, you should be able to do this the same way that it is done for a Central connection.

    Alternatively, you could stop sending connection events from the peripheral and this will terminate the connection.

    -Nathan
  • Hi,

    Here's the scenario, I have two simultaneous connections, one connection is to a peripheral device and the other is to a central device. Both connections have handles that equal zero. The GAPRole_TerminateConnection() API call only takes one argument which is the handle number. How does it know if it should disconnect the central connection or the peripheral connection?

    Thanks again for the help.
  • Hi,

    The GAP_LINK_ESTABLISHED_EVENT also provides the connection role, so your application can keep track of this as well. Also there is HCI_EXT_GetConnInfoCmd() command that will provide more info for each connection.

    Best wishes
  • Hi,

    Figuring out which role a connection handle is associated with isn't the problem. The problem is how do you specify to the stack which connection to terminate when the only argument allowed is the handle. Wouldn't you also need to be able to specify that the handle is for either a central or peripheral connection?

    Thanks.
  • Hi Michael,

    the connection handle is, in the multirole example, stored in the array connHandleMap[connIdx]. To see how a connection is terminated, scroll down to multi_role_handleKeys():

    //disconnect a connection
    case DISCONNECT:
      //disconnect
      GAPRole_TerminateConnection(connHandleMap[connIdx]);        
      Display_print0(dispHandle, 0, 0, "Disconnecting");        
      break;