Fork of the espurna firmware for `mhsw` switches
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 lines
880 B

  1. /*
  2. NTP MODULE
  3. */
  4. #pragma once
  5. #include "espurna.h"
  6. #if NTP_SUPPORT
  7. #include "broker.h"
  8. #if NTP_LEGACY_SUPPORT // Use legacy TimeLib and NtpClientLib
  9. #include <TimeLib.h>
  10. #include <WiFiUdp.h>
  11. #include <NtpClientLib.h>
  12. time_t ntpLocal2UTC(time_t local);
  13. #else // POSIX time functions + configTime(...)
  14. #include <lwip/apps/sntp.h>
  15. #include <TZ.h>
  16. #include "ntp_timelib.h"
  17. #endif
  18. // --- rest of the module is ESPurna functions
  19. enum class NtpTick {
  20. EveryMinute,
  21. EveryHour
  22. };
  23. struct NtpCalendarWeekday {
  24. int local_wday;
  25. int local_hour;
  26. int local_minute;
  27. int utc_wday;
  28. int utc_hour;
  29. int utc_minute;
  30. };
  31. using NtpBroker = TBroker<TBrokerType::Datetime, const NtpTick, time_t, const String&>;
  32. String ntpDateTime(tm* timestruct);
  33. String ntpDateTime(time_t ts);
  34. String ntpDateTime();
  35. bool ntpSynced();
  36. void ntpSetup();
  37. #endif // NTP_SUPPORT