<?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>nrf5_calendar example callback function?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/58443/nrf5_calendar-example-callback-function</link><description>Hello, 
 I am using nrf52840 and SDK 16.0.0 
 I am doing some work with the calendar example and got some questions. 
 Q1. 
 Inside the main function in main.c file there is nrf_cal_set_callback (calendar_updated, 4 ); function. How it can be called multiple</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 28 Feb 2020 19:10:56 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/58443/nrf5_calendar-example-callback-function" /><item><title>RE: nrf5_calendar example callback function?</title><link>https://devzone.nordicsemi.com/thread/237241?ContentTypeID=1</link><pubDate>Fri, 28 Feb 2020 19:10:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:67cd097a-6d3c-4c72-9aa9-3f8f8f1dffdc</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;You get this error because you have the app_timer library included in your application, which uses RTC1.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf5_calendar example callback function?</title><link>https://devzone.nordicsemi.com/thread/237237?ContentTypeID=1</link><pubDate>Fri, 28 Feb 2020 19:01:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1017931d-7288-428c-a0e6-acd6cad2614b</guid><dc:creator>dalsee</dc:creator><description>&lt;p&gt;Thanks for your reply. However, whenever I try to use RTC1 by changing&lt;a href="https://github.com/NordicPlayground/nrf5-calendar-example/blob/master/nrf_calendar.h#L21"&gt; #define in the header&lt;/a&gt; it returns this compile error. So I had to use RTC2 instead because it does not return any error. Could you kindly explain this situation please? Thank you !!&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/Screen-Shot-2020_2D00_02_2D00_28-at-12.44.03-PM.png" /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf5_calendar example callback function?</title><link>https://devzone.nordicsemi.com/thread/237235?ContentTypeID=1</link><pubDate>Fri, 28 Feb 2020 18:52:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f551288a-b30f-48dd-8da1-b641e9a821af</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Yes, that is correct. That line is a reference to &lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.1/rtc.html?cp=4_2_0_24_9#topic"&gt;a register in the RTC peripheral&lt;/a&gt; itself. &lt;a href="https://github.com/NordicPlayground/nrf5-calendar-example/blob/master/nrf_calendar.h#L21"&gt;CAL_RTC is defined in the header&lt;/a&gt;, allowing you to easily change it if the default RTC instance used is occupied by other libraries (RTC0 is by default used by the softdevice when running BLE application).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf5_calendar example callback function?</title><link>https://devzone.nordicsemi.com/thread/237213?ContentTypeID=1</link><pubDate>Fri, 28 Feb 2020 16:21:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c204cc82-4e3c-429e-b963-2213a0cd4b34</guid><dc:creator>dalsee</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;Could you let me know if I understand everything correctly?&lt;/p&gt;
&lt;p&gt;So, inside the nrf_calendar.c file, this function below is the interrupt handler right?&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;void CAL_RTC_IRQHandler(void)
{
    if(CAL_RTC-&amp;gt;EVENTS_COMPARE[0])
    {
        CAL_RTC-&amp;gt;EVENTS_COMPARE[0] = 0;
        
        CAL_RTC-&amp;gt;TASKS_CLEAR = 1;
        
        m_time += m_rtc_increment;
        if(cal_event_callback) cal_event_callback();
    }
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Now, I have questions, what does this line mean?&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;CAL_RTC-&amp;gt;EVENTS_COMPARE[0]&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf5_calendar example callback function?</title><link>https://devzone.nordicsemi.com/thread/237112?ContentTypeID=1</link><pubDate>Fri, 28 Feb 2020 12:04:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f961829c-e895-48e3-bd44-55c7d404d694</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Q1. When you call&amp;nbsp;&lt;span&gt;nrf_cal_set_callback(), this tells the nrf_calendar library which function to call with events. The callback will be called whenever the nrf_calendar library has an event for the application. The calendar library uses the RTC peripheral to keep track of time, which will generate interrupts on given conditions. From the interrupt handler, the application callback will be called if there are relevant events for the application.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Q2. This looks ok to me.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards,&lt;br /&gt;Jørgen&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf5_calendar example callback function?</title><link>https://devzone.nordicsemi.com/thread/236995?ContentTypeID=1</link><pubDate>Thu, 27 Feb 2020 21:19:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:957ebbd4-2922-4e27-8502-87dce0ef1a83</guid><dc:creator>dalsee</dc:creator><description>&lt;p&gt;To be more specific about Q2,&lt;/p&gt;
&lt;p&gt;Advertisement update function looks like below. I got the function from this &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/57324/confusion-about-new-style-of-manufacturer-specific-data-updating/236981#236981"&gt;thread&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;static void advertising_update_mfg_data(void)
{
    ret_code_t             err_code;

    static ble_advdata_t new_data; // SDK 16.x.x implementation is similar to advertising_init

    // Variables used for manufacturer specific data
    ble_advdata_manuf_data_t p_manuf_specific_data;
    uint8_array_t            adv_manuf_data_array;
    uint8_t                  adv_manuf_data_data[1];
    
    // Configuration of manufacturer specific data
    adv_manuf_data_data[0] = nrf_cal_get_time()-&amp;gt;tm_sec;   // Update second
    
    
    adv_manuf_data_array.p_data      = adv_manuf_data_data;
    adv_manuf_data_array.size        = sizeof(adv_manuf_data_data);

    p_manuf_specific_data.company_identifier = 0x0059;
    p_manuf_specific_data.data       = adv_manuf_data_array; 
      
    new_data.p_manuf_specific_data   = &amp;amp;p_manuf_specific_data;

    new_data.name_type               = BLE_ADVDATA_SHORT_NAME;
    new_data.short_name_len          = 5;
    new_data.include_appearance      = false;
    new_data.flags                   = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE;
    new_data.uuids_complete.uuid_cnt = 0;
    new_data.uuids_complete.p_uuids  = m_adv_uuids;

    //SDK16.x.x implementation will handle all buffering and encoding inside the update function
    err_code = ble_advertising_advdata_update(&amp;amp;m_advertising, &amp;amp;new_data, NULL);  
    APP_ERROR_CHECK(err_code);

}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Callback function and update function.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;void nrf_cal_set_callback(void (*callback)(void), uint32_t interval)
{
    // Set the calendar callback, and set the callback interval in seconds
    cal_event_callback = callback;
    m_rtc_increment = interval;
    m_time += CAL_RTC-&amp;gt;COUNTER / 8;
    CAL_RTC-&amp;gt;TASKS_CLEAR = 1;
    CAL_RTC-&amp;gt;CC[0] = interval * 8;  
    
    advertising_update_mfg_data(); // update function
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Is there any other way to update this manufacturer data every 1 sec?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>