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

Questions – orders of event reported to the app?

Dear sirs/madams

I am using SDK 17.0.2

Situation:

One Central unit (nRF52840) and one Peripheral unit (nRF52840) have established a connection (NUS service).

When Central unit is switched off, I get the following events in peripheral unit in the following order:

  • on_adv_evt(….) with the event BLE_ADV_FAST
  • ble_evt_handler(….) with the event BLE_GAP_EVT_DISCONNECTED

 

Why do I get these events in this order? To my understanding these events should come in the opposite order.

 

Kind regards

Svein

Parents
  • Hello,

    The event order is controlled by what priority the observer handlers have been assigned with, please refer to the "Observers and their priorities" section of the SoftDevice Handler library documentation for a more detailed description of this. You could increase the priority of the 'ble_evt_handler' if you want it to get called before the advertising callback, but it's usually recommended to keep the priorities as is. Do you need to have the ble_evt_handler called first?

    Best regards,

    Vidar

  • Hi Vidar,

    Thanks a lot for your feedback.

    On the peripheral device we have an OLED screen where various information is printed. Our customer also wants to know the status of the connection between the peripheral and central unit, hence we want to display advertising when advertising, connect when connected, disconnect when disconnected, and so on. As it is now with the order of reporting of these events to the APP the sequence printed to the OLED become wrong. Sometimes the advertising event is received after that the connect event is received and sometimes, I get the advertising event before the disconnect event. This behaviour led to that the information written to the display does not always match the actual state.

    I will take a closer look at the links you pointed to and hopefully I will be able to solve this minor problem.  Blush

     

    Kind regards,

    Svein

Reply
  • Hi Vidar,

    Thanks a lot for your feedback.

    On the peripheral device we have an OLED screen where various information is printed. Our customer also wants to know the status of the connection between the peripheral and central unit, hence we want to display advertising when advertising, connect when connected, disconnect when disconnected, and so on. As it is now with the order of reporting of these events to the APP the sequence printed to the OLED become wrong. Sometimes the advertising event is received after that the connect event is received and sometimes, I get the advertising event before the disconnect event. This behaviour led to that the information written to the display does not always match the actual state.

    I will take a closer look at the links you pointed to and hopefully I will be able to solve this minor problem.  Blush

     

    Kind regards,

    Svein

Children
No Data
Related