khoih-prog / NTPClient_Generic

Library for NTPClient to connect to an NTP time-server. Get time from a NTP time-server and keep it in sync. For ESP8266/ESP32, nRF52, SAMD21/SAMD51, STM32F/L/H/G/WB/MP1, Teensy, etc. besides AVR, using ESP WiFi, WiFiNINA, Ethernet W5x00, ENC28J60, LAN8742A, ESP8266/ESP32 AT-command WiFi.
MIT License
28 stars 12 forks source link

added setUDP function #8

Closed argo9 closed 2 years ago

argo9 commented 2 years ago

Added a function that allows setting the UDP socket after the declaration of the NTPClient element. This allows you to use Ethernet and WiFi within the same code and switch between them at run time.

khoih-prog commented 2 years ago

HI @argo9

Thanks for your PR.

Could you provide some MRE to demonstrate the problem this PR will fix.

I'm sorry I currently can't spend some time to study the effect of this PR.

Regards,

khoih-prog commented 2 years ago

Hi @argo9

I just have some time to look at your PR, which is very good feature to have. I'll merge, then publish a new release, along with some new examples to use the new enhancement for auto-switching between WiFi and Ethernet UDP to update NTP time.

Thanks for your good idea and looking forward to receiving more PRs from you.

Regards,

khoih-prog commented 2 years ago

Hi @argo9

The new NTPClient_Generic releases v3.7.2 has just been published. Your contribution is noted in Contributions and Thanks

Please check the new examples as well as the debug terminal output when running example ESP_WiFi_ETH_NTPClient_Advanced

Best Regards,


Releases v3.7.2

  1. Add setUDP() function to enable auto-switching between WiFi and Ethernet UDP instances. Check added setUDP function #8
  2. Add new examples ESP_WiFi_ETH_NTPClient_Advanced and WT32_WiFi_ETH01_NTPClient_Advanced to use the new setUDP() function for auto-switching between WiFi and Ethernet UDP to update NTP time.
  3. Update Packages_Patches