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

Provide millisToEpoch and isSynced functions #136

Open
hgrecco opened this issue Apr 4, 2021 · 2 comments
Open

Provide millisToEpoch and isSynced functions #136

hgrecco opened this issue Apr 4, 2021 · 2 comments
Labels
type: enhancement Proposed improvement

Comments

@hgrecco
Copy link

hgrecco commented Apr 4, 2021

There is a feature that I need in multiple projects and I wonder if there is any interest to have it upstream. Briefly, I use arduino (and similar devices) to acquire data at 1 Hz from sensors and then upload it to a server. It is not uncommon that that due to the location of the sensor WiFi is not available from the very beginning and therfore the data is stored in a buffer. As soon as WiFi is available I start transmiting the buffer data to the server. But I need to make sure that the NTPClient has been synced first (that is why I need isSynced function). Currently I am either checking if the date is too old and/or _lastUpdate is zero. Then I have to convert the value of millis that I have stored in each record (insteado of the epoch) and convert it to Epoch. For this purpose I just do:

unsigned long millisToEpoch(unsigned long value) const {
  return this->_timeOffset + // User offset
         this->_currentEpoc + // Epoc returned by the NTP server
         ((value - this->_lastUpdate) / 1000); // Time since last update
}

In both cases I need to copy NTPClient as there all these members are private. Have you considered adding these functions or at least making these members protected so we can add this behaviour via subclassing.

@per1234
Copy link
Contributor

per1234 commented Apr 5, 2021

From a quick read of both, it seems related to #23

@per1234 per1234 added the type: enhancement Proposed improvement label Apr 5, 2021
@Anton-V-K
Copy link

I use the same scenario as the issue's author, so I'm wondering whether the library can already be used for the same purpose?

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

No branches or pull requests

3 participants