-
Notifications
You must be signed in to change notification settings - Fork 375
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
Make update() non-blocking. #22
base: master
Are you sure you want to change the base?
Conversation
I really like this approach! Thanks for this contribution. @sandeepmistry Any objections? |
I like the concept, however is this a breaking changing in behaviour? If so, maybe we can add a new API for non-blocking behaviour. |
Under identical network conditions the behavior may change a bit. (i.e. A single call to update() on a slow network may not update the time.) If the use of update() is to call it multiple times (i.e. in loop() ) and that the application expects that it sometimes fails to update, then it should be fine. |
Adding an API for the current time in a blocking way would be great to ensure that the time was synced at least once on startup. Otherwise I think that the behavior change is not that bad. |
forceUpdate() continues to behave with the with the same blocking behavior in my patch. Maybe that's what should be used? Keep in mind the original behavior of update() was to block for only one second so on unreliable or slow networks it will continue to fail. |
Thanks for the clarification. The suggested changes sound good to me. |
Accuracy is improved by using the fractional portion of seconds. Make millisecond accurate time available via new getEpochMillis() function.
Those last three actually support #23 with a new method:
|
Any chance this request will be accepted? |
@blackketter up to commit b68746a was good for me. Not sure why that wasn't merged then. @FWeinb what do you think of the newer commits? |
Will this PR be accepted and included? |
@blackketter When I use your fork, i often get a crash of the program. I've tried to decode the stacktrace, but it doesn't show line numbers:
The exception is in Edit: I also got this exception:
|
Hm, nothing stands out here.
Does it happen every time or just occasionally?
Is it possible to figure out approximately what line is failing with an objdump or by putting in some debugging printfs?
… On Jan 16, 2018, at 12:48 PM, corneyl ***@***.***> wrote:
@blackketter <https://github.com/blackketter> When I use your fork, i often get a crash of the program. I've tried to decode the stacktrace, but it doesn't show line numbers:
Exception Cause: 0 [Illegal instruction]
0x4021099d: NTPClient::checkResponse() at ??:?
0x40210b08: NTPClient::update() at ??:?
0x4020d58d: Clock::update() at ??:?
0x402113b8: PubSubClient::connected() at ??:?
0x40211635: loop at ??:?
0x402020ad: esp_schedule at ??:?
0x402020d8: loop_wrapper() at core_esp8266_main.cpp:?
0x40203fec: cont_norm at cont.o:?
The exception is in checkResponse(), any clue what this can be?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub <#22 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AAICX7vll7ujAH4tUavtwREY2vHtKF66ks5tLQs2gaJpZM4KUI5c>.
|
I think I found it:
it actually prints If I initialise _updateCallback like this: |
Good find!
… On Jan 16, 2018, at 2:30 PM, corneyl ***@***.***> wrote:
I think I found it: _updateCallback is not initialised.
I do not set a callback, but if I add a print statement to the callback check like this:
if (_updateCallback) {
Serial.println("Calling callback...");
_updateCallback(this);
}
it actually prints Calling callback... just before the stacktrace.
If I initialise _updateCallback like this: NTPUpdateCallbackFunction _updateCallback = NULL;, I do not get the exception.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub <#22 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AAICXwFU4-9Bh2I0h_MDVjzPJU0zmTaXks5tLSMdgaJpZM4KUI5c>.
|
Is this library still being maintained? |
|
When the network is unreliable or the NTP server is unavailable, the update() function can block for a substantial amount of time. This patch separates update request and response processing and allows for a single outstanding request. Requests are retransmitted every second if there's no response.
ForceUpdate() is still available and can still block.