<?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>When are BLE event observers called? Getting disconnection events as fast as possible?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/42197/when-are-ble-event-observers-called-getting-disconnection-events-as-fast-as-possible</link><description>Hi, 
 I&amp;#39;m working on a custom bootloader based on the one included with SDK 15. 
 I have a blocking method (i.e. while loop) that runs at the end of the transmission of all the data over BLE. I want to break out of the while loop and throw an error if</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 08 Jan 2019 10:04:42 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/42197/when-are-ble-event-observers-called-getting-disconnection-events-as-fast-as-possible" /><item><title>RE: When are BLE event observers called? Getting disconnection events as fast as possible?</title><link>https://devzone.nordicsemi.com/thread/164481?ContentTypeID=1</link><pubDate>Tue, 08 Jan 2019 10:04:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6cc5913c-d5c3-4a7f-b45e-adf2d8390772</guid><dc:creator>Andy</dc:creator><description>&lt;p&gt;That&amp;#39;s correct. Anyway, apparently, the app developers decided it wasn&amp;#39;t a big deal so I&amp;#39;m not pursuing this further. In the case I need to do this in the future, I will try to call it from the app scheduler.&lt;/p&gt;
&lt;p&gt;Thanks for your help as always :)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: When are BLE event observers called? Getting disconnection events as fast as possible?</title><link>https://devzone.nordicsemi.com/thread/164473?ContentTypeID=1</link><pubDate>Tue, 08 Jan 2019 09:45:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3f191bf9-36c9-4629-8a7d-89f95051aff7</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;&amp;nbsp;I assume you want to receive the last acknowledgment on the phone that the image has been transfer via I2C successfully before disconnection. If the DFU process can be finished successfully without the phone, from my opinion it&amp;#39;s OK even though there is a disconnection before the last step finishes.&amp;nbsp;&lt;br /&gt;But please try to put the function to app scheduler , I think it would fix the issue.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: When are BLE event observers called? Getting disconnection events as fast as possible?</title><link>https://devzone.nordicsemi.com/thread/164348?ContentTypeID=1</link><pubDate>Mon, 07 Jan 2019 16:05:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:df6ff63a-5f13-424f-ab75-ec9799814f3e</guid><dc:creator>Andy</dc:creator><description>&lt;p&gt;I actually thought that this function was already called from the main context using the app scheduler, but apparently, it isn&amp;#39;t. It is only scheduled in case there&amp;#39;s a flash operation pending. I think that if I force it to be scheduled, it should work then.&lt;/p&gt;
&lt;p&gt;My bootloader is already heavily modified. I have an app that performs the DFU on my device. Apparently, from the app developer&amp;#39;s perspective, it doesn&amp;#39;t make sense that the DFU continues by itself if the app is not connected, even though the actual BLE transfer is done. The I2C&amp;nbsp;erase, transfer and CRC check together still take about a minute after the BLE transfer.&lt;/p&gt;
&lt;p&gt;I&amp;#39;m told that if the process continues, this behavior gives problems in case of disconnection/reconnection during DFU.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: When are BLE event observers called? Getting disconnection events as fast as possible?</title><link>https://devzone.nordicsemi.com/thread/164330?ContentTypeID=1</link><pubDate>Mon, 07 Jan 2019 15:19:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b0cd1f45-0b96-425a-8c22-9eae43940283</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Most likely the command&amp;nbsp;&lt;strong&gt;on_data_obj_execute_request_sched() &lt;/strong&gt;will be called when there is an BLE event of an execute object write meaning you would have same priority level with the Disconnected event.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;Why do you need to stop the operation when the device disconnect ?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;You may want to think of using&amp;nbsp;app_sched_event_put() to schedule the loop into main context. But you may need to modify the bootloader because I afraid it would reset before you can execute that loop (when&amp;nbsp;dfu_observer() receives NRF_DFU_EVT_DFU_COMPLETED the bootloader will reset)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: When are BLE event observers called? Getting disconnection events as fast as possible?</title><link>https://devzone.nordicsemi.com/thread/164250?ContentTypeID=1</link><pubDate>Mon, 07 Jan 2019 12:54:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:341f2f19-d17f-4443-bffd-1345c012e2ff</guid><dc:creator>Andy</dc:creator><description>&lt;p&gt;I use the NRF52832 to perform the DFU over BLE for an STM32. The loop is basically writing the contents of the flash in bank 1 to the STM over I2C.&lt;/p&gt;
&lt;p&gt;The loop is within the body of&amp;nbsp;&lt;strong&gt;nrf_dfu_validation_post_data_execute()&lt;/strong&gt;, which is called by &lt;strong&gt;on_data_obj_execute_request_sched()&lt;/strong&gt;, a function queued and called by the app scheduler.&lt;/p&gt;
&lt;p&gt;I don&amp;#39;t know if the priority of the app scheduler is higher than the SD event stuff, but I doubt it.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: When are BLE event observers called? Getting disconnection events as fast as possible?</title><link>https://devzone.nordicsemi.com/thread/164238?ContentTypeID=1</link><pubDate>Mon, 07 Jan 2019 12:35:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f5c68eb8-49c6-423d-a9a6-8017bcf22e62</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Andy,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Where do you have the loop ? Could you explain a little bit more what&amp;#39;s the loop for ?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;If you have a look at Section 7.2 in the S132 SDS v6.0 you can find the&amp;nbsp;SoftDevice Event Notification is at priority level 6 .&amp;nbsp;&lt;/p&gt;
&lt;p&gt;If you have your loop at level 6 or higher (6-5-4 etc) the event wouldn&amp;#39;t be able to preempt your loop. If you need to stay in a loop you should set the context level to priority lv 7 or in main.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>