Got hardfault reconnecting to paird iOS device

We found this problem in our tests.

In our tests, one test leaves the device in a state of poor signal with the iOS device. The device is then regularly disconnected from the iOS device and reconnected.

After hundreds of reconnections, this problem occurred.

We use ANCS, so the iOS device is bonded to the nRF52.

We would like to know how we can prevent this hardfault from happening.

Env:

  • SoC: nRF52832
  • SDK: nRF5_SDK_17.0.2_d674dde
  • SD: s132_nrf52_7.2.0_softdevice

CallStack:

Call Stack

The related code in pm_evt_handler is below:

static void pm_evt_handler(pm_evt_t const* p_evt)
{
	uint32_t ret;
	pm_handler_on_pm_evt(p_evt);
	pm_handler_flash_clean(p_evt);

	switch (p_evt->evt_id) {
		case PM_EVT_BONDED_PEER_CONNECTED: {
			if (p_evt->peer_id != PM_PEER_ID_INVALID) {
				uint32_t data_len = sizeof(m_peer_srv_buf);
				ret = pm_peer_data_remote_db_load(p_evt->peer_id, m_peer_srv_buf, &data_len);
				if (ret == NRF_ERROR_NOT_FOUND) {
					LOG_RAW("Could not find the remote database in flash.\r\n");
					ret = nrf_ble_gatts_c_handles_assign(&m_gatts_c, p_evt->conn_handle, NULL);
					APP_ERROR_CHECK(ret);

					// Discover peer's services.
					m_ancs_discovered  = false;
					m_gatts_discovered = false;
					memset(&m_db_disc, 0x00, sizeof(m_db_disc));
					ret = ble_db_discovery_start(&m_db_disc, p_evt->conn_handle);
					APP_ERROR_CHECK(ret);
				} else {
					// Check if the load was successful.
					ASSERT(data_len == sizeof(m_peer_srv_buf));
					APP_ERROR_CHECK(ret);
					LOG_RAW("Remote Database loaded from flash.\r\n");

					// Assign the loaded handles to the GATT Service client module.
					ble_gatt_db_char_t srv_changed_handles = m_peer_srv_buf[0].charateristics[0];
					ret = nrf_ble_gatts_c_handles_assign(&m_gatts_c,
					                                     p_evt->conn_handle,
					                                     &srv_changed_handles);
					APP_ERROR_CHECK(ret);

					// Enable indications.
					ret = nrf_ble_gatts_c_enable_indication(&m_gatts_c, true);
					APP_ERROR_CHECK(ret);

					// Load the relevant handles into a ble_ancs_c_service_t struct that can be
					// assigned to the ANCS module.
					ble_ancs_c_service_t ancs_handles;
					ble_gatt_db_char_t* p_char           = m_peer_srv_buf[1].charateristics;
					ancs_handles.control_point_char       = p_char[0].characteristic;
					ancs_handles.notif_source_char        = p_char[1].characteristic;
					ancs_handles.notif_source_cccd.handle = p_char[1].cccd_handle;
					ancs_handles.data_source_char         = p_char[2].characteristic;
					ancs_handles.data_source_cccd.handle  = p_char[2].cccd_handle;

					ret = nrf_ble_ancs_c_handles_assign(&m_ancs_c, p_evt->conn_handle,
					                                    &ancs_handles);
					APP_ERROR_CHECK(ret);
				}
			}
		}
		break;

Related