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
  • Hi Richard,

    Our device manager module will try to store bond information when we disconnect from a bonded device. So if you erase all the bond information before the connection actually terminated. You may have a trouble.

    I would suggest you to try disconnect first, wait for the Disconnection event to come (DM_EVT_DISCONNECTION event) make sure there is no active connectoin and then erase bond information before you start another connection or advertising.

Reply
  • Hi Richard,

    Our device manager module will try to store bond information when we disconnect from a bonded device. So if you erase all the bond information before the connection actually terminated. You may have a trouble.

    I would suggest you to try disconnect first, wait for the Disconnection event to come (DM_EVT_DISCONNECTION event) make sure there is no active connectoin and then erase bond information before you start another connection or advertising.

Children