gmag11 / ESPNtpClient

High accuracy NTP library for ESP32 and ESP8266
MIT License
118 stars 25 forks source link

begin resetting the NTP server #23

Closed abaskin closed 2 years ago

abaskin commented 3 years ago

The begin method sets the NTP server if it is called without a value. I find this behavior unintuitive and at minimum suggest that the behavior should be documented. To give an example.

NTP.setNtpServerName("asia.pool.ntp.org"); NTP.begin();

In the code above the NTP server is reset to the default by begin even though it was previously set by setNtpServerName. A better approach would be for begin to only set the NTP server value to the default is it has not already been set.

gmag11 commented 2 years ago

Hello. You are right. I'll make that a prior call to NTP.setNtpServerName(...) force begin to use assigned server if begin() is called without arguments. Thank you

gmag11 commented 2 years ago

This should be working as expected after 8be062413c3a410a4677c6e7148fd1b2aa90cd5a, on dev branch. @abaskin Please test it and give some feedback

abaskin commented 2 years ago

I changed my code to set the NTP server before calling begin, pointed to the dev branch and it workes perfectly. Thank you.