Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set system time so LittleFS can take over the real time #161

Open
Andreotti100 opened this issue Jul 4, 2021 · 0 comments
Open

Set system time so LittleFS can take over the real time #161

Andreotti100 opened this issue Jul 4, 2021 · 0 comments

Comments

@Andreotti100
Copy link

Andreotti100 commented Jul 4, 2021

Using this library resulted in wrong file time stamps, 1970 style.
So, I made a change:

#include <coredecls.h> // Needed for setting the right system time

void setTime(time_t t) {
#ifdef TIME_DRIFT_INFO
if(sysUnsyncedTime == 0)
sysUnsyncedTime = t; // store the time of the first call to set a valid Time
#endif

sysTime = (uint32_t)t;
nextSyncTime = (uint32_t)t + syncInterval;
Status = timeSet;
prevMillis = millis(); // restart counting from now (thanks to Korman for this fix)
tune_timeshift64((uint64_t)sysTime * 1000000ULL); // Take over the new time into the system time
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant