Terminate established peripheral connection

Hello all!

I am currently developing on the development board nRF52832, SDK16.0 and SD132v7.2.0.

My developmnet board acts as a central whereas my phone as peripheral. The idea is now that my developmnet board terminates the connection with my phone after a few seonds. My first try was to set CONN_SUP_TIMEOUT with the wish that the SD terminates the connection automatically by its own:

#define MIN_CONN_INTERVAL MSEC_TO_UNITS(400, UNIT_1_25_MS) 
#define MAX_CONN_INTERVAL MSEC_TO_UNITS(650, UNIT_1_25_MS) 
#define SLAVE_LATENCY 0                                    
#define CONN_SUP_TIMEOUT MSEC_TO_UNITS(4000, UNIT_10_MS)   
 
 void init_gap_conn(void)
 {
 ble_gap_conn_params_t gap_conn = {0};
 
 gap_conn.min_conn_interval         = MIN_CONN_INTERVAL;
 gap_conn.max_conn_interval         = MAX_CONN_INTERVAL;
 gap_conn.slave_latency             = SLAVE_LATENCY;
 gap_conn_params.conn_sup_timeout   = CONN_SUP_TIMEOUT;

 sd_ble_gap_ppcp_set(&gap_conn_params);
 }

Please correct me if i am wrong but based on the code snippet above the connection to the peripheral should terminate after 4 s? But the problem is that the connection remains until i disconnet manually on my peripheral itself. Is there a possibility to perform a termination of the connection or do i have to do it in SW by using follwowing command:

sd_ble_gap_disconnect();

Any hint would be really appreciated.

Best regards,

Karl

  • Hello Karl,

    Please correct me if i am wrong but based on the code snippet above the connection to the peripheral should terminate after 4 s? But the problem is that the connection remains until i disconnet manually on my peripheral itself.

    This is not quite correct, since the Connection Supervision Timeout parameter configures the time it will take to terminate a link when the peer has become unresponsive. In essence, this is the time that the devices will keep trying to reach the peer, even though the peer has stopped responding. This thus only comes into play once one of the peers stops showing up to the connection events.

    If you would like to disconnect the link after a specific time has passed you should instead set up a timer that invokes the sd_ble_gap_disconnect function upon expiration.

    Best regards,
    Karl

  • Hi Karl,

    thank you for your quick response. As you also proposed, i am starting a timer and after expiration, the link is disconnected by using sd_ble_gap_disconnect.

    Thank you again.

    BR,

    Karl

  • MKarl said:
    thank you for your quick response.
    MKarl said:
    Thank you again.

    No problem at all, Karl - I am happy to help!

    MKarl said:
    As you also proposed, i am starting a timer and after expiration, the link is disconnected by using sd_ble_gap_disconnect.

    Great, that is a good way to implement it.

    Please do not hesitate to open another ticket if you should encounter any other issues or questions in the future.

    Good luck with your development!

    Best regards,
    Karl

Related