5#ifdef USE_RX8111_TIMESTAMP
18#ifdef USE_BINARY_SENSOR
19PROGMEM_STRING_TABLE(StatusSensorNames,
"Voltage low flag",
"Alarm flag",
"Timer flag",
"Oscillation stop flag",
20 "Event flag",
"Battery low",
"EVIN");
22#ifdef USE_RX8111_TIMESTAMP
25PROGMEM_STRING_TABLE(BootFailureNames,
"RX8111 battery configuration failed",
"RX8111 FOUT configuration failed",
26 "RX8111 EVIN configuration failed", ESP_LOG_MSG_COMM_FAIL, ESP_LOG_MSG_COMM_FAIL);
28static constexpr uint8_t RX8111_REG_SEC = 0x10;
29static constexpr uint8_t RX8111_REG_MIN_ALARM = 0x17;
30static constexpr uint8_t RX8111_REG_EXTENSION = 0x1D;
31static constexpr uint8_t RX8111_REG_FLAG = 0x1E;
32static constexpr uint8_t RX8111_REG_TIMER0 = 0x1A;
33static constexpr uint8_t RX8111_REG_CONTROL = 0x1F;
34static constexpr uint8_t RX8111_REG_SEC_ALARM = 0x2C;
35static constexpr uint8_t RX8111_REG_TIMER_CONTROL = 0x2D;
36static constexpr uint8_t RX8111_REG_POWER_SWITCH = 0x32;
37static constexpr uint8_t RX8111_REG_TIMESTAMP_CONTROL = 0x34;
38#ifdef USE_RX8111_TIMESTAMP
39static constexpr uint8_t RX8111_REG_TIMESTAMP_STATUS = 0x36;
40static constexpr uint8_t RX8111_REG_TIMESTAMP_LATEST = 0x20;
41static constexpr uint8_t RX8111_REG_TIMESTAMP_BUFFER = 0x40;
42static constexpr uint8_t RX8111_TIMESTAMP_RAM = 0x01;
43static constexpr uint8_t RX8111_TIMESTAMP_CLEAR = 0x02;
44static constexpr uint8_t RX8111_TIMESTAMP_EMPTY = 0x08;
45static constexpr uint8_t RX8111_TIMESTAMP_FULL = 0x10;
46static constexpr uint8_t RX8111_EVIN_OVERWRITE = 0x02;
48static constexpr uint8_t RX8111_TIMESTAMP_EISEL = 0x04;
49static constexpr uint8_t RX8111_REG_EVIN = 0x2B;
50static constexpr uint8_t RX8111_EXTENSION_ETS = 0x04;
51static constexpr uint8_t RX8111_CONTROL_EIE = 0x04;
52static constexpr uint8_t RX8111_FLAG_EVF = 0x04;
53static constexpr uint8_t RX8111_POWER_CHGEN = 0x80;
54static constexpr uint8_t RX8111_POWER_INIEN = 0x40;
55static constexpr uint8_t RX8111_POWER_SWSEL = 0x0C;
56static constexpr uint8_t RX8111_POWER_VDD_ONLY = 0x08;
57static constexpr uint8_t RX8111_FOUT_FSEL = 0xC0;
58static constexpr uint8_t RX8111_TIMER_TMPIN = 0x02;
59static constexpr uint8_t RX8111_TIMER_MODE = 0x0F;
60static constexpr uint8_t RX8111_ALARM_DISABLED = 0x80;
61static constexpr uint8_t RX8111_EXTENSION_WADA = 0x08;
62static constexpr uint8_t RX8111_CONTROL_AIE = 0x08;
63static constexpr uint8_t RX8111_CONTROL_TIE = 0x10;
64static constexpr uint8_t RX8111_EXTENSION_TE = 0x10;
65static constexpr uint8_t RX8111_EXTENSION_TSEL = 0x03;
66static constexpr uint8_t RX8111_FLAG_TF = 0x10;
67static constexpr uint8_t RX8111_FLAG_AF = 0x08;
68static constexpr uint8_t RX8111_FLAG_POR = 0x80;
69static constexpr uint8_t RX8111_FLAG_VLF = 0x02;
70static constexpr uint8_t RX8111_FLAG_XST = 0x01;
71#ifdef USE_BINARY_SENSOR
72static constexpr uint8_t RX8111_REG_STATUS = 0x33;
73static constexpr uint8_t RX8111_STATUS_VLOW = 0x02;
74static constexpr uint8_t RX8111_STATUS_EVIN = 0x40;
75static constexpr uint8_t STATUS_SENSOR_MASKS[] PROGMEM = {
76 RX8111_FLAG_VLF, RX8111_FLAG_AF, RX8111_FLAG_TF, RX8111_FLAG_XST,
77 RX8111_FLAG_EVF, RX8111_STATUS_VLOW, RX8111_STATUS_EVIN,
81static constexpr uint8_t RX8111_CTRL_STOP = 0x01;
83static constexpr uint8_t RX8111_KEEP_EVENT_FLAGS = 0x3C;
84static constexpr uint32_t RX8111_EVENT_INTERVAL_ID = 0;
85static constexpr uint32_t RX8111_BOOT_ALARM_RETRY_ID = 1;
86static constexpr uint32_t RX8111_BOOT_TIMER_RETRY_ID = 2;
87static constexpr uint32_t RX8111_BOOT_BATTERY_RETRY_ID = 3;
88static constexpr uint32_t RX8111_BOOT_FOUT_RETRY_ID = 4;
89static constexpr uint32_t RX8111_BOOT_EVENT_RETRY_ID = 5;
90static constexpr uint32_t RX8111_DEFERRED_UPDATE_ID = 6;
91static constexpr uint32_t RX8111_DEFERRED_STATUS_ID = 7;
92static constexpr uint8_t RX8111_BOOT_MAX_ATTEMPTS = 3;
95static bool mask_bcd_calendar(uint8_t *calendar) {
96 static constexpr uint8_t MASKS[7] PROGMEM = {0x7F, 0x7F, 0x3F, 0x00, 0x3F, 0x1F, 0xFF};
98 for (
size_t i = 0; i <
sizeof(MASKS); i++) {
102 valid =
valid && (calendar[i] & 0x0F) <= 9 && (calendar[i] >> 4) <= 9;
113#ifdef USE_RX8111_TIMESTAMP
121#ifdef USE_RX8111_TIMESTAMP
129#ifdef USE_BINARY_SENSOR
142#ifdef USE_RX8111_TIMESTAMP
159#ifdef USE_RX8111_TIMESTAMP
166#ifdef USE_RX8111_TIMESTAMP
170 if (!this->
update_register(RX8111_REG_EXTENSION, RX8111_EXTENSION_ETS, 0) ||
171 !this->
read_byte(RX8111_REG_TIMESTAMP_CONTROL, &control))
174 const uint8_t
mode = buffered ? RX8111_TIMESTAMP_RAM : 0;
176 if (buffered && !(control & RX8111_TIMESTAMP_RAM))
177 control |= RX8111_TIMESTAMP_CLEAR;
178 control = (control & ~(RX8111_TIMESTAMP_RAM | RX8111_TIMESTAMP_EISEL)) |
mode;
181 this->
write_byte(RX8111_REG_TIMESTAMP_CONTROL, control) &&
184 this->
update_register(RX8111_REG_EXTENSION, RX8111_EXTENSION_ETS, RX8111_EXTENSION_ETS);
189 return this->
update_register(RX8111_REG_CONTROL, RX8111_CONTROL_EIE, 0);
193 this->
update_register(RX8111_REG_TIMESTAMP_CONTROL, RX8111_TIMESTAMP_EISEL, 0) &&
194 this->
update_register(RX8111_REG_EXTENSION, RX8111_EXTENSION_ETS, RX8111_EXTENSION_ETS) &&
195 this->
update_register(RX8111_REG_CONTROL, RX8111_CONTROL_EIE, RX8111_CONTROL_EIE);
200 if (!this->
write_byte(RX8111_REG_FLAG,
static_cast<uint8_t
>(~RX8111_FLAG_EVF))) {
212 const uint8_t
value = RX8111_POWER_VDD_ONLY | (this->
battery_backup_ ? RX8111_POWER_INIEN : 0) |
216 RX8111_POWER_INIEN | RX8111_POWER_CHGEN | RX8111_POWER_SWSEL,
value));
221 uint8_t timer_control;
222 bool success = this->
read_byte(RX8111_REG_TIMER_CONTROL, &timer_control);
223 if (success && this->
fout_frequency_ != 3 && (timer_control & RX8111_TIMER_TMPIN)) {
224 ESP_LOGW(TAG,
"FOUT is routed to the wake-up timer (TMPIN); cannot configure clock output");
226 }
else if (success) {
262 this->
set_warning_(config.warning, BootFailureNames::get_log_str(feature));
263 if (attempts < RX8111_BOOT_MAX_ATTEMPTS) {
265 this->
set_timeout(config.retry_id, this->boot_retry_delay_ms_, [
this, feature]() {
267 progmem_memcpy(&retry, &CONFIGS[feature], sizeof(retry));
268 (this->*retry.configure)();
290 success = this->
read_byte(RX8111_REG_CONTROL, &control);
292 this->
alarm_armed_ = (control & RX8111_CONTROL_AIE) != 0;
311 uint8_t extension, control;
326 this->
cancel_timeout(alarm ? RX8111_BOOT_ALARM_RETRY_ID : RX8111_BOOT_TIMER_RETRY_ID);
404 ESP_LOGCONFIG(TAG,
"RX8111:");
405 LOG_I2C_DEVICE(
this);
406#ifdef USE_BINARY_SENSOR
409 log_binary_sensor(TAG,
" ", LOG_STR_ARG(StatusSensorNames::get_log_str(i)), this->
status_sensors_[i]);
413#ifdef USE_RX8111_TIMESTAMP
416 ESP_LOGCONFIG(TAG,
" Timestamp record mode: %s",
421 ESP_LOGCONFIG(TAG,
" Battery backup: %s, charging: %s", ONOFF(this->
battery_backup_),
425 ESP_LOGCONFIG(TAG,
" FOUT: %s", LOG_STR_ARG(FoutNames::get_log_str(this->
fout_frequency_)));
428 ESP_LOGCONFIG(TAG,
" EVIN interrupt: %s", ONOFF(this->
event_enabled_));
430#ifdef USE_RX8111_TIMESTAMP
434 ESP_LOGCONFIG(TAG,
" EVIN: %s, filter: %u, pull: %s",
435 (this->
evin_settings_ & 0x80) ? LOG_STR_LITERAL(
"high") : LOG_STR_LITERAL(
"low"),
437 LOG_STR_ARG(EvinPullNames::get_log_str((this->
evin_settings_ >> 2) & 7)));
441 " Alarm interrupt: %s\n"
442 " Wake-up timer: %s",
445 ESP_LOGCONFIG(TAG,
" Count: %" PRIu32
", clock: %s", this->
timer_count_,
446 LOG_STR_ARG(TimerClockNames::get_log_str(this->
timer_clock_)));
448 RealTimeClock::dump_config();
460 ESP_LOGD(TAG,
"Read UTC time: %04d-%02d-%02d %02d:%02d:%02d", rtc_time.
year, rtc_time.
month, rtc_time.
day_of_month,
478 if (
flags !=
nullptr)
480 if (!this->
read_bytes(RX8111_REG_FLAG, regs,
sizeof(regs))) {
484 if (
flags !=
nullptr)
486 if (regs[1] & RX8111_CTRL_STOP) {
490 if (regs[0] & (RX8111_FLAG_VLF | RX8111_FLAG_XST | RX8111_FLAG_POR)) {
491 ESP_LOGW(TAG,
"RTC time invalidated by power loss or oscillator stop; write trusted time");
498 if (!this->
read_bytes(RX8111_REG_SEC, buf,
sizeof(buf))) {
503 bool valid = mask_bcd_calendar(buf);
504 const uint8_t onehot = buf[3];
505 valid =
valid && onehot != 0 && onehot <= 0x40 && (onehot & (onehot - 1)) == 0;
507 rtc_time = time::decode_bcd_calendar<time::EPSON_BCD_CALENDAR>(buf);
512 ESP_LOGW(TAG,
"Invalid RTC time, not syncing to system clock");
523 ESP_LOGE(TAG,
"Invalid system time, not syncing to RTC");
532 time::encode_bcd_calendar<time::EPSON_BCD_CALENDAR>(
now, buf);
534 const bool calendar_written = this->
write_bytes(RX8111_REG_SEC, buf,
sizeof(buf));
544 if (!calendar_written) {
559 return this->
update_register(RX8111_REG_CONTROL, RX8111_CTRL_STOP, stop ? RX8111_CTRL_STOP : 0);
563 return this->
update_register(RX8111_REG_CONTROL, RX8111_CONTROL_AIE, enabled ? RX8111_CONTROL_AIE : 0);
569 if (!this->
read_byte(RX8111_REG_EXTENSION, &extension))
572 extension &= ~RX8111_EXTENSION_WADA;
574 extension |= RX8111_EXTENSION_WADA;
577 const uint8_t fields[] = {
583 : RX8111_ALARM_DISABLED,
595 if (!this->
write_byte(RX8111_REG_SEC_ALARM, fields[0]) || !this->
write_bytes(RX8111_REG_MIN_ALARM, &fields[1], 3) ||
596 !this->
write_byte(RX8111_REG_EXTENSION, extension))
606 ESP_LOGE(TAG,
"Alarm interrupt disabled; set alarm_enabled: true");
611 (weekday != unset && (weekday < 1 || weekday > 7)) || (
day != unset && (
day < 1 || day > 31)) ||
612 (weekday != unset &&
day != unset) ||
613 (
second == unset &&
minute == unset &&
hour == unset && weekday == unset &&
day == unset)) {
614 ESP_LOGE(TAG,
"Invalid alarm fields");
629 if (!this->
alarm_enabled_ || seconds == 0 || seconds >= 28U * 86400U) {
630 ESP_LOGE(TAG,
"Relative alarm requires alarm_enabled and a duration of 1 second to less than 28 days");
635 ESP_LOGE(TAG,
"Cannot read valid RTC time for relative alarm");
639 if (!target.is_valid() || target.year > 2099) {
640 ESP_LOGE(TAG,
"Relative alarm target is outside RTC year range");
654 static constexpr uint8_t DISABLED_FIELDS[3] = {RX8111_ALARM_DISABLED, RX8111_ALARM_DISABLED, RX8111_ALARM_DISABLED};
655 if (!this->
write_byte(RX8111_REG_SEC_ALARM, RX8111_ALARM_DISABLED) ||
656 !this->
write_bytes(RX8111_REG_MIN_ALARM, DISABLED_FIELDS,
sizeof(DISABLED_FIELDS))) {
665 if (!this->
write_byte(RX8111_REG_FLAG,
static_cast<uint8_t
>(~RX8111_FLAG_AF))) {
676 return this->
read_byte(RX8111_REG_EXTENSION, &extension) &&
677 this->
write_byte(RX8111_REG_EXTENSION, extension & ~RX8111_EXTENSION_TE) &&
678 this->
read_byte(RX8111_REG_CONTROL, &control) &&
679 this->
write_byte(RX8111_REG_CONTROL, control & ~RX8111_CONTROL_TIE);
691 if (!this->
update_register(RX8111_REG_TIMER_CONTROL, RX8111_TIMER_MODE, 0))
698 (extension & ~(RX8111_EXTENSION_TE | RX8111_EXTENSION_TSEL)) | this->
timer_clock_) ||
700 !this->
write_byte(RX8111_REG_CONTROL, control | RX8111_CONTROL_TIE))
703 (extension & ~RX8111_EXTENSION_TSEL) | this->
timer_clock_ | RX8111_EXTENSION_TE);
708 ESP_LOGW(TAG,
"Cannot start timer without a valid timer_count");
715 uint8_t extension, control;
730 if (!this->
write_byte(RX8111_REG_FLAG,
static_cast<uint8_t
>(~RX8111_FLAG_TF))) {
742 uint8_t extension, control;
754 bool flags_valid =
false;
755 switch (snapshot.
state) {
766 bool success = flags_valid;
767#ifdef USE_BINARY_SENSOR
771 const bool status_valid = !monitor_requested || this->
read_byte(RX8111_REG_STATUS, &
status);
772 success = success && status_valid;
781 const bool event_active = (
flags & RX8111_FLAG_EVF) != 0;
782 const bool event_rising =
786 const bool alarm_active = flags_valid && (
flags & RX8111_FLAG_AF) != 0;
787 const bool timer_active = flags_valid && (
flags & RX8111_FLAG_TF) != 0;
793 const bool timer_rising = timer_active && !this->
timer_flag_seen_ && timer_watched;
797 if (flags_valid && this->alarm_armed_)
800 if (flags_valid && timer_watched)
803 this->timer_retained_event_pending_ =
false;
804#ifdef USE_BINARY_SENSOR
809 if (this->
status_sensors_[i] !=
nullptr && (uses_flags ? flags_valid : status_valid)) {
815#ifdef USE_RX8111_TIMESTAMP
836#ifdef USE_RX8111_TIMESTAMP
852 if (!buffered &&
count != 0) {
856 for (uint8_t i = 0; i <
count; i++)
862 const uint8_t offset = buffered ? 1 : 2;
863 uint8_t calendar[7] = {
raw[offset],
raw[offset + 1],
raw[offset + 2], 1,
864 raw[buffered ? 4 : 6],
raw[buffered ? 5 : 7],
raw[buffered ? 6 : 8]};
866 const bool valid = mask_bcd_calendar(calendar) && (
raw[buffered ? 7 : 9] & 2) == 0;
867 const auto captured = time::decode_bcd_calendar<time::EPSON_BCD_CALENDAR>(calendar);
868 if (!
valid || !captured.is_valid(
true,
false) || captured.second > 59) {
869 ESP_LOGW(TAG,
"Skipping invalid RTC timestamp record");
872 const uint16_t fraction = buffered ?
raw[0] * 4 :
raw[1] * 4 + (
raw[0] & 3);
874 const unsigned milliseconds = fraction * 1000U / 1024U;
877 std::snprintf(
value,
sizeof(
value),
"%04u-%02u-%02uT%02u:%02u:%02u.%03uZ", captured.year, captured.month,
878 captured.day_of_month, captured.hour, captured.minute, captured.second, milliseconds);
884 if (!this->
update_register(RX8111_REG_EXTENSION, RX8111_EXTENSION_ETS, RX8111_EXTENSION_ETS))
889 uint8_t records[64]{};
892 if (!this->
read_bytes(RX8111_REG_TIMESTAMP_LATEST, records, 10))
897 if (!startup && buffered) {
901 if (
status & RX8111_TIMESTAMP_EMPTY)
905 if (!this->
read_byte(RX8111_REG_EXTENSION, &extension))
907 const bool restore = (extension & RX8111_EXTENSION_ETS) != 0;
910 (flags & (RX8111_FLAG_POR | RX8111_FLAG_VLF | RX8111_FLAG_XST)) == 0 && ((
flags & RX8111_FLAG_EVF) || restore);
913 if (restore && !this->
write_byte(RX8111_REG_EXTENSION, extension & ~RX8111_EXTENSION_ETS)) {
926 }
else if (!buffered) {
927 success = this->
read_bytes(RX8111_REG_TIMESTAMP_LATEST, records, 10);
929 const bool publish_latest =
932 count = publish_latest ? 1 : 0;
936 if (success && !(
status & RX8111_TIMESTAMP_EMPTY)) {
937 const uint8_t latest =
status & 7;
938 const uint8_t available = (
status & RX8111_TIMESTAMP_FULL) ? 8 : latest + 1;
939 const uint8_t first = available == 8 ? (latest + 1) & 7 : 0;
940 for (uint8_t i = 0; i < available && success; i++)
941 success = this->
read_bytes(RX8111_REG_TIMESTAMP_BUFFER + (((first + i) & 7) * 8), records + i * 8, 8);
947 success = this->
update_register(RX8111_REG_TIMESTAMP_CONTROL, RX8111_TIMESTAMP_CLEAR, RX8111_TIMESTAMP_CLEAR);
969 if (!this->
update_register(RX8111_REG_TIMESTAMP_CONTROL, RX8111_TIMESTAMP_CLEAR, RX8111_TIMESTAMP_CLEAR))
978 const bool restored = !restore || this->
write_byte(RX8111_REG_EXTENSION, extension);
980 success = success && restored;
BedjetMode mode
BedJet operating mode.
void status_set_warning()
void defer(const char *name, SchedulerCallback &&f)
Defer a callback to the next loop() call with a const char* name.
bool cancel_interval(const char *name)
Cancel an interval function.
bool cancel_timeout(const char *name)
Cancel a timeout function.
bool cancel_defer(const char *name)
Cancel a defer callback using the specified name, name must not be empty.
void status_clear_warning()
void set_interval(const char *name, uint32_t interval, SchedulerCallback &&f)
Set an interval function with a const char* name.
void set_timeout(const char *name, uint32_t timeout, SchedulerCallback &&f)
Set a timeout function with a const char* name.
void publish_state(bool new_state)
Publish a new state to the front-end.
bool write_byte(uint8_t a_register, uint8_t data) const
bool read_byte(uint8_t a_register, uint8_t *data)
bool write_bytes(uint8_t a_register, const uint8_t *data, uint8_t len) const
bool update_register(uint8_t a_register, uint8_t mask, uint8_t value)
Read a register, replace the bits in mask with those of value and write it back.
bool read_bytes(uint8_t a_register, uint8_t *data, uint8_t len)
Compat APIs All methods below have been added for compatibility reasons.
void deliver_timestamps_(const uint8_t *records, uint8_t count, bool buffered)
static constexpr uint8_t ALARM_FIELD_UNSET
bool set_alarm(uint16_t second, uint16_t minute, uint16_t hour, uint16_t weekday, uint16_t day)
LazyCallbackManager< void()> alarm_callbacks_
uint8_t boot_attempts_[BOOT_FEATURE_COUNT]
bool timestamp_clear_pending_
bool program_alarm_(uint8_t second, uint8_t minute, uint8_t hour, uint8_t weekday, uint8_t day, bool boot=false)
void dump_config() override
void publish_staged_timestamps_()
bool poll_event_flags_(FlagSnapshot snapshot={})
bool disable_timer_(uint8_t &extension, uint8_t &control)
bool read_calendar_(ESPTime &rtc_time, FlagSnapshot *flags=nullptr)
void start_event_polling_()
void configure_boot_alarm_()
bool alarm_explicitly_configured_
void publish_timestamp_(const uint8_t *raw, bool buffered)
bool schedule_alarm_in(uint32_t seconds)
bool capture_restore_pending_
binary_sensor::BinarySensor * status_sensors_[STATUS_SENSOR_COUNT]
void read_time_(FlagSnapshot &flags)
bool configure_timer_(bool clear_stale_flag=false)
bool event_polling_started_
bool deferred_update_running_
bool boot_alarm_event_seen_
bool has_status_sensor_() const
void run_deferred_update_(bool status_only)
bool retained_latest_qualified_
bool set_alarm_interrupt_(bool enabled)
TimestampMode timestamp_mode_
void retry_fout_after_timer_start_()
bool timer_retained_event_pending_
text_sensor::TextSensor * timestamp_sensor_
bool finish_time_write_(bool calendar_written)
bool retained_flags_seen_
void cancel_boot_retry_(bool alarm)
uint32_t event_poll_interval_
uint8_t staged_timestamps_[64]
void boot_config_result_(BootFeature feature, bool success)
bool set_stop_bit_(bool stop)
void clear_warning_(uint16_t bit)
void check_event_flags_(FlagSnapshot flags={})
void configure_boot_event_()
bool retained_evidence_seen_
uint8_t last_timestamp_[10]
void configure_boot_battery_()
void set_warning_(uint16_t bit, const LogString *message)
bool publish_timestamps_(uint8_t flags, bool buffered, bool startup=false)
LazyCallbackManager< void()> event_callbacks_
LazyCallbackManager< void()> timer_callbacks_
void configure_boot_fout_()
void configure_boot_timer_()
void publish_state(const std::string &state)
ESPTime now()
Get the time in the currently defined timezone.
ESPTime utcnow()
Get the time without any time zone or DST corrections.
LazyCallbackManager< void()> time_sync_callback_
void synchronize_epoch_(uint32_t epoch)
Report a unix epoch as current time.
const LogString * message
@ TIMESTAMP_MODE_OVERWRITE
ESPHOME_LOG_TAG(TAG, "rx8111")
@ STATUS_SENSOR_BATTERY_LOW
@ STATUS_SENSOR_FIRST_MONITOR
PROGMEM_STRING_TABLE(TimerClockNames, "4096 Hz", "64 Hz", "1 Hz", "1/60 Hz")
constexpr uint8_t uint8_to_bcd(uint8_t value)
Encode a value from 0 to 99 as a two-digit packed BCD byte, e.g. 59 to 0x59.
void progmem_memcpy(void *dst, const void *src, size_t len)
uint8_t progmem_read_byte(const uint8_t *addr)
A more user-friendly version of struct tm from time.h.
uint8_t minute
minutes after the hour [0-59]
uint8_t second
seconds after the minute [0-60]
uint8_t hour
hours since midnight [0-23]
time_t timestamp
unix epoch time (seconds since UTC Midnight January 1, 1970)
bool is_valid(bool check_day_of_week=true, bool check_day_of_year=true) const
Check if this ESPTime is valid (year >= internal::MIN_VALID_YEAR and the requested fields are in rang...
static ESPTime from_epoch_utc(time_t epoch)
Convert an UTC epoch timestamp to a UTC time ESPTime instance.
uint8_t day_of_month
day of the month [1-31]
uint8_t month
month; january=1 [1-12]
uint8_t day_of_week
day of the week; sunday=1 [1-7]