-
Notifications
You must be signed in to change notification settings - Fork 670
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
If syncProvder is set but does not return time, subsequent calls to now() should try to sync. #15
base: master
Are you sure you want to change the base?
Conversation
I do not want to interfere with the existing capability for the caller to recognize that the sync function has not set the time so an alternative sync source can be used if available. What are the disadvantages of adding the functionality you require in the sketch instead of in the library? |
The main issue is that Time does not provide any forced way to sync. At least not obviously from the API point of view. But of course a new call to setSyncProvider() or change the setSyncInterval to 0 would achieve that. Though I think it would be a bit strange to first setup Time and then change sync interval until I have seen it has synced. What I want to achieve is that I as soon as possible get a correct time and not something like 1970-ish. And my change does not remove the existing capability for the caller to recognise that sync has not set time. Status is still timeNotSet after now() was called and the caller can check status and decide to either call now() again to try to sync again(which existing code will not allow) or set an alternative sync source. But of course the alternative to achieve this same functionality is to call setSyncInterval(0) and then call now() and once status has changed to timeSet, call setSyncInterval(300). I guess it depends on how one looks at syncInterval, is that the exact interval at which the getTimeFunction will be called or is it the amount a time that will pass at least until getTimeFunction is called. |
Hi I have a similar problem. I'm not sure why, but sometimes the internal sync functionality of the library does not work at all. wayfarer |
wayfarerbasta, is the problem that the time source is not available when the system starts (which I believe is the issue raised by karl-petter. Or is the sync functionality intermittently not working? If the latter, can you say more about how to reproduce this problem. |
… RFC-2616 standard; now Thursday is correctly abreviated to Thu
…l time sync was achieved.
I find that I sometimes get timeouts on the first sync attempt after powering up an ESP8266 and connecting to Wifi. I'd like to suggest simply adding the following to Time.cpp (and TimeLib.h). The sketch can determine for itself if the time is not set and kick off another one if needed. void syncNow() |
I know this thread is a long time ago, but I think this is what I need.. I've got a clock with a RTC and i want to sync it every hour. |
I use a GSM modem to sync my time. When I initialise my program I call setSyncProvider to set my getTImeFunction. Though at that time the modem is not turned on neither has it connected to the mobile network and thus the sync attempt in now() will fail. But subsequent calls after I have taken the modem online will return a none synced time even if the sync service is available. Once syncInterval has passed now() will make a new sync attempt.
Instead I would like now() to try to sync everytime as long as the status is timeNotSet. The provided code takes care of this.
Also changed the indentation to spaces instead of tabs of my previous commit.