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

Propagating events to the application; what does it mean?

I arrived at step 8 in this tutorial

github.com/.../custom_ble_service_example

Now I'm supposed to propagate events to the application, for example connection state change events and read and write events.

I now have two questions

  1. Am I currently propagating events to or from the soft device to toggle the LED?
  1. What does it mean to propagate events to the application? Which application is that?

From step 7

Step 7 - Propagating Custom Service events to the application

Until now we've only handled the events that are propagated by the SoftDevice, but in some cases it makes sense to propagate events to the application.

Thanks

  • Hello Michael

    1: An event is generated by the softdevice, which is then forwarded to the application code, see answer below, which again forwards the event to the designated handlers. It is in one of these handlers, in this case the "static void on_write" function in the C file of the custom service, that toggle the LED. So here an event has first been propagated from the Softdevice to the application, and then from the application to the service.

    2: The idea is that the service you design will be in separate files that you can reuse in different projects. The application is then essentially the software in the main file as this will be unique from project to project, while the service code would be the same. Similarly to what I described above, you can propagate an event to the application from the service, by having the service call an event handler that is defined in the main code. In the example this handler is called on_cus_evt, and is registered with the service during service initialization. This event handler can then be called by the service.

    So the signal path for a BLE_GATTS_EVT_WRITE event which enables notification would be something like Softdevice event -> ble_evt_dispatch (in main)->ble_cus_on_ble_evt (in service)->on_write (in service)->on_cus_evt (in main)

    Best regards

    Jørn Frøysa

Related