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.

CC2640R2F: terminate connection from the peripheral device

Part Number: CC2640R2F

Hi

I am developing a BLE application that is used to communicate between a mobile phone and a PC via UART. The application was developed on top on ble5_simple_peripheral.
The ideia is that an undefined number of different mobile devices can connect to communicate with the PC, one at a time (I plan to make it 3/4 at the same time in the future, but that is of no concern for now. but let me know if you have any thoughts on this).

Now, I want to be able, from the peripheral (slave) side, to break the connection if i desire. My goal is to prevent a malicious device to keep the connection and cause a Denial of Service. 

Another useful thing to know is that if it is possible to prevent a certain device to connect.

I tried to use "GAP_TerminateLinkReq()" but it did not work

Bonus Question:

Is it possible (or feasible) to control the distance that the device can connect, I wanted to only be able to connect at 10 - 20 cm. I know that from Mobile device it is possible to make connection only when there is a certain signal strength. Is it possible to make something similar in the peripheral (slave) side? 

thank you

  • Hello Luis,

    What SDK version are you working with?

    "Either the Central or the Peripheral can terminate a connection for any reason. One side initiates termination and the other side must respond before both devices exit the connected state" Could you please give more detail on where/when are you calling GAP_TerminateLinkReq()?

    Is it possible to prevent a certain device to connect? Is it possible to connect based on RSSI on the peripheral side?

    There are a couple of things you can do:

    1. Consider using directed advertising so that your peripheral device will advertise to known/wanted devices.
    2. Establish a connection and execute some type of authentication logic where the peripheral can decide to continue or to end the connection. As for the RSSI, you can also consider to monitoring the RSSI at the connection events and decide if continue or not with the connection.

    Hope it helps,

    David.

  • Hi, David

    thank you so much for the reply and the suggestions!

    I am using cc2640r2_sdk_5_30_00_03 version. I am calling the GAP_TerminateLinkReq() from the simple_peripheral task context due to it being ICALL registered (that's necessary right?).

    The function seems to return 0, but the connection continues up.

  • Hello Luis,

    Could you please share a code-snippet of how you are doing this so I can further assist you? Are you calling it when you are sure the connection is already established (GAP_LINK_ESTABLISHED_EVENT)? Are you using an interrupt to trigger this termination event?

    BR,

    David.