Closed stanzlavos closed 7 years ago
Hi Thanks for your proposal. I looked at it, but it is not easy to compare the file because you reformatted it. In addition, I think, you did not use the newest version of my code (I added the support for US time zone). It also seams to me that you added two new calls. So, I think, also the example file has to be enhanced by these two calls? I would be glad to add your code. May I ask you to do me a favor? If you know Github, it would be easiest to fork my library, only change what is really necessary, and create a pull request. If you do not know Github: Just download the newest version, add your enhancements, keep the formatting as much as possible, and send it back as a zip file (as you did now). This would be much safer because you know your changes much better than me...
Hi Andreas
I will just give a brief description of what I have done :
1) "printDateTime" prints only if ".valid" is true 2) I have not touched any of the conversion/adjust/DST APIs 3) The logic change is only in "getNTPtime" (which used to be a blocking call)
* It is now divided into two "phases" : send and recv (starts of with send phase)
* There are two new parameters : send interval and recv timeout (default values are 1 sec)
* Psuedo code :
time.valid = false
if(sendPhase)
{
if (time since last send less than send interval)
return time;
sendPhase = false
Send NTP packet
Set new "sent time"
}
else
{
if (packet not received)
{
if(recv timeout exceeded)
{
sendPhase = true
Reset "sent time"
}
}
else
{
Parse packet and get time
sendPhase = true
}
}
return time
4) The two new APIs are to set the send interval and recv timeout. It is not mandatory to use as the default values are used. 5) Let me try creating a fork and generating a pull request. :)
Have created a pull request. Do check. :)
merged
Hi Andreas
The problem I ran into with this library is that it is a blocking call. So, my UI/Touch interface gets stuck. So, I have made a few changes to the library so that it is non-blocking. Since there are a few changes, I am attaching the source code itself. Please check. :)
NTPtimeESP.zip