Update time (UTC) using LTE?

Hi,

I have been looking for some libraries to get current time (UTC) using LTE on the nrf9160. Are there any samples that uses that method? Which libraries do recommend? After receiving time, can you use the time.h library?  Can see that several samples uses GPS to get timestamps, but LTE fits my application better.

Parents
  • This works:

    void main(void)
    {
    	int err;
    	char response[513];
    	int rc;
    	
    	k_sleep(K_MSEC(2000)); //Just to get time to open LTE Link monitor.
    
    	printk("Activating LTE... \n");
    	err = lte_lc_init_and_connect(); //BLOCKS until connection.
    	if (err) {
    		printf("Failed to connect to the LTE network, err %d\n", err);
    		return;
    	}
    	printk("OK!\n");
    
    	k_busy_wait(1000000); //Don't know the optimal timestamp
    	rc = nrf_modem_at_scanf("AT+CCLK?", "+CCLK: %s", &response);
    	
    	printf("rc: %d\n", rc);
    	printf("Modem response: %s \n",response);
    
    	nrf_modem_lib_shutdown();
    	
    	printk("Turning off LTE\n");
    	lte_lc_power_off();
    
    
    	
    	printk("SHUTDOWN.\n");
    }
    Not optimized, but will extract the time from the modem in the response string when connected to the LTE network.
Reply
  • This works:

    void main(void)
    {
    	int err;
    	char response[513];
    	int rc;
    	
    	k_sleep(K_MSEC(2000)); //Just to get time to open LTE Link monitor.
    
    	printk("Activating LTE... \n");
    	err = lte_lc_init_and_connect(); //BLOCKS until connection.
    	if (err) {
    		printf("Failed to connect to the LTE network, err %d\n", err);
    		return;
    	}
    	printk("OK!\n");
    
    	k_busy_wait(1000000); //Don't know the optimal timestamp
    	rc = nrf_modem_at_scanf("AT+CCLK?", "+CCLK: %s", &response);
    	
    	printf("rc: %d\n", rc);
    	printf("Modem response: %s \n",response);
    
    	nrf_modem_lib_shutdown();
    	
    	printk("Turning off LTE\n");
    	lte_lc_power_off();
    
    
    	
    	printk("SHUTDOWN.\n");
    }
    Not optimized, but will extract the time from the modem in the response string when connected to the LTE network.
Children
No Data
Related