<?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>NTP Date/Time from nrfConnect v1.2.1</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/110406/ntp-date-time-from-nrfconnect-v1-2-1</link><description>For reasons beyond my control I need to do some changes to a nrf9160 project that was developed using nrfConnect v1.2.1. I know the ideal situation is to upgrade it to the latest version, but it uses several deprecated config options that would require</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 26 Apr 2024 13:16:01 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/110406/ntp-date-time-from-nrfconnect-v1-2-1" /><item><title>RE: NTP Date/Time from nrfConnect v1.2.1</title><link>https://devzone.nordicsemi.com/thread/480900?ContentTypeID=1</link><pubDate>Fri, 26 Apr 2024 13:16:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:433c2d28-fa43-4e90-ad16-77b80ef08c9a</guid><dc:creator>dave</dc:creator><description>&lt;p&gt;Thanks for all of your help. You are correct, certifications are keeping us from changing versions&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NTP Date/Time from nrfConnect v1.2.1</title><link>https://devzone.nordicsemi.com/thread/480810?ContentTypeID=1</link><pubDate>Fri, 26 Apr 2024 07:22:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0e0aa04b-cb22-42d5-aeca-34eace992240</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi Dave,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The v1.2.x version had a bug, where it did not take in the size of the string. This was later introduced with this commit:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/nrfconnect/sdk-nrf/commit/92c95b2dda7a47542268162f2b81eef8f7db1325"&gt;https://github.com/nrfconnect/sdk-nrf/commit/92c95b2dda7a47542268162f2b81eef8f7db1325&lt;/a&gt;&lt;/p&gt;
[quote user="dave_s"]What happens if the buffer isn&amp;#39;t large enough?[/quote]
&lt;p&gt;Buffer overflow.&lt;/p&gt;
&lt;p&gt;You should set this to the same define/len as being tested against in the function itself (ie: MODEM_INFO_MAX_RESPONSE_SIZE):&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/nrfconnect/sdk-nrf/blob/v1.2.1/lib/modem_info/modem_info.c#L478C23-L478C51"&gt;https://github.com/nrfconnect/sdk-nrf/blob/v1.2.1/lib/modem_info/modem_info.c#L478C23-L478C51&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;As previously mentioned; It is highly recommended that you update to a newer version, but if there&amp;#39;s certifications involved in the current product; I understand why you don&amp;#39;t want to.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NTP Date/Time from nrfConnect v1.2.1</title><link>https://devzone.nordicsemi.com/thread/480753?ContentTypeID=1</link><pubDate>Thu, 25 Apr 2024 15:33:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:173bd55e-d46d-4794-9b79-5acf8f0fac59</guid><dc:creator>dave</dc:creator><description>&lt;p&gt;Is the response from&amp;nbsp;&amp;nbsp;modem_info_string_get a fixed size?&lt;br /&gt;&lt;br /&gt;A buffer is provided to the function but the size is not sent.&amp;nbsp; What happens if the buffer isn&amp;#39;t large enough?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NTP Date/Time from nrfConnect v1.2.1</title><link>https://devzone.nordicsemi.com/thread/480495?ContentTypeID=1</link><pubDate>Wed, 24 Apr 2024 14:11:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:be1095b2-aaa9-4cf6-9605-66f254368e9f</guid><dc:creator>dave</dc:creator><description>&lt;p&gt;Thanks for your responses.&lt;br /&gt;&lt;br /&gt;I had originally intended to use NTP but after finding out the nrfConnect version I was using is too old to have it already integrated with the DateTime module it looked like it would be simpler and easier to get the modem time.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NTP Date/Time from nrfConnect v1.2.1</title><link>https://devzone.nordicsemi.com/thread/480372?ContentTypeID=1</link><pubDate>Wed, 24 Apr 2024 08:46:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3a15fd24-daef-4ad9-a483-b73b2e49cf38</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The network provides this time, but there&amp;#39;s a catch, as described in this thread:&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/78608/nrf9160-at-cclk-response-time-does-not-take-into-account-the-time-zone-difference/393125"&gt;RE: nRF9160 AT+CCLK response time does not take into account the time zone difference&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The implementation depends on the network configuration, thus you can handle this in two different ways. Have you considered fetching via ntp or XTIME to better work around this?&lt;/p&gt;
[quote user="dave_s"]One additional question, for the function modem_info_string_get, it says a negative error code is returned if it isn&amp;#39;t successful.&amp;nbsp; Where are the error codes documented?[/quote]
&lt;p&gt;It will return based on errno.h definitions.&lt;/p&gt;
&lt;p&gt;errno.h values is based on which libc that you use, normally it is newlib-nano:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/eblot/newlib/blob/master/newlib/libc/include/sys/errno.h"&gt;https://github.com/eblot/newlib/blob/master/newlib/libc/include/sys/errno.h&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NTP Date/Time from nrfConnect v1.2.1</title><link>https://devzone.nordicsemi.com/thread/480247?ContentTypeID=1</link><pubDate>Tue, 23 Apr 2024 14:21:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6f3ddd13-f425-4271-8631-5318d2d418ea</guid><dc:creator>dave</dc:creator><description>&lt;p&gt;Thanks&lt;br /&gt;&lt;br /&gt;That makes a bit more sense on time format if the timezone is in quarter of an hour.&lt;br /&gt;&lt;br /&gt;But &lt;strong&gt;it looks like the date / time portion is UTC and doesn&amp;#39;t have the timezone offset applied?&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;For example, last night I received the following response&lt;br /&gt;&lt;br /&gt;24/04/23,01:48:50-20&lt;br /&gt;&lt;br /&gt;I am in US central DST, so the -20 offset makes sense.&amp;nbsp; But it shows 1:48 am on April 23 2024.&amp;nbsp; I read the time at 8:48 pm April 22 local time&lt;br /&gt;&lt;br /&gt;One additional question, for the function modem_info_string_get, it says a negative error code is returned if it isn&amp;#39;t successful.&amp;nbsp; Where are the error codes documented?&lt;br /&gt;&lt;br /&gt;When does the modem time get updated?&lt;br /&gt;Can I programmatically tell it to update if the return value is negative?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NTP Date/Time from nrfConnect v1.2.1</title><link>https://devzone.nordicsemi.com/thread/480187?ContentTypeID=1</link><pubDate>Tue, 23 Apr 2024 11:50:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cda2ee20-3c95-452f-ac01-10773a60b543</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;That is the format of CCLK:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://infocenter.nordicsemi.com/topic/ref_at_commands/REF/at_commands/mob_termination_ctrl_status/cclkl_set.html?cp=2_2_0_4_22_0"&gt;https://infocenter.nordicsemi.com/topic/ref_at_commands/REF/at_commands/mob_termination_ctrl_status/cclkl_set.html?cp=2_2_0_4_22_0&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;You can use scanf to convert it into&amp;nbsp;struct tm:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/nrfconnect/sdk-nrf/blob/v2.6.0/lib/date_time/date_time_modem.c#L53-L65"&gt;https://github.com/nrfconnect/sdk-nrf/blob/v2.6.0/lib/date_time/date_time_modem.c#L53-L65&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NTP Date/Time from nrfConnect v1.2.1</title><link>https://devzone.nordicsemi.com/thread/480043?ContentTypeID=1</link><pubDate>Mon, 22 Apr 2024 15:19:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:173dbd2d-864e-4953-9f48-1d10ee365c93</guid><dc:creator>dave</dc:creator><description>&lt;p&gt;&lt;span&gt;Q1: What modem fw version are you using?&amp;nbsp;&lt;/span&gt;mfw_nrf9160_1.1.2&lt;br /&gt;&lt;span&gt;Q2: How are you implementing the routine to fetch MODEM_INFO_DATE_TIME? Can you share this?&amp;nbsp;&amp;nbsp;&lt;br /&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;    char sbuf[30];

    size = modem_info_string_get(MODEM_INFO_DATE_TIME, sbuf);&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;The string being returned is like this&lt;br /&gt;&lt;br /&gt;24/04/22,15:18:34-20&lt;br /&gt;&lt;br /&gt;which doesn&amp;#39;t seem to match a standard format&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NTP Date/Time from nrfConnect v1.2.1</title><link>https://devzone.nordicsemi.com/thread/479914?ContentTypeID=1</link><pubDate>Mon, 22 Apr 2024 09:05:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:adfd9c70-0306-44f8-9c2f-a06ab7937455</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The specific modem_info call will effectively call AT+CCLK, which should return a string similar to this:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fref_at_commands%2FREF%2Fat_commands%2Fnw_service%2Fxtime_set.html&amp;amp;cp=2_2_0_7_8_0"&gt;https://infocenter.nordicsemi.com/index.jsp?topic=%2Fref_at_commands%2FREF%2Fat_commands%2Fnw_service%2Fxtime_set.html&amp;amp;cp=2_2_0_7_8_0&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Q1: What modem fw version are you using?&lt;/p&gt;
&lt;p&gt;Q2: How are you implementing the routine to fetch MODEM_INFO_DATE_TIME? Can you share this?&lt;/p&gt;
[quote user="dave_s"]Is there way to retrieve the modem time in seconds since epoch?&amp;nbsp; Or do I need to parse the string to get the UTC date/time?[/quote]
&lt;p&gt;You will need to add a routine for it, similar to this:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/nrfconnect/sdk-nrf/blob/v2.6.0/lib/date_time/date_time_modem.c#L109"&gt;https://github.com/nrfconnect/sdk-nrf/blob/v2.6.0/lib/date_time/date_time_modem.c#L109&lt;/a&gt;&lt;/p&gt;
[quote user="dave_s"]Is the format and string length always the same regardless of the date / time?[/quote]
&lt;p&gt;string length returned is \0 terminated, length will vary&lt;/p&gt;
[quote user="dave_s"]How / when does the modem time get updated?&amp;nbsp; Is there a way to know how recently updated it is?[/quote]
&lt;p&gt;If the network supports and provides time, it is sent as a part of the EPS MM (EMM) PDU, as described here:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://infocenter.nordicsemi.com/topic/ref_at_commands/REF/at_commands/nw_service/xtime_set.html?cp=2_2_0_7_8_0"&gt;https://infocenter.nordicsemi.com/topic/ref_at_commands/REF/at_commands/nw_service/xtime_set.html?cp=2_2_0_7_8_0&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NTP Date/Time from nrfConnect v1.2.1</title><link>https://devzone.nordicsemi.com/thread/479782?ContentTypeID=1</link><pubDate>Fri, 19 Apr 2024 18:56:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e4efdd77-410a-4549-b025-2ed6afc33075</guid><dc:creator>dave</dc:creator><description>&lt;p&gt;Hi,&lt;br /&gt;&lt;br /&gt;I changed my approach to get the time from the modem using&amp;nbsp;&lt;span class="enlighter-m0"&gt;modem_info_string_get with&amp;nbsp;&lt;/span&gt;&lt;span class="enlighter-text"&gt;MODEM_INFO_DATE_TIME&lt;br /&gt;&lt;br /&gt;Here is the response I get&lt;br /&gt;&lt;br /&gt;24/04/19,18:50:33-20dy&lt;br /&gt;&lt;br /&gt;What is the &amp;#39;-20dy&amp;#39; portion represent?&lt;br /&gt;&lt;br /&gt;Is there way to retrieve the modem time in seconds since epoch?&amp;nbsp; Or do I need to parse the string to get the UTC date/time?&lt;br /&gt;&lt;br /&gt;Is the format and string length always the same regardless of the date / time?&lt;br /&gt;&lt;br /&gt;How / when does the modem time get updated?&amp;nbsp; Is there a way to know how recently updated it is?&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NTP Date/Time from nrfConnect v1.2.1</title><link>https://devzone.nordicsemi.com/thread/479755?ContentTypeID=1</link><pubDate>Fri, 19 Apr 2024 14:35:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:59f2d129-d0ef-4151-a427-d9fc25785bd2</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Although I would recommend that you upgrade your project, you could cherry-pick the initial commit for the date_time library:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/nrfconnect/sdk-nrf/commit/1e6e3e3530be53f5a61794fbc30c6c7f58f6f4d3"&gt;https://github.com/nrfconnect/sdk-nrf/commit/1e6e3e3530be53f5a61794fbc30c6c7f58f6f4d3&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The current time can also be queried via AT%XTIME (if your connected network provides time):&lt;/p&gt;
&lt;p&gt;&lt;a href="https://infocenter.nordicsemi.com/topic/ref_at_commands/REF/at_commands/nw_service/xtime_set.html?cp=2_2_0_7_8_0"&gt;https://infocenter.nordicsemi.com/topic/ref_at_commands/REF/at_commands/nw_service/xtime_set.html?cp=2_2_0_7_8_0&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;See this function for how to translate it:&amp;nbsp;&lt;a href="https://github.com/nrfconnect/sdk-nrf/blob/v2.6.0/lib/date_time/date_time_modem.c#L109"&gt;https://github.com/nrfconnect/sdk-nrf/blob/v2.6.0/lib/date_time/date_time_modem.c#L109&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>