<?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>NRF_SDH_BLE_OBSERVER and other questions, including macro clarification</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/46522/nrf_sdh_ble_observer-and-other-questions-including-macro-clarification</link><description>Folks, 
 This is probably a C question as much as Nordic, so I might be told this is off topic. That&amp;#39;s fine if so, I can try Stack Overflow. 
 I never use macros in my C code other than things like #define BUFFER_SIZE 10 as I like the least obfuscated</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 24 Apr 2019 10:35:23 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/46522/nrf_sdh_ble_observer-and-other-questions-including-macro-clarification" /><item><title>RE: NRF_SDH_BLE_OBSERVER and other questions, including macro clarification</title><link>https://devzone.nordicsemi.com/thread/183403?ContentTypeID=1</link><pubDate>Wed, 24 Apr 2019 10:35:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e8e08569-e2d7-4716-b43c-12ae2d19a92d</guid><dc:creator>Andy</dc:creator><description>&lt;p&gt;Happy to help :)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF_SDH_BLE_OBSERVER and other questions, including macro clarification</title><link>https://devzone.nordicsemi.com/thread/183397?ContentTypeID=1</link><pubDate>Wed, 24 Apr 2019 10:11:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7024cc69-9854-4582-afcf-9b2b6f21e5b0</guid><dc:creator>DiBosco</dc:creator><description>&lt;p&gt;Thanks Andy, that&amp;#39;s helpful. As I was drifting off to sleep last night it suddenly hit me that I should have run the preprocessor on main.c not my file and sure enough I can see the expanded macro there. &lt;/p&gt;
&lt;p&gt;The other question was about what an observer is, which you kindly answered. Thanks again.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF_SDH_BLE_OBSERVER and other questions, including macro clarification</title><link>https://devzone.nordicsemi.com/thread/183224?ContentTypeID=1</link><pubDate>Tue, 23 Apr 2019 18:02:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:85971b53-d97c-45d9-a827-b62f0755aa43</guid><dc:creator>Andy</dc:creator><description>[quote userid="79197" url="~/f/nordic-q-a/46522/nrf_sdh_ble_observer-and-other-questions-including-macro-clarification"]what, exactly, is this observer thing please?[/quote]
&lt;p&gt;I can&amp;#39;t tell you &lt;strong&gt;exactly&lt;/strong&gt; what it is because I don&amp;#39;t understand it fully myself, but -in a nutshell- it declares a function that will be called whenever a BLE event happens.&amp;nbsp;The linker file specifies some memory sections and the softdevice&amp;nbsp;somehow refers to these sections internally.&lt;/p&gt;
&lt;p&gt;This macro:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;NRF_SDH_BLE_OBSERVER(m_ble_observer, APP_BLE_OBSERVER_PRIO, ble_evt_handler, NULL);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;expands to this:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static_assert(1, &amp;quot;NRF_SDH_BLE_ENABLED not set!&amp;quot;);                                 \
static_assert(3 &amp;lt; 4, &amp;quot;Priority level unavailable.&amp;quot;);             \
static nrf_sdh_ble_evt_observer_t m_ble_observer __attribute__ ((section(&amp;quot;.&amp;quot; &amp;quot;sdh_ble_observers3&amp;quot;))) __attribute__((used)) =  \
{                                                                                                   \
    .handler   = ble_evt_handler,                                                                          \
    .p_context = ((void *)0)                                                                           \
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Which as far as I understand it just puts a struct in a specific section in memory.&lt;/p&gt;
&lt;hr /&gt;[quote userid="79197" url="~/f/nordic-q-a/46522/nrf_sdh_ble_observer-and-other-questions-including-macro-clarification"]Oh and one more thing, I see this &amp;quot;soft device&amp;quot; term used, what is that please?[/quote]
&lt;p&gt;The softdevice is just how Nordic calls its radio stack. It comes as a precompiled hex file and needs to be flashed together with the application if you want to use any radio functionality.&lt;/p&gt;
&lt;hr /&gt;[quote userid="79197" url="~/f/nordic-q-a/46522/nrf_sdh_ble_observer-and-other-questions-including-macro-clarification"]So the other question is[/quote]
&lt;p&gt;What was the other question?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>