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

ble_evt_dispatch sdk14

Hi,

I am confused with the migration document regarding the dispatch function being removed.

In the previous uart example the dispatch function included:

ble_conn_params_on_ble_evt(p_ble_evt);
nrf_ble_gatt_on_ble_evt(&m_gatt, p_ble_evt);
ble_nus_on_ble_evt(&m_nus, p_ble_evt);
on_ble_evt(p_ble_evt);
ble_advertising_on_ble_evt(p_ble_evt);
bsp_btn_ble_on_ble_evt(p_ble_evt);

now there is the OBSERVER definition:

NRF_SDH_BLE_OBSERVER(m_ble_observer, APP_BLE_OBSERVER_PRIO, ble_evt_handler, NULL);

and instances:

BLE_NUS_DEF(m_nus); /**< BLE NUS service instance. */

NRF_BLE_GATT_DEF(m_gatt); /**< GATT module instance. */

BLE_ADVERTISING_DEF(m_advertising); /**< Advertising module instance. */

where are (the equal functions) ble_conn_params_on_ble_evt(p_ble_evt); nrf_ble_gatt_on_ble_evt(&m_gatt, p_ble_evt); ble_nus_on_ble_evt(&m_nus, p_ble_evt); on_ble_evt(p_ble_evt); ble_advertising_on_ble_evt(p_ble_evt); bsp_btn_ble_on_ble_evt(p_ble_evt);

called?

And what about the sys_event_handler?

BR

  • Hi Bjarke,

    You don't need to register the equivalent observers for 'ble_conn_params_on_ble_evt', 'ble_conn_state_on_ble_evt', 'pm_on_ble_evt' and many others, since they all are registered in the respective source files - ble_conn_params.c, ble_conn_state.c, peer_manager.c and so on.

    If you'd search for their respective priorities you'll easily be able to locate the piece of code where the observers are registered.

    But as far as I know, you still need to register the observers for your custom service, ble events in your application and if you're using any other ble_services - NUS, HRS, etc. I hope this helps!

    Regards,

    Abe

  • Hi,

    I have done all that and can find the Observer registrations in the SDK files. And I can compile the program, but when I run it on my board, it wont work(no advertise). I dont know if it has something to do with the memory location, even though I have increased the softdevice space to 0x00023000 before the app begins. And it looks ok when I use the nrf-intel-hex-viewer.

    It does complain about APP_BLE_OBSERVER_PRIO 3 as in the uart example, when I set it to 2 it will compile BR

  • Hi, I'm no expert but having spent a lot of time debugging the advertising for SDK 14.2, there are a couple of things I can guide you to look into, namely -

    1. If you're using a Vendor Specified Service (a custom service), then according to the github project by Bjorn(github.com/.../custom_ble_service_example) you'll have to update the start address of the RAM to 0x200020F0 and the length to 0xDF10. Also, you'll need to set the NRF_SDH_BLE_VS_UUID_COUNT to 1 in SDK_CONFIG.H
    2. The observer pattern is still a little new to me but according to the documentation, if you're trying to register two observers with the same priorities, you should make sure that they're not dependent on each other's state, since the stack follows a random choice algorithm when it encounters two or more observers with same priority and it depends on how they were linked.
Related