Module keira_rtc

Module keira_rtc 

Source
Expand description

Optional wall-clock inheritance after a KeiraOS MultiBoot software reset. Inherit a UTC wall clock left by KeiraOS/ESP-IDF in the ESP32-S3 RTC.

Requires the opt-in keira-rtc feature. It enables no allocator, radio, network stack or timezone database. Keira must synchronize its clock before launching the application through MultiBoot (a software reset).

ESP-IDF keeps the Unix time base in RTC STORE2/STORE3. esp-hal reads those registers through [esp_hal::rtc_cntl::Rtc::current_time_us]. This API samples that value once and uses the monotonic HAL timer afterwards, without changing RTC registers.

A plausible RTC value does not prove NTP synchronization or identify Keira as its source. Power loss, different ESP-IDF time settings or an incorrect clock can make inheritance unavailable or inaccurate. Test the handoff on hardware.

use lilkaoxide::{hal::rtc_cntl::Rtc, keira_rtc::KeiraClock, prelude::*};

let lilka = Lilka::init(Configuration::default()).unwrap();
let rtc = Rtc::new(lilka.peripherals.LPWR);
match KeiraClock::inherit(&rtc) {
    Ok(clock) => {
        let utc_seconds = clock.now_unix_seconds().unwrap();
        // Convert UTC to the timezone / file timestamp your app needs.
    }
    Err(_) => { /* Show "time unavailable", or offer synchronization. */ }
}

The example uses blocking initialization; in an async app use Lilka::init(...).await. No changes to Keira or direct calls into its process are needed. A full power-off requires synchronizing the clock again.

Structs§

KeiraClock
A UTC clock sampled from RTC, then advanced by the monotonic HAL timer.

Enums§

RtcTimeError
Why a retained RTC clock cannot supply a usable wall time.