CDC Badge OS
Firmware for the CDC Badge v1.0 hardware security key
Loading...
Searching...
No Matches
cdc::hal::IRtc Class Referenceabstract

#include <IRtc.h>

Inheritance diagram for cdc::hal::IRtc:
cdc::core::IService cdc::hal::Esp32Rtc

Public Member Functions

virtual ~IRtc ()=default
virtual void getTime (struct tm *timeinfo) const =0
virtual void getTimeStr (char *buf, size_t bufLen) const =0
virtual void getDateStr (char *buf, size_t bufLen) const =0
virtual void setTime (int hour, int minute, int second)=0
virtual void setDate (int year, int month, int day)=0
virtual void setTimestamp (time_t timestamp)=0
virtual time_t getTimestamp () const =0
virtual bool isTimeSet () const =0
virtual void markTimeSet ()=0
virtual void setTimezoneOffset (int8_t hours)=0
virtual int8_t getTimezoneOffset () const =0
Public Member Functions inherited from cdc::core::IService
virtual ~IService ()=default
virtual bool init ()=0
virtual bool start ()=0
virtual void stop ()=0
virtual ServiceState getState () const =0
virtual const char * getName () const =0

Detailed Description

RTC (Real-Time Clock) Interface

Uses ESP32-S3's internal RTC. Time survives light sleep but NOT deep sleep or power cycles without battery backup.

Reference: ~/GIT/cdc-badge-os-legacy/components/cdc_badge/cdc_rtc.cpp

Definition at line 17 of file IRtc.h.

Constructor & Destructor Documentation

◆ ~IRtc()

virtual cdc::hal::IRtc::~IRtc ( )
virtualdefault

Member Function Documentation

◆ getDateStr()

virtual void cdc::hal::IRtc::getDateStr ( char * buf,
size_t bufLen ) const
pure virtual

Get date as formatted string "YYYY-MM-DD"

Implemented in cdc::hal::Esp32Rtc.

◆ getTime()

virtual void cdc::hal::IRtc::getTime ( struct tm * timeinfo) const
pure virtual

Get current time as struct tm

Implemented in cdc::hal::Esp32Rtc.

◆ getTimestamp()

virtual time_t cdc::hal::IRtc::getTimestamp ( ) const
pure virtual

Get Unix timestamp

Implemented in cdc::hal::Esp32Rtc.

◆ getTimeStr()

virtual void cdc::hal::IRtc::getTimeStr ( char * buf,
size_t bufLen ) const
pure virtual

Get time as formatted string "HH:MM"

Implemented in cdc::hal::Esp32Rtc.

◆ getTimezoneOffset()

virtual int8_t cdc::hal::IRtc::getTimezoneOffset ( ) const
pure virtual

Get timezone offset in hours

Implemented in cdc::hal::Esp32Rtc.

◆ isTimeSet()

virtual bool cdc::hal::IRtc::isTimeSet ( ) const
pure virtual

Check if time has been set (year >= 2024)

Implemented in cdc::hal::Esp32Rtc.

Referenced by initRtc().

◆ markTimeSet()

virtual void cdc::hal::IRtc::markTimeSet ( )
pure virtual

Mark time as set (e.g. after NTP sync)

Implemented in cdc::hal::Esp32Rtc.

◆ setDate()

virtual void cdc::hal::IRtc::setDate ( int year,
int month,
int day )
pure virtual

Set date (year, month 1-12, day 1-31)

Implemented in cdc::hal::Esp32Rtc.

◆ setTime()

virtual void cdc::hal::IRtc::setTime ( int hour,
int minute,
int second )
pure virtual

Set time (hour, minute, second) If date is not set, defaults to 2025-01-01

Implemented in cdc::hal::Esp32Rtc.

◆ setTimestamp()

virtual void cdc::hal::IRtc::setTimestamp ( time_t timestamp)
pure virtual

Set time from Unix timestamp

Implemented in cdc::hal::Esp32Rtc.

◆ setTimezoneOffset()

virtual void cdc::hal::IRtc::setTimezoneOffset ( int8_t hours)
pure virtual

Set timezone offset in hours from UTC E.g., +1 for CET, +2 for CEST

Implemented in cdc::hal::Esp32Rtc.


The documentation for this class was generated from the following file:
  • components/cdc_hal/include/cdc_hal/IRtc.h