Hello,
How can we force a device to disconnect from a BLE Network after a certain period of inactivity (timeout) ?
Thanks.
Hello,
How can we force a device to disconnect from a BLE Network after a certain period of inactivity (timeout) ?
Thanks.
There is nothing internally in softdevice or SDK drivers that will detect this inactivity. Your application have to detect this by itself. It can for example start a 10 second timer which has to be reset everytime there is data write is done. So when it expires it means that no data has been transferred in the last 10 seconds. The downside is that this will only work for writes, if you want notifications or other procedures to count as activity, you have to reset the timer at those places.
There is a lot of traffic between two controllers in connection that are not notified to the application. If you use timers that traffic will be considered as inactivity. There is no other way that I can think of right now.
There is nothing internally in softdevice or SDK drivers that will detect this inactivity. Your application have to detect this by itself. It can for example start a 10 second timer which has to be reset everytime there is data write is done. So when it expires it means that no data has been transferred in the last 10 seconds. The downside is that this will only work for writes, if you want notifications or other procedures to count as activity, you have to reset the timer at those places.
There is a lot of traffic between two controllers in connection that are not notified to the application. If you use timers that traffic will be considered as inactivity. There is no other way that I can think of right now.
Thanks for replying. Can you show me how to start and reset a timer after 10 seconds ? Do you have some examples ?
using app_timer library
static void timers_init(void)
{
// Initialize timer module.
APP_TIMER_INIT(0, APP_TIMER_MAX_TIMERS, APP_TIMER_OP_QUEUE_SIZE, false);
// Create timers.
uint32_t err_code;
err_code = app_timer_create(&m_app_timer_id, APP_TIMER_MODE_REPEATED, timer_timeout_handler);
APP_ERROR_CHECK(err_code);
}
void start_timer()
{
uint32_t err_code;
err_code = app_timer_start(m_app_timer_id, 10 * 32768, NULL); // handler timer_timeout_handler will be called every 10 seconds unless stopped
APP_ERROR_CHECK(err_code);
}
void stop_timer()
{
uint32_t err_code;
err_code= app_timer_stop(m_app_timer_id);
APP_ERROR_CHECK(err_code); }
void reset_timer()
{
stop_timer();
start_timer();
}
Thanks, this is how it should be done
is there anything on this topic? if not can we close the thread and you accept the answer with the code.
Yes you can close the thread, this is the answer i was looking for