-
Notifications
You must be signed in to change notification settings - Fork 74
Description
I think this library is still useful. It could instead of retriving the time with UDP on esp8266 and esp32 work with the SDK API. The API is different on the esps so this way this library would hide the differences and have one way for different hardware.
And additionally to retrieving the time from NTP server this library sets-up the TimeLib. It helps the IoT newbies much.
Some thoughts to compatibility with different networking libraries. I made my local copy of this library compatible with WiFiNINA and my WiFiEspAT library simply by adding NETWORK_WIFI. (My PR to add WiFi.h to WiFi101 was not accepted yet so NETWORK_WIFI101 is still necessary)
#elif NETWORK_TYPE == NETWORK_WIFI
#include <WiFi.h>
#include <WiFiUdp.h>
a tip to network library used by the sketch detection. __has_include
works
#if __has_include(<Ethernet.h>)
#include <Ethernet.h>
#define USE_ETHERNET 1
#else
#include <WiFi.h>
#endif
In my TelnetStream library examples I played with esp SDK time retrieving. it is simple, but not so straightforward as with NtpClient library.
EDIT:
I see this in NtpClientLib.h
#elif NETWORK_TYPE == NETWORK_WIFI101
#include <WiFiClient.h>
#include <WiFiUdp.h>
#include <WiFi101.h>
always include the specific include first (WiFi101.h). Used in this ordering in a sketch it would include WiFiClient of the old WiFi library which is still bundled with Arduino IDE.