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.

52 lines
819 B

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