When legato system starts default date is Jan 1. 1970. and I would like the date to be set to some other before my application starts.
I know I can set time trough my application by using “le_rtc_interface.h” API, but because I’m running my app in couple of processes I’d like the time to be already set inbefore they are started.
If I understood correctly, you are suggesting to make an app which will set the date/time as I wish and then start my app afterwards. That can work, only downside is having 2 apps instead of 1, is there any other way?
I was looking in a way of AT commands but couldn’t find any or maybe editing some files in SierraWireless system?
This application has to be unsandboxed in order to be able to change the time of the system, am I correct? There is no way of changing the time from a sandboxed application?
// NEW_EPOCH_TIME_IN_MS is 2019. 1. 1. 00:00:00:000
#define NEW_EPOCH_TIME_IN_MS 1546300800000
COMPONENT_INIT
{
const uint64_t newTime = 1546300800000;
uint64_t msPastEpochPtr = 0;
LE_INFO("Getting absolute time");
le_clk_Time_t timeNow = le_clk_GetAbsoluteTime();
LE_INFO("The time obtained is: %ld", timeNow.usec);
le_clk_Time_t newTm;
if((uint64_t)(timeNow.usec) < (newTime)){
LE_INFO("Date is sooner than 2019. 1. 1. it is going to be updated!");
newTm.usec = newTime;
le_clk_SetAbsoluteTime(newTm);
}else LE_INFO("Readtime: %lld isn't less than %ld", msPastEpochPtr, newTm.usec);
timeNow = le_clk_GetAbsoluteTime();
LE_INFO("The time obtained is: %lld", (uint64_t)timeNow.usec);
}
From the log (I shortened it a bit to be easier to see):
Jan 1 00:31:16 swi-mdm9x28-wp user.info Legato: Getting absolute time
Jan 1 00:31:16 swi-mdm9x28-wp user.info Legato: The time obtained is: 326873
Jan 1 00:31:16 swi-mdm9x28-wp user.info Legato: Time is less than the 2019. 1. 1. it is going to be updated.
Jan 1 00:31:16 swi-mdm9x28-wp user.err Legato: =ERR= | timetestapp[8169]/framework T=main | LE_FILENAME le_clk_SetAbsoluteTime() 597 | Setting CLOCK_REALTIME for Absolute time is not permitted
Jan 1 00:31:16 swi-mdm9x28-wp user.info Legato: The time obtained is: 327150
Question was:
application has to be unsandboxed in order to be able to change the time of the system, am I correct?