Uniot Core
0.8.1
Loading...
Searching...
No Matches
uniot::Date Class Reference

#include <Date.h>

Inheritance diagram for uniot::Date:
[legend]

Public Member Functions

bool store () override
 Stores the current time to persistent storage.
 
bool restore () override
 Restores time from persistent storage.
 
virtual void execute (short _) override
 Periodic execution callback.
 
void forceSync ()
 Forces immediate NTP time synchronization.
 
- Public Member Functions inherited from uniot::IExecutor
virtual ~IExecutor ()
 Virtual destructor for proper cleanup.
 
- Public Member Functions inherited from uniot::CBORStorage
 CBORStorage (const String &path)
 Constructs a new CBORStorage object.
 
virtual ~CBORStorage ()
 Virtual destructor.
 
CBORObjectobject ()
 Get access to the underlying CBORObject.
 
virtual bool clean () override
 Clean the CBOR object and remove the storage file.
 
- Public Member Functions inherited from uniot::Storage
 Storage (const String &path)
 Constructs a Storage object for a specific file.
 
virtual ~Storage ()
 Destructor.
 
- Public Member Functions inherited from uniot::Singleton< Date >
 Singleton (const Singleton &)=delete
 Copy constructor is deleted to prevent duplicating the singleton instance.
 
Singletonoperator= (const Singleton &)=delete
 Assignment operator is deleted to prevent duplicating the singleton instance.
 
- Public Member Functions inherited from uniot::EventEmitter< unsigned int, int, Bytes >
virtual ~EventEmitter ()=default
 Virtual destructor to ensure proper cleanup of derived classes.
 
virtual type_id getTypeId () const override
 Returns the type identifier for this EventEmitter.
 
void emitEvent (unsigned int topic, int msg)
 Emits an event to all registered event buses.
 
virtual ~EventEmitter ()=default
 Virtual destructor to ensure proper cleanup of derived classes.
 
virtual type_id getTypeId () const override
 Returns the type identifier for this EventEmitter.
 
void emitEvent (unsigned int topic, int msg)
 Emits an event to all registered event buses.
 
- Public Member Functions inherited from uniot::EventEntity< T_topic, T_msg, T_data >
virtual ~EventEntity ()
 Destructor - disconnects from all connected EventBus instances.
 
bool sendDataToChannel (T_topic channel, T_data data)
 Sends data to a specific channel on all connected EventBus instances.
 
void receiveDataFromChannel (T_topic channel, DataChannelCallback callback)
 Receives data from a specific channel on all connected EventBus instances.
 

Static Public Member Functions

static time_t now ()
 Returns the current Unix timestamp.
 
static String getFormattedTime ()
 Gets the current time in human-readable format.
 
- Static Public Member Functions inherited from uniot::Storage
static void unmount ()
 Explicitly unmounts the filesystem.
 
- Static Public Member Functions inherited from uniot::Singleton< Date >
static DategetInstance ()
 Gets the singleton instance of the derived class.
 

Friends

class Singleton< Date >
 

Additional Inherited Members

- Public Types inherited from uniot::EventEntity< T_topic, T_msg, T_data >
using DataChannelCallback = std::function<void(unsigned int, bool, T_data)>
 Callback type for handling data received from channels.
 
- Protected Member Functions inherited from uniot::Storage
void setPath (const String &path)
 Sets the file path, ensuring it starts with "/".
 
- Protected Member Functions inherited from uniot::Singleton< Date >
 Singleton ()=default
 Default constructor is protected to prevent instantiation outside of derived classes.
 
 ~Singleton ()=default
 Default destructor is protected to prevent deletion through base class pointer.
 
- Protected Member Functions inherited from uniot::EventEntity< T_topic, T_msg, T_data >
bool connectUnique (EventBus< T_topic, T_msg, T_data > *eventBus)
 Connects to an EventBus instance if not already connected.
 
- Protected Attributes inherited from uniot::CBORStorage
CBORObject mCbor
 The CBOR object used for data serialization/deserialization.
 
- Protected Attributes inherited from uniot::Storage
Bytes mData
 The byte array containing the data to be stored or the loaded data.
 
String mPath
 The file path where data is stored.
 
- Protected Attributes inherited from uniot::EventEntity< T_topic, T_msg, T_data >
IterableQueue< EventBus< T_topic, T_msg, T_data > * > mEventBusQueue
 Queue of EventBus instances this entity is connected to.
 

Member Function Documentation

◆ execute()

virtual void uniot::Date::execute ( short _)
inlineoverridevirtual

Periodic execution callback.

Called periodically to store the current time to persistent storage.

Parameters
_Unused parameter required by IExecutor interface

Implements uniot::IExecutor.

◆ forceSync()

void uniot::Date::forceSync ( )
inline

Forces immediate NTP time synchronization.

Reconfigures the NTP client and initiates an immediate time sync request regardless of the regular sync schedule.

◆ getFormattedTime()

static String uniot::Date::getFormattedTime ( )
inlinestatic

Gets the current time in human-readable format.

Return values
StringTime in "YYYY-MM-DD HH:MM:SS" format

◆ now()

static time_t uniot::Date::now ( )
inlinestatic

Returns the current Unix timestamp.

Return values
time_tCurrent time as Unix timestamp (seconds since epoch)

◆ restore()

bool uniot::Date::restore ( )
inlineoverridevirtual

Restores time from persistent storage.

Loads the last saved epoch time from CBOR storage and sets the system time accordingly.

Return values
trueRestore operation was successful
falseRestore operation failed

Reimplemented from uniot::CBORStorage.

◆ store()

bool uniot::Date::store ( )
inlineoverridevirtual

Stores the current time to persistent storage.

Saves the current epoch time to CBOR storage to preserve time information between device reboots.

Return values
trueStorage operation was successful
falseStorage operation failed

Reimplemented from uniot::CBORStorage.

Friends And Related Symbol Documentation

◆ Singleton< Date >

friend class Singleton< Date >
friend

The documentation for this class was generated from the following file: