This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Date time issue with nrf9160 using SDK 1.4.2

Hi,

I am trying to get the time and UNIX time after LTE connected. but getting 0 only.

please log

2021-06-04T18:02:33.896Z DEBUG modem << Date time 1: 0000000000000000
2021-06-04T18:02:33.904Z DEBUG modem << Date time unix: 0000000000000000
2021-06-04T18:02:34.900Z DEBUG modem << [00:03:23.441,711] [1;33m<wrn> date_time: Valid time not currently available[0m
2021-06-04T18:02:34.909Z DEBUG modem << [00:03:23.441,711] [1;33m<wrn> date_time: date_time_uptime_to_unix_time_ms, error: -78[0m
2021-06-04T18:02:34.916Z DEBUG modem << [00:03:23.444,427] [1;33m<wrn> date_time: Valid time not currently available[0m
2021-06-04T18:02:59.000Z DEBUG modem << Date time 1: 0000000000000000
2021-06-04T18:02:59.009Z DEBUG modem << Date time unix: 0000000000000000
2021-06-04T18:02:59.010Z DEBUG modem << Date time 2: 0000000000000000

date_time_update() function does not support in SDK 1.4.2 so I used date_time_now() and this keep giving me zero value for time.

please check the below code for your reference

	while (1) {
                  k_sleep(100);
                  while (!lte_connected) 
                    {
                    printk("Not connected, let's wait for lte_lc\n");
                    k_sleep(K_MSEC(1000));   
                    }
                            k_sleep(K_MSEC(25000));
                            int err1 = date_time_now(&unix_time_ms);
                            printk("Date time 1: %016llX\n", unix_time_ms);
                            date_time_uptime_to_unix_time_ms(&unix_time_ms);
                            printk("Date time unix: %016llX\n", unix_time_ms);

                    char str[10];

                   
                  while(recieved_first_packet != true)
                     {
                /*Force the date_time library to get current time */
               // date_time_update();  showing error in SDK 1.4.2
                
               
                /*Read current time and put in container */
                err1 = date_time_now(&unix_time_ms);

                //display the time

                printk("Date time 2: %016llX\n", unix_time_ms);

Thanks you in Advance.

Rahul

Related