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

Nrf52810 - SDH BLE OBSERVER Not getting Notified

Hi All,

I have an application successfully running on nrf52832 with sd132 which I am migrating to nrf52810 sd112. Unfortunately since the softdevice structure has changed I am facing issues.

The device is able to advertise fine. However when I try to connect, it simply hangs / goes on forever

my code is

err_code = nrf_sdh_enable_request();
	APP_ERROR_CHECK(err_code);

	//CONFIGURE THE BLE STACK USING THE DEFAULT SETTINGS.
    //FETCH THE START ADDRESS OF THE APPLICATION RAM.
    uint32_t ram_start = 0;
    err_code = nrf_sdh_ble_default_cfg_set(APP_BLE_CONN_CFG_TAG, &ram_start);
    APP_ERROR_CHECK(err_code);

	//ENABLE BLE STACK
    err_code = nrf_sdh_ble_enable(&ram_start);
    APP_ERROR_CHECK(err_code);

	//REGISTER A HANDLER FOR BLE EVENTS
    NRF_SDH_BLE_OBSERVER(s_ble_observer, 
							APP_BLE_OBSERVER_PRIO, 
							s_internal_ble_evt_handler, 
							NULL);
	
	//REGISTER DISPATCH FOR SYSTEM EVENTS
	NRF_SDH_SOC_OBSERVER(s_ble_soc_observer,
							APP_SOC_OBSERVER_PRIO, 
							s_internal_ble_sys_evt_dispatch, 
							NULL);

	UTIL_DebugPrint("BLE - BLE Stack Init...\n");

static void s_internal_ble_evt_handler(ble_evt_t const* p_ble_evt, void* p_context)
{
	//HANDLER FOR APPLICATION BLE EVENTS
	
	UTIL_DebugPrint("AAAAAAAA\n");
	
	switch(p_ble_evt->header.evt_id)
	{
		case BLE_GAP_EVT_CONNECTED:
			UTIL_DebugPrint("BLE - BLE_GAP_EVT_CONNECTED\n");
			float time = (p_ble_evt->evt.gap_evt.params.connected.conn_params.max_conn_interval) * 1.25;
			uint16_t time_int = (uint16_t)time;
			uint16_t  time_dec = (uint16_t)((time - time_int)*100);
			UTIL_DebugPrint("BLE - BLE Interval = %u.%u ms\n",time_int, time_dec);
			s_conn_handle = p_ble_evt->evt.gap_evt.conn_handle;
			EXTERNAL_CUSTOM_BLE_SERVICE_SetBleHandle(s_conn_handle);
			break;

		case BLE_GAP_EVT_DISCONNECTED:
			UTIL_DebugPrint("BLE - BLE_GAP_EVT_DISCONNECTED\n");
			s_conn_handle = BLE_CONN_HANDLE_INVALID;
			break;

		case BLE_GAP_EVT_TIMEOUT:
			UTIL_DebugPrint("BLE - BLE_GAP_EVT_TIMEOUT\n");
			break;

		case BLE_GATTS_EVT_WRITE:
			UTIL_DebugPrint("BLE - BLE_GATTS_EVT_WRITE\n");
			s_internal_ble_handle_gatts_evt_write(p_ble_evt);
			break;

		default:
			break;
	}
}

I was expecting when the central tries to connect, I should see some debug prints on the log terminal. However nothing gets printed and the 1 second timer that I have running that prints to the log window also stops.

It's almost like the observer function is never being called

Any help is appreciated.

Related