<?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>Problem with nrf5_calendar example</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/93096/problem-with-nrf5_calendar-example</link><description>Dear, 
 I have integrated the nrf5_calendar example with &amp;quot;usbd_ble_uart&amp;quot; . Everything works correctly, but I have detected two possible errors (or I am doing something wrong): 
 ERROR 1: problem with the configured year. I can solve this by changing 1900</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 20 Oct 2022 09:12:09 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/93096/problem-with-nrf5_calendar-example" /><item><title>RE: Problem with nrf5_calendar example</title><link>https://devzone.nordicsemi.com/thread/391790?ContentTypeID=1</link><pubDate>Thu, 20 Oct 2022 09:12:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:72281e13-f164-4002-ad89-82b20224cd50</guid><dc:creator>rqLST</dc:creator><description>&lt;p&gt;Thank you very much for your help.&lt;/p&gt;
&lt;p&gt;I&amp;#39;m going to close this ticket.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem with nrf5_calendar example</title><link>https://devzone.nordicsemi.com/thread/391789?ContentTypeID=1</link><pubDate>Thu, 20 Oct 2022 09:09:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:48e8899c-bd75-4a99-82aa-6b3142fe61bb</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;that seems about right.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem with nrf5_calendar example</title><link>https://devzone.nordicsemi.com/thread/391788?ContentTypeID=1</link><pubDate>Wed, 19 Oct 2022 12:12:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:346209ca-5740-4614-a8d7-d4b62b47a1bf</guid><dc:creator>rqLST</dc:creator><description>&lt;p&gt;So the month setting has to be taking into account January = 0 and December = 11, however, the function &lt;strong&gt;nrf_cal_get_time_string(false)&lt;/strong&gt; does return the correct value (January = 1, December = 12).&lt;br /&gt;My tests make me think that this is the case.&amp;nbsp;&lt;span style="font-family:inherit;"&gt;Can you confirm this?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:inherit;"&gt;TEST:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;I want to set &lt;strong&gt;mm/dd/yyyy = 12/12/2022&lt;/strong&gt; and &lt;strong&gt;hh:mm:ss = 23:59:55&lt;/strong&gt;. Taking into account that month = 0 means January and month = 11 means December, I configure by USB the following:&lt;/p&gt;
&lt;p&gt;[INFO]: &lt;strong&gt;11/12/2022, 23:59:55&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1666181434270v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;After 5 seconds the day, month and year must be changed.&amp;nbsp; You can see that January is shown as 01 (and not as 00):&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1666181487866v2.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;Thank you.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem with nrf5_calendar example</title><link>https://devzone.nordicsemi.com/thread/391787?ContentTypeID=1</link><pubDate>Wed, 19 Oct 2022 10:35:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7181836b-b93a-45fd-88b0-7bd8f7d41ae4</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Please note that this is not an official example from Nordic. It was a project used in a demo at some point, and uploaded to the Nordic Playground for convenience, in case anyone needed something similar.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The confusion regarding the month is just because you believe that the months go from 1 to 12, but they go from 0 to 11. As it says &amp;quot;months since january&amp;quot;. Try inserting a date in december, and you should see that it is not possible to use month number 12.&lt;/p&gt;
&lt;p&gt;I do agree that it is a bit confusing, but when you enter the month 10 over UART, it is not october, it is november. If this confuses you, you need to either adjust how the time is printed (add 1 to the month) or change the way that the month is input (add one).&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem with nrf5_calendar example</title><link>https://devzone.nordicsemi.com/thread/391786?ContentTypeID=1</link><pubDate>Wed, 19 Oct 2022 06:28:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7ee4776c-2e5e-4bec-8c49-bd542eb8e5c0</guid><dc:creator>rqLST</dc:creator><description>&lt;p&gt;Hi Edvin,&lt;/p&gt;
&lt;p&gt;Thank you for your answer.&lt;br /&gt;I have not been very clear with the problems I am having. I will try to explain better below:&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;I send the year,month,day,second,minute and hour values via USB (I use TeraTerm) and via Bluetooth (with the nRF Toolbax mobile app). In both cases I capture and store the data correctly (see following image):&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1666159703498v2.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;When I apply the values to &lt;strong&gt;time_struct&lt;/strong&gt; using&lt;strong&gt; nrf_cal_set_time(...)&lt;/strong&gt; it also seems to work correctly (see following image):&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1666159731406v3.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;However, when I try to query the configured values by calling the function &amp;quot;&lt;strong&gt;nrf_cal_get_time_string(false)&lt;/strong&gt;&amp;quot; the values are not the correct ones (See following image):&lt;br /&gt;Note: I also tried with &lt;strong&gt;nrf_cal_get_time_string(true)&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1666159818881v4.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;The value of &amp;quot;month&amp;quot; is not correct.&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1666159839647v5.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1666159845298v6.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;I attach below the code where I capture and process this data:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static void cdc_acm_user_ev_handler(app_usbd_class_inst_t const *p_inst,
    app_usbd_cdc_acm_user_event_t event) 
{
 [...]
 case APP_USBD_CDC_ACM_USER_EVT_RX_DONE: {
    ret_code_t ret;
    static uint8_t index = 0;
    index++;
    
      if((startAccsample == true)){
          memcpy(arrayUsb, &amp;quot;\r\nSTOP DATALOGGER\r\n&amp;quot;, sizeof(arrayUsb));
          writeToUsb();
          app_timer_stop(acc_timer_id);
          startAccsample = false;
      }

    do {

      if ((m_cdc_data_array[index - 1] == &amp;#39;\n&amp;#39;) ||(m_cdc_data_array[index - 1] == &amp;#39;\r&amp;#39;)) 
      {
        if (index &amp;gt; 1) {
              memcpy(usb_rx_data, m_cdc_data_array, sizeof(m_cdc_data_array));
        }

         eventUsbDetected = eventUsbRx();
         EvaluateUsbOption(eventUsbDetected);

        index = 0;
         memcpy(usb_rx_data,0,sizeof(usb_rx_data));
         memcpy(m_cdc_data_array,0,sizeof(m_cdc_data_array));
      }
 [...]
 
 }
 
 }&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;void currentTime() {

  char *time_string;
  uint16_t length;

  time_string = nrf_cal_get_time_string(false);
  length = strlen(time_string);

  #if (CONFIG_USB == 0)
  uint32_t err_code = ble_nus_data_send(&amp;amp;m_nus, time_string, &amp;amp;length, m_conn_handle);
  APP_ERROR_CHECK(err_code);
  #else
  sprintf(time_string,&amp;quot;%s\r\n&amp;quot;,time_string);
  memcpy(arrayUsb, time_string, sizeof(arrayUsb));
  writeToUsb();
  #endif
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;void configTimeRx(void){


  #if(CONFIG_USB == 0)
  hour = atol(ble_rx_data);       // 1 - 24
  minute = atol(ble_rx_data + 3); // 0 - 59
  second = atol(ble_rx_data + 6); // 0 - 59
  day = atol(ble_rx_data + 9);    // 1 - 31
  month = atol(ble_rx_data + 12); // 0 - 11
  year = atol(ble_rx_data + 15);  // 1900
  #else
  hour = atol(usb_rx_data);       // 1 - 24
  minute = atol(usb_rx_data + 3); // 0 - 59
  second = atol(usb_rx_data + 6); // 0 - 59
  day = atol(usb_rx_data + 9);    // 1 - 31
  month = atol(usb_rx_data + 12); // 0 - 11
  year = atol(usb_rx_data + 15);  // 1900
  #endif

  nrf_cal_set_time(year, month, day, hour, minute, second);


  SEGGER_RTT_printf(0, &amp;quot;\r\nTime set: &amp;quot;);
  SEGGER_RTT_printf(0, &amp;quot;\r\n%s&amp;quot;, nrf_cal_get_time_string(false));
  SEGGER_RTT_printf(0, &amp;quot;\r\n\n&amp;quot;);

  currentTime(); //tx time

  memset(ble_rx_data, 0, 26);

  update_time = false;
  data_rx_time = false;
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;--------------------------------------------------------------&lt;/p&gt;
&lt;p&gt;I have observed that I am not working with the same version of the library that you propose. Please note the definition of my &amp;quot;struct tm&amp;quot;:&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1666160477303v7.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;I am working with &amp;quot;SEGGER Embedded Studio for ARM 5.50d&amp;quot;.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/time.h"&gt;devzone.nordicsemi.com/.../time.h&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;------------------------------------&lt;/p&gt;
&lt;p&gt;On the other hand:&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;The first capture I attached in ERROR 1 was made with &lt;strong&gt;time_struct.tm_year = year - 1900&lt;/strong&gt;;&lt;br /&gt;But the second capture was made with &lt;strong&gt;time_struct.tm_year = year - 2000&lt;/strong&gt;;&lt;br /&gt;However, this problem was solved by removing the following part in &lt;strong&gt;the nrf_cal_set_time(...)&lt;/strong&gt; function (I read this proposal from some NORDIC colleague).&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1666160734016v8.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;-----------------------------&lt;/p&gt;
&lt;p&gt;This is the example of nrf5_calendar I am working with:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/nrf5_2D00_calendar_2D00_example_2D00_master.zip"&gt;devzone.nordicsemi.com/.../nrf5_2D00_calendar_2D00_example_2D00_master.zip&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thank you for your help,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Raquel.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem with nrf5_calendar example</title><link>https://devzone.nordicsemi.com/thread/391785?ContentTypeID=1</link><pubDate>Mon, 17 Oct 2022 12:16:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d30e3d85-6363-46d1-89e8-9d12fa31f5aa</guid><dc:creator>Edvin</dc:creator><description>[quote user=""]&lt;p&gt;&lt;span&gt;ERROR 1: problem with the configured year. I can solve this by changing 1900 to 2000, but I don&amp;#39;t know if it will affect another time.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;[/quote]
&lt;p&gt;I don&amp;#39;t think you should do that. The reason is that the&amp;nbsp;&lt;strong&gt;external&lt;/strong&gt; time library expects to get the &amp;quot;year&amp;quot; parameter given as years after 1900. Please look up the &amp;quot;struct tm&amp;quot; in time.h.&lt;/p&gt;
&lt;p&gt;What sort of problem did you see? (your screenshot shows 1900 as being used), by the way.)&lt;/p&gt;
[quote user=""]&lt;p&gt;&lt;span&gt;ERROR 2: The function &amp;quot;nrf_cal_get_time_string&amp;quot; adds +1 to the configured month value (I have tried with different configurations and it always happens).&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;[/quote]
&lt;p&gt;This is also something that is decided by the&amp;nbsp;&lt;strong&gt;external&lt;/strong&gt; library. Please have a look at the struct (from time.h) :&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;struct tm {
    int tm_sec;   /* seconds after the minute, 0 to 60
                     (0 - 60 allows for the occasional leap second) */
    int tm_min;   /* minutes after the hour, 0 to 59 */
    int tm_hour;  /* hours since midnight, 0 to 23 */
    int tm_mday;  /* day of the month, 1 to 31 */
    int tm_mon;   /* months since January, 0 to 11 */
    int tm_year;  /* years since 1900 */
    int tm_wday;  /* days since Sunday, 0 to 6 */
    int tm_yday;  /* days since January 1, 0 to 365 */
    int tm_isdst; /* Daylight Savings Time flag */
    union {       /* ABI-required extra fields, in a variety of types */
        struct {
            int __extra_1, __extra_2;
        };
        struct {
            long __extra_1_long, __extra_2_long;
        };
        struct {
            char *__extra_1_cptr, *__extra_2_cptr;
        };
        struct {
            void *__extra_1_vptr, *__extra_2_vptr;
        };
    };
};
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>