Skip to content

Initialize external RTC after power loss#3003

Open
axhoff wants to merge 1 commit into
meshcore-dev:devfrom
axhoff:agent/fix-lost-power-rtc
Open

Initialize external RTC after power loss#3003
axhoff wants to merge 1 commit into
meshcore-dev:devfrom
axhoff:agent/fix-lost-power-rtc

Conversation

@axhoff

@axhoff axhoff commented Jul 20, 2026

Copy link
Copy Markdown

Summary

  • detect lost-power state for discovered PCF8563 and DS3231 RTCs
  • initialize an invalid external RTC from the already-initialized fallback clock
  • preserve valid battery-backed RTC time
  • add regression tests for both seed and preserve behavior

Root cause

AutoDiscoverRTCClock selected a PCF8563 after successful I2C initialization without checking its voltage-low/lost-power flag. On the XIAO expansion board without an RTC backup battery, a hard power loss could therefore leave untrustworthy clock contents (for example, a date in 2042). The companion's existing backward-time guard would then correctly reject the lower current time, leaving the node stuck on the invalid future timestamp.

Scope

  • no protocol, packet, or storage changes
  • existing backward-time guards remain unchanged
  • valid external RTCs are unchanged
  • DS3231 is included because it exposes the same lostPower() state and follows the same discovery path
  • RV3028 and RX8130 behavior is unchanged

Validation

  • pio test -e native — 15/15 tests passed
  • pio run -e Xiao_S3_WIO_companion_radio_ble — passed
  • git diff --check — passed

Fixes #2996

@axhoff
axhoff marked this pull request as ready for review July 20, 2026 14:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant