Time Date set from BLE nrf52

Hi 

I set the time and date from cfs 

the received package is valid. the timestamp is transfer to the set method correctly. the output shows also that the system time is set correct. 

The invalid TZ doesn't matter with my config like 
NRF52840 date time example

            struct tm ble_time;
			ble_time.tm_hour=  current_time->exact_time_256.hours;
			ble_time.tm_min =  current_time->exact_time_256.minutes;
			ble_time.tm_sec =  current_time->exact_time_256.seconds;
			ble_time.tm_mday =  current_time->exact_time_256.day;
			ble_time.tm_mon = current_time->exact_time_256.month -1 ;
			ble_time.tm_year = current_time->exact_time_256.year - 1900; //time since 1990
			ble_time.tm_isdst = 0; // Assume no DST
			//TODO: reasons mapping to internal time!
		    date_time_set(&ble_time); 	
	
			char buffer[80];

    		// Format the date into the buffer
    		strftime(buffer, sizeof(buffer), "%Y-%m-%d %H:%M:%S", &ble_time);
    		// Output the formatted date string
    		LOG_INF("Update date/time: %s\n", buffer);


	        int previous_time = k_uptime_get_32();
	        LOG_INF("Time received from %u\n", date_time_uptime_to_unix_time_ms(&previous_time));
	        int64_t time = 0;
            date_time_now(&time);
	        LOG_INF("Time received now %u\n", time);

//time from CFS
[00:00:13.825,866] <dbg> date_time: date_time_core_schedule_update: New periodic date time update in: 14400 seconds
[00:00:13.839,538] <dbg> date_time: date_time_core_store_tz: System time updated: 2024-08-09 14:11:57+99
//print time tm which i set
[00:00:13.852,294] <inf> ble_p: Update date/time: 2024-08-09 14:11:57

//wired 
[00:00:13.862,274] <wrn> date_time: Uptime too large or previously converted
[00:00:13.872,711] <wrn> date_time: Clear variable or set a new uptime
[00:00:13.882,476] <inf> ble_p: Time received from 4294967274

[00:00:13.891,723] <inf> ble_p: Time received now 4294967274

Currently i have a workaround with get the uptime and use this for offset to the sync time and than always when i need the time add the current uptime. 
For time considering methods i just  uptime!

Parents
  • Not sure if I understand this right.

    So the peer which is a CTS server is sending time in large number? Is this expected or is it just that the peer system has been up for a long time?

    I am not sure what we can do to change the peer value as it looks like we can only read the time from the server. So the workaround you have to use the offset you get the first time to calculate a meaningful time later on based on this offset seems reasonable. 

Reply
  • Not sure if I understand this right.

    So the peer which is a CTS server is sending time in large number? Is this expected or is it just that the peer system has been up for a long time?

    I am not sure what we can do to change the peer value as it looks like we can only read the time from the server. So the workaround you have to use the offset you get the first time to calculate a meaningful time later on based on this offset seems reasonable. 

Children
Related