Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Is race condition possible when stopping advertising?

Is race condition possible when stopping advertising?

I need to disable BLE for some time to perform critical tasks. I need to stop advertising and be disconnected.

Let's consider simple code snippet that runs with the lowest priority:

	if (m_conn_handle == BLE_CONN_HANDLE_INVALID) {
		sd_ble_gap_adv_stop();
	}

Is it possible that after checking connection handle and before stopping advertising some device might connect to my device and in the end I will be in connection while performing critical tasks?

Related