<?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>scheduler and struct</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/15938/scheduler-and-struct</link><description>Hi, 
 I would like to save some data from characteristic into the Flash. Due to this fact I decided that I will use scheduler. When the value of actual characteristic is changed the writing event handler triggers the following event handler 
 static</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 24 Aug 2016 12:58:46 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/15938/scheduler-and-struct" /><item><title>RE: scheduler and struct</title><link>https://devzone.nordicsemi.com/thread/60801?ContentTypeID=1</link><pubDate>Wed, 24 Aug 2016 12:58:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:501bd131-c8f0-42ba-8548-b216e59b63d8</guid><dc:creator>samo</dc:creator><description>&lt;p&gt;Thank one more time, Bill.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: scheduler and struct</title><link>https://devzone.nordicsemi.com/thread/60800?ContentTypeID=1</link><pubDate>Wed, 24 Aug 2016 12:56:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a0af2829-f21c-41b0-85e4-d6ab5c2438fe</guid><dc:creator>Bill Siever</dc:creator><description>&lt;p&gt;There are at least two major approaches. A) If all your events have different lengths, you could decide based on the length. (I consider this a poor design, but it would work). B) It would be better to use struct that contains a type-tag and a union of all the possible message types (i.e., a tagged union). In this approach all messages would take the same space in the event queue even if not all of it was used.  Here&amp;#39;s a stackoverflow article that has a response (by Tom Anderson) showing the C syntax for such a union and explaining a bit about it: &lt;a href="http://stackoverflow.com/questions/4194506/how-to-know-that-which-variable-from-union-is-used"&gt;http://stackoverflow.com/questions/4194506/how-to-know-that-which-variable-from-union-is-used&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: scheduler and struct</title><link>https://devzone.nordicsemi.com/thread/60799?ContentTypeID=1</link><pubDate>Wed, 24 Aug 2016 12:30:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dc7530f8-fbe2-4d14-8699-f053a10bd5ea</guid><dc:creator>samo</dc:creator><description>&lt;p&gt;At this point, I have still one short question. How I can check if void *p_event_data is really ble_srv_utf8_str_t type. I would like to apply different types in p_evet_data and if statment before that is required. What is the best solution for my problem.&lt;/p&gt;
&lt;p&gt;Thanks for help&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: scheduler and struct</title><link>https://devzone.nordicsemi.com/thread/60798?ContentTypeID=1</link><pubDate>Wed, 24 Aug 2016 10:20:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8c584ee7-f284-44a6-a521-d3f61757565a</guid><dc:creator>samo</dc:creator><description>&lt;p&gt;Now everythink work fine, you have right:) Thanks for help, Bill.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: scheduler and struct</title><link>https://devzone.nordicsemi.com/thread/60797?ContentTypeID=1</link><pubDate>Wed, 24 Aug 2016 00:19:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c9826372-6fbf-4893-95de-be83e5565a52</guid><dc:creator>Bill Siever</dc:creator><description>&lt;p&gt;It doesn&amp;#39;t look like your event handler matches the &lt;em&gt;app_sched_event_handler_t&lt;/em&gt; required by &lt;em&gt;app_sched_event_put&lt;/em&gt;.  It should probably look like:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;void scheduler_name_flash_handler(void *p_event_data, uint16_t size) {
   // Note the signature is void function(void *, uint16_t)
   // Assuming the data really points to a &amp;quot;ble_srv_utf8_str_t&amp;quot;, just type cast it.
   ble_srv_utf8_str_t *p_srv_utf8_str = (ble_srv_utf8_str_t *)p_event_data;
    ...
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You may need to typecast the parameter being passed too, like:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;    app_sched_event_put((void *)&amp;amp;name, sizeof(name),scheduler_name_flash_handler);
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>