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

S110 & SDK9 -> S140 & SDK14, BLE Handler Register ploblem

Hi,

I had a difficult problem.

First, S110 & SDK9 ble_stack_init () is the source.

static void ble_stack_init(void)
{
	uint32_t err_code;

	// Initialize the SoftDevice handler module.
	SOFTDEVICE_HANDLER_INIT(NRF_CLOCK_LFCLKSRC_RC_250_PPM_250MS_CALIBRATION, NULL);

	#if defined(S110) || defined(S130) || defined(S310)
	// Enable BLE stack.
	ble_enable_params_t ble_enable_params;
	memset(&ble_enable_params, 0, sizeof(ble_enable_params));
	#if defined(S130) || defined(S310)
	ble_enable_params.gatts_enable_params.attr_tab_size   = BLE_GATTS_ATTR_TAB_SIZE_DEFAULT;
	#endif
	ble_enable_params.gatts_enable_params.service_changed = IS_SRVC_CHANGED_CHARACT_PRESENT;
	err_code = sd_ble_enable(&ble_enable_params);
	APP_ERROR_CHECK(err_code);
	#endif

	// Register with the SoftDevice handler module for BLE events.
	err_code = softdevice_ble_evt_handler_set(ble_evt_dispatch);
	APP_ERROR_CHECK(err_code);

	// Register with the SoftDevice handler module for BLE events.
	err_code = softdevice_sys_evt_handler_set(sys_evt_dispatch);
	APP_ERROR_CHECK(err_code);
}

And the ble_evt_dispatch part,

static void ble_evt_dispatch(ble_evt_t * p_ble_evt)
{
	#if 0
	{
		uint8_t dbg_msg[128];
		sprintf((char *)dbg_msg, "evt id: %x, len: %d\n", p_ble_evt->header.evt_id, p_ble_evt->header.evt_len);
		writepen_debugmsg(dbg_msg);
	}
	#endif

	dm_ble_evt_handler(p_ble_evt);
	ble_writepen_on_ble_evt(&m_writepen, p_ble_evt);
	ble_conn_params_on_ble_evt(p_ble_evt);
	// bsp_btn_ble_on_ble_evt(p_ble_evt);
	#ifdef BLE_DFU_APP_SUPPORT
	/** @snippet [Propagating BLE Stack events to DFU Service] */
	ble_dfu_on_ble_evt(&m_dfus, p_ble_evt);
	/** @snippet [Propagating BLE Stack events to DFU Service] */
	#endif // BLE_DFU_APP_SUPPORT
	on_ble_evt(p_ble_evt);
	ble_advertising_on_ble_evt(p_ble_evt);
}

Here I would like to add a handler like softdevice_ble_evt_handler_set (ble_evt_dispatch) and softdevice_sys_evt_handler_set (sys_evt_dispatch).

But in S140 & SDK14, it is difficult to find the corresponding function.

The following is the part ble_stack_init () used in S140 & SDK14.

static void ble_stack_init (void)
{
     ret_code_t err_code;

     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 (m_ble_observer, APP_BLE_OBSERVER_PRIO, ble_evt_handler, NULL);
}

I would appreciate if you can help me with functions that function softdevice_ble_evt_handler_set and ble_evt_dispatch in S140 and SDK14.

Related