This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Relay example, erasing bonds unexpected behavior?

I'm trying to figure out something I'm seeing. I've modified the relay demo in the nRF52 SDK so that when I press button 2 on the board, it destroys any connections, erases bond information and begins scanning.

Is it a no-no to do these three things in succession in the button ISR context? The strangeness that I see is when I have debug logging on, there are a ton of NRF_EVT_FLASH_OPERATION_ERROR events that restart the scan and this lasts for several seconds. Is there an event or events I should wait for rather than trying to do all of these things together?

What I'm doing in a call from bsp_event_handler:

	case APP_EVENT_PAIR_BUTTON:
		APPL_LOG("[APPL]: APP_EVENT_PAIR_BUTTON\n");

		// Remove keys when button pressed
		//
		err_code = dm_device_delete_all(&m_dm_app_id);
		APP_ERROR_CHECK(err_code);
		disconnect_all_periph();

		// Start scanning with no whitelist
		//
		m_scan_mode = BLE_FAST_SCAN;
		scan_start();
		break;

Here's the disconnect_all_periph:

static void disconnect_all_periph(void)
{
uint32_t err_code;

if (m_conn_handle_central_hrs != BLE_CONN_HANDLE_INVALID)
{
	err_code = sd_ble_gap_disconnect(m_conn_handle_central_hrs,
						BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION);
	APP_ERROR_CHECK(err_code);
}
if (m_conn_handle_central_rsc != BLE_CONN_HANDLE_INVALID)
{
	err_code = sd_ble_gap_disconnect(m_conn_handle_central_rsc,
							BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION);
	APP_ERROR_CHECK(err_code);
}

}

I'm attaching my main.c:main.c

Parents Reply Children
No Data
Related