<?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>BLE with FreeRTOS, user events</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/71784/ble-with-freertos-user-events</link><description>A plain question : we are using the BLE stack with FreeRTOS based observers. 
 Is it possible to send to some observer an application defined event from some other FreeRTOS task.</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 19 Feb 2021 15:30:39 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/71784/ble-with-freertos-user-events" /><item><title>RE: BLE with FreeRTOS, user events</title><link>https://devzone.nordicsemi.com/thread/295391?ContentTypeID=1</link><pubDate>Fri, 19 Feb 2021 15:30:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6cc7cd75-943f-4571-82ef-2f4ada1f64fc</guid><dc:creator>Vincent Bela&amp;#239;che</dc:creator><description>&lt;p&gt;Thank you&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/members/vibe"&gt;Vidar Berg&lt;/a&gt;&amp;nbsp;for the answer.&lt;/p&gt;
&lt;p&gt;I definitely was referring to custom app events.&lt;/p&gt;
&lt;p&gt;The only reason why I was mentioning&amp;nbsp;SDH stack observers was to use an observer like a hook function to be processed within&amp;nbsp;the nrf_sdh_freertos task main loop, and this hook function could be used to check for any suitable FreeRTOS inter-thread communication objects.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE with FreeRTOS, user events</title><link>https://devzone.nordicsemi.com/thread/295390?ContentTypeID=1</link><pubDate>Fri, 19 Feb 2021 15:25:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:38ae6570-8d65-4383-a638-e7fd2b69f556</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;I misread your question, I thought you were referring to custom app events defined by you, not Softdevice events from the Softdevice handler libary. Anyway. You can define as many observers as you like outside nrf_sdh_freertos.c&amp;nbsp; file(within reasonable limits of course), does that help?&lt;/p&gt;
[quote]Then I understand that the definition of NRF_SDH_STACK_OBSERVER_PRIO_LEVELS by default to 2, while&amp;nbsp;NRF_SDH_BLE_STACK_OBSERVER_PRIO is by default defined to 0, suggests that priority 1 can be used for application specific sdh stack observers.[/quote]
&lt;p&gt;&amp;nbsp;This defines the order of which the observers are stored in memory, and hence in what order they called. It&amp;#39;s not related to OS task priorities (&lt;span&gt;&lt;a title="Registering section set variables" href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.2/lib_section_iter.html?cp=7_1_3_57_3_1#lib_section_vars_usage_regdata"&gt;Registering section set variables, &lt;/a&gt;&lt;a title="Assigning priorities" href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.2/lib_softdevice_handler.html?cp=7_1_3_48_2_1#lib_sdh_priority"&gt;Assigning priorities&lt;/a&gt;&lt;/span&gt;). &lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE with FreeRTOS, user events</title><link>https://devzone.nordicsemi.com/thread/295385?ContentTypeID=1</link><pubDate>Fri, 19 Feb 2021 15:04:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4c476d26-c4ee-4aec-a4d8-e2fa328fdc18</guid><dc:creator>Vincent Bela&amp;#239;che</dc:creator><description>&lt;p&gt;OK I see. So the way to make it would be to register some stack observer function the context of which would contain e.g. some FreeRTOS queue, and the function would peek this queue everytime the observer handler is called.&lt;/p&gt;
&lt;p&gt;Is this what you have in mind ?&lt;/p&gt;
&lt;p&gt;Then I understand that the definition of NRF_SDH_STACK_OBSERVER_PRIO_LEVELS by default to 2, while&amp;nbsp;NRF_SDH_BLE_STACK_OBSERVER_PRIO is by default defined to 0, suggests that priority 1 can be used for application specific sdh stack observers.&lt;/p&gt;
&lt;p&gt;Is that correct ?&lt;/p&gt;
&lt;p&gt;But then we have limitation with&amp;nbsp;nrf_sdh_freertos.c :&amp;nbsp;m_softdevice_task is declared static (in C jargon local to this file), so it is not visible outside, so the task cannot be notified from another FreeRTOS task just by calling xTaskNotifyGive(m_softdevice_task), for our application specific SDH stack observer to come in action. Maybe the following patch could help:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/patch.diff"&gt;devzone.nordicsemi.com/.../patch.diff&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE with FreeRTOS, user events</title><link>https://devzone.nordicsemi.com/thread/295340?ContentTypeID=1</link><pubDate>Fri, 19 Feb 2021 12:59:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ee390b8f-a520-43f1-ae16-e2343f4aa75a</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;One of my colleagues who&amp;#39;s experienced with Freertos said it was best to use existing OS module to achieve the event-observer communication between threads.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://www.freertos.org/Inter-Task-Communication.html"&gt;https://www.freertos.org/Inter-Task-Communication.html&lt;/a&gt; &lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>