Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Added support for server IPAddress argument to NTPClient #32

Closed
wants to merge 1 commit into from
Closed

Added support for server IPAddress argument to NTPClient #32

wants to merge 1 commit into from

Conversation

sheffieldnikki
Copy link
Contributor

@sheffieldnikki sheffieldnikki commented Apr 26, 2017

Added option to connect to NTP server with binary poolServerIP argument, as alternative to string poolServerName. This takes slightly less memory, and is faster than doing a DNS lookup. If a string IP address was provided, it would still incur the overhead of being recognised as a numeric string, and converted to binary.

Fixes #31

@@ -30,6 +31,7 @@ class NTPClient {
NTPClient(UDP& udp);
NTPClient(UDP& udp, int timeOffset);
NTPClient(UDP& udp, const char* poolServerName);
NTPClient(UDP& udp, IPAddress poolServerIP);
NTPClient(UDP& udp, const char* poolServerName, int timeOffset);
NTPClient(UDP& udp, const char* poolServerName, int timeOffset, int updateInterval);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sheffieldnick thanks for submitting this pull request!

The change above looks good to me. However, what do you think about adding the IPAddress option to the other constructors that accept a string?

    NTPClient(UDP& udp, IPAddress poolServerIP, int timeOffset);
    NTPClient(UDP& udp, IPAddress poolServerIP, int timeOffset, int updateInterval);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would certainly work. I didn't add that code because I find it strange having multiple functions all doing much the same thing - I guess I'm just not used to the way things are structured in C++ ? A single function with optional arguments would seem more 'natural' to me. e.g.,

NTPClient(UDP& udp, IPAddress poolServerIP, int timeOffset = -1, int updateInterval = -1);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough, I would suggest leaving the current style for now.

We can open another PR later to discuss the default constructor args with @FWeinb.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good to me.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sheffieldnick ping any process on this?

@sheffieldnikki
Copy link
Contributor Author

?? I thought you were happy with my pull request?

@sandeepmistry
Copy link
Contributor

Ooops, sorry there was some confusion, still waiting for #32 (comment).

@aentinger
Copy link
Contributor

Since no response by @sheffieldnick was given since 2017 (and his fork of NTPClient has been deleted) I've taken it up to still introduce those changes into master - see #77 for details.

@aentinger aentinger closed this Sep 19, 2019
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Using an IP address for NTP connections
3 participants