Dear Nordic Support Team,
After I updated the nRF Connect SDK (1.4.0 to 1.5.1) and the Modem firmware (1.2.2 to 1.2.3) on my nrf9160 DK devices, the date time isn't synchronized anymore.
After the modem successfully connects to the LTE network (lte_lc_psm_req(.) and lte_lc_init_and_connect() return 0), I initiate the date time synchronization with date_time_update_async(). I wait until date_time_is_valid() returns true. This however never happens and printing the current system time obviously shows wrong results. Please note that I used the same application code before and after the SDK and Modem firmware update (except for the new date_time_is_valid() function). Before the update, the date time synchronization was not an issue.
I flashed the Asset Tracker v2 sample onto one of my devices to tackle the problem. The sample failed and issued a reboot on the first run. In the second run, the sample worked properly and the data sent to the nRF Connect Cloud had a correct time stamp. Thereafter I again flashed my application code to the very same device on which I had the Asset Tracker v2 running. Surprisingly, now the date time synchronization was working on that device. I have a second device on which the date time synchronization still fails. I never had the Asset Tracker v2 sample running on this second device.
I would like to understand what causes this behavior and how I can get my devices to synchronize their system time again without utilizing the Asset-Tracker-v2-workaround.
Thank you very much for you help!
PS: You find my prj.conf attached.
EDIT: updated prj.conf, added dateTimeError.log, added minimalExample.c
*** Booting Zephyr OS build v2.4.99-ncs2 *** I am running! Init modem lte_lc_psm_req returned: 0 lte_lc_init_and_connect returned: 0 Fetch date time d[00:00:13.057,067] <wrn> date_time: getaddrinfo, error: -11 a[00:00:13.063,476] <wrn> date_time: getaddrinfo, error: -11 te[00:00:13.070,037] <wrn> date_time: getaddrinfo, error: -11 _[00:00:13.076,477] <wrn> date_time: getaddrinfo, error: -11 tim[00:00:13.083,068] <wrn> date_time: getaddrinfo, error: -11 [00:00:13.089,294] <wrn> date_time: Not getting time from any NTP server e_update_async returned: 0 *** Booting Zephyr OS build v2.4.99-ncs2 *** I am running! Init modem lte_lc_psm_req returned: 0 lte_lc_init_and_connect returned: 0 Fetch date time d[00:00:11.937,042] <wrn> date_time: getaddrinfo, error: -11 a[00:00:11.943,481] <wrn> date_time: getaddrinfo, error: -11 te[00:00:11.950,042] <wrn> date_time: getaddrinfo, error: -11 _[00:00:11.956,451] <wrn> date_time: getaddrinfo, error: -11 tim[00:00:11.963,043] <wrn> date_time: getaddrinfo, error: -11 [00:00:11.969,299] <wrn> date_time: Not getting time from any NTP server e_update_async returned: 0
// Zephyr #include <zephyr.h> // Nordic #include <date_time.h> #include <modem/lte_lc.h> // Local #include "Hardware/lmWatchdog.h" // Macro //============================================================================= //============================================================================= // Declaration //============================================================================= //============================================================================= // Interface //============================================================================= /** * @brief Directly called in main.c */ void lmControlProtoApp_initialize(void) { int error = 0; printk("Init modem\n"); error = lte_lc_psm_req(true); printk("\tlte_lc_psm_req returned: %d\n", error); error = lte_lc_init_and_connect(); printk("\tlte_lc_init_and_connect returned: %d\n", error); printk("Fetch date time\n"); error = date_time_update_async(NULL); printk("\tdate_time_update_async returned: %d\n", error); LmWatchdog watchdog; lmWatchdog_initialize(&watchdog, 1000*10); lmWatchdog_start(&watchdog); while (!date_time_is_valid()) { k_msleep(1000); } lmWatchdog_stop(&watchdog); printk("Init done\n"); } /** * @brief Directly called in main.c after initialize is complete */ void lmControlProtoApp_run(void) { int64_t unixStamp; while (true) { date_time_now(&unixStamp); printk("unix time stamp: &lld\n", unixStamp); k_msleep(1000*5); } } //============================================================================= // Definition //============================================================================= //=============================================================================