<?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>Notification Enabled by event or poll</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/646/notification-enabled-by-event-or-poll</link><description>Should we keep track of this by monitoring the write events or poll the gatts value via the softdevice? 
 It looks like it&amp;#39;s faster (+shorter = less consumption) to monitor the event, as to poll the value seems like a lot of code overhead, which I would</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 14 Oct 2013 13:06:40 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/646/notification-enabled-by-event-or-poll" /><item><title>RE: Notification Enabled by event or poll</title><link>https://devzone.nordicsemi.com/thread/3301?ContentTypeID=1</link><pubDate>Mon, 14 Oct 2013 13:06:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6ff37669-700c-444a-9848-f0eb30f64407</guid><dc:creator>KPE</dc:creator><description>&lt;p&gt;Ahh yes I see that this could become an issue, espcially when you are working with limited resources.&lt;/p&gt;
&lt;p&gt;But honestly, I wouldn&amp;#39;t mind not to have to think about it. In many ways I&amp;#39;d also say that you could probably save memory with C++ by simply working smarter - or at least save CPU cycles. Plain procedural C code often has a slight overhead in memory housekeeping, and might therefore be less efficent by moving blocks around more frequently.&lt;/p&gt;
&lt;p&gt;But I &amp;#39;d guess that objects would be similar to structs in their memory behaviour. Most of the API code is carrying structs around from function to function - this is what C++ does behind the scenes with the object instance. When you declare/construct a class it will either live on the stack or in the free (global) memory area, (unless you allocate it dynamically via the heap). So I think it would be comparable to using structs. There are also some memory aspects when working with virtual methods and so on, but these might actually benefit your overall design from beein less clumsy and memory hungry in that you need less blocks of memory to do the same.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Notification Enabled by event or poll</title><link>https://devzone.nordicsemi.com/thread/3300?ContentTypeID=1</link><pubDate>Mon, 14 Oct 2013 11:50:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2085866c-0c9e-4e23-b834-f7c9094c896f</guid><dc:creator>Janek Mann</dc:creator><description>&lt;p&gt;With C++ it is much more difficult (for mere mortals like myself) to understand the memory layout of &amp;quot;classes&amp;quot; and &amp;quot;objects&amp;quot; etc. This is important for embedded programming, so I prefer to use C as it is easier for me to have reasonably accurate expectations of what the compiler will produce.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Notification Enabled by event or poll</title><link>https://devzone.nordicsemi.com/thread/3299?ContentTypeID=1</link><pubDate>Mon, 14 Oct 2013 10:00:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ae2ab089-4867-4cb8-a2dc-ad2077e71fc9</guid><dc:creator>KPE</dc:creator><description>&lt;p&gt;Thanks. I did originally check the NRF_ERROR_INVALID_STATE, but figured that I could probably save some power by not read out data through SPI, preparing it, put it into a buffer and then try to send it - if nobody was actually asking for it :-)&lt;/p&gt;
&lt;p&gt;So I&amp;#39;ve implemented the event handler, as this also induces less overhead than querying the structure for every packet I send.&lt;/p&gt;
&lt;p&gt;If it doesn&amp;#39;t really matter which flavour it comes in, I&amp;#39;ll vote for a future C++ version. I believe that most of your customers will favour this over time as well, as C++ is not as imparative as C (meaning that you can define and see more of the trees in the forest). I&amp;#39;ve already started to convert some of the C files, and the number of lines are shrinking considerably, and the code becomes more natural to read, understand and work with. Of course you will need to adapt to C++ and OOP principles if you are not already familiar with it, but it will pay off in the long run.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Notification Enabled by event or poll</title><link>https://devzone.nordicsemi.com/thread/3298?ContentTypeID=1</link><pubDate>Mon, 14 Oct 2013 09:31:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9a4bff16-62c4-4a5d-a485-e0f429078364</guid><dc:creator>Ole Morten</dc:creator><description>&lt;p&gt;To know when the CCCD is written, you have to monitor the write event, and compare the handle to the CCCD handle of the characteristic you&amp;#39;re interested in. However, unless you want to start anything exactly when the CCCD is written, you can also just try to send a notification and look at the return code. If you get NRF_ERROR_INVALID_STATE back, this means that the CCCD is not currently enabled.&lt;/p&gt;
&lt;p&gt;As for why the softdevice doesn&amp;#39;t expose a C++ API, I don&amp;#39;t really have an explanation as such. However, there isn&amp;#39;t any problems with using the softdevice from a C++ based application, and I know several customers who have been doing this. Using C or C++ in an embedded application seems to me to be mostly a matter of personal preference, but when exposing a C compatible API, this choice is entirely left to the application developer.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>