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.

46 lines
742 B

  1. /*
  2. NTP MODULE
  3. Copyright (C) 2016-2019 by Xose Pérez <xose dot perez at gmail dot com>
  4. Copyright (C) 2019-2021 by Maxim Prokhorov <prokhorov dot max at outlook dot com>
  5. */
  6. #pragma once
  7. #include "espurna.h"
  8. enum class NtpTick {
  9. EveryMinute,
  10. EveryHour
  11. };
  12. using NtpTickCallback = void(*)(NtpTick);
  13. struct NtpCalendarWeekday {
  14. int local_wday;
  15. int local_hour;
  16. int local_minute;
  17. int utc_wday;
  18. int utc_hour;
  19. int utc_minute;
  20. };
  21. struct NtpInfo {
  22. String local;
  23. String utc;
  24. String sync;
  25. String tz;
  26. time_t now;
  27. };
  28. void ntpOnTick(NtpTickCallback);
  29. NtpInfo ntpInfo();
  30. String ntpDateTime(tm* timestruct);
  31. String ntpDateTime(time_t ts);
  32. String ntpDateTime();
  33. bool ntpSynced();
  34. void ntpSetup();