<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Propagating events to the application; what does it mean?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/22842/propagating-events-to-the-application-what-does-it-mean</link><description>I arrived at step 8 in this tutorial 
 github.com/.../custom_ble_service_example 
 Now I&amp;#39;m supposed to propagate events to the application, for example connection state change events and read and write events. 
 I now have two questions 
 
 
 Am</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 16 Jun 2017 13:36:49 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/22842/propagating-events-to-the-application-what-does-it-mean" /><item><title>RE: Propagating events to the application; what does it mean?</title><link>https://devzone.nordicsemi.com/thread/89804?ContentTypeID=1</link><pubDate>Fri, 16 Jun 2017 13:36:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d1be8855-fea8-4dfe-a756-05cec4d961a6</guid><dc:creator>J&amp;#248;rn</dc:creator><description>&lt;p&gt;Hello Michael&lt;/p&gt;
&lt;p&gt;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 &amp;quot;static void on_write&amp;quot; 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.&lt;/p&gt;
&lt;p&gt;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.&lt;/p&gt;
&lt;p&gt;So the signal path for a BLE_GATTS_EVT_WRITE event which enables notification would be something like
Softdevice event -&amp;gt; ble_evt_dispatch (in main)-&amp;gt;ble_cus_on_ble_evt (in service)-&amp;gt;on_write (in service)-&amp;gt;on_cus_evt (in main)&lt;/p&gt;
&lt;p&gt;Best regards&lt;/p&gt;
&lt;p&gt;Jørn Frøysa&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>