<?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>Is calling Softdevice function from main context safe?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/4344/is-calling-softdevice-function-from-main-context-safe</link><description>Hello, 
 my application is using the event scheduler while the softdevice is not. Is it save to call softdevice functions (like sd_ble_gap_scan_stop(), dm_device_delete_all(), ...) directly from the main context?</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 07 Nov 2014 10:20:43 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/4344/is-calling-softdevice-function-from-main-context-safe" /><item><title>RE: Is calling Softdevice function from main context safe?</title><link>https://devzone.nordicsemi.com/thread/15449?ContentTypeID=1</link><pubDate>Fri, 07 Nov 2014 10:20:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e12da82e-0182-421f-a67b-e58f7a2135ad</guid><dc:creator>Petter Myhre</dc:creator><description>&lt;p&gt;You would just need to consider that SVC calls and application interrupts will be scheduled and handled in turn. :)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Is calling Softdevice function from main context safe?</title><link>https://devzone.nordicsemi.com/thread/15448?ContentTypeID=1</link><pubDate>Fri, 07 Nov 2014 09:59:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c8b656dd-5d13-474e-a11b-dce1ebdbcb21</guid><dc:creator>michael</dc:creator><description>&lt;p&gt;Thanks Petter! What I&amp;#39;m reading from your reply is that it might be a better idea to use the scheduler for both, the application and the softdevice. I ended up in the constellation I&amp;#39;m currently using because I started from a S120 example that did not use the scheduler for the SD and I did not yet dare to change it. In case I&amp;#39;m using the scheduler for my application anyways, are there any reasons or considerations why I would not use the scheduler also for the softdevice?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Is calling Softdevice function from main context safe?</title><link>https://devzone.nordicsemi.com/thread/15447?ContentTypeID=1</link><pubDate>Fri, 07 Nov 2014 08:38:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b0a180b4-e435-4105-acbb-46303d2fbbcc</guid><dc:creator>Petter Myhre</dc:creator><description>&lt;p&gt;&lt;code&gt;dm_device_delete_all()&lt;/code&gt; is a function that belongs to the Device Manager, which is a software module, it is not part of the SoftDevice.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;sd_ble_gap_scan_stop()&lt;/code&gt; is an SVC call and has interrupt priority 2 (0 is the highest, 3 is the lowest)&lt;/p&gt;
&lt;p&gt;There are two application interrupt priorities available, 1 and 3.&lt;/p&gt;
&lt;p&gt;The general answer is yes, it is safe, but it depends on your application, you could get unwanted behavior if you don&amp;#39;t keep in mind how the interrupts and the events are handled.&lt;/p&gt;
&lt;p&gt;One difference will be that:&lt;/p&gt;
&lt;p&gt;If you use scheduling on both the application and the SoftDevice, SVC calls and application interrupts will be scheduled and handled in turn.&lt;/p&gt;
&lt;p&gt;If you use scheduling only on the application, the SoftDevice will be able to interrupt the scheduled application events, even the ones with priority 1.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>