Hello,
I am using nRF Connect SDK 1.8.0 on the nRF52840. I want to limit the amount of time that a peripheral can connect to my central 52840. On connection start I initiate a timer following the K_timer convention set by zephyr and it times out properly. I want to use the timeout handler function to call
int bt_conn_disconnect(struct bt_conn *conn, uint8_t reason)
I have used asynchronous functions to handle the connection and disconnection events but I had to register their callbacks using the struct
static struct bt_conn_cb connection_callbacks.
Since there is no BLE event I'm timing out with, I wasn't sure how to get the bt_conn object to the timer's timeout handling function. I assume that the on_connected or on_disconnected events are receiving the bt_conn object through the event handler, but I was not sure about this. I tried to make the bt_conn object a static global var within the file, but in the timer handler the bt_conn_disconnect function fails with ENOTCONN (-128) so it seems it isn't accepting the bt_conn object correctly.
What would be the best way to correctly give the bt_conn object to the timer's timeout handling function here?
Thanks!