TinyCTS
Bluetooth Current Time Service client and server for Arduino
Loading...
Searching...
No Matches
tiny_cts::TinyCTSClockSource Class Reference

A software clock: you set the UTC time (from an RTC, a GPS, ...) and it keeps counting with millis(). The time is 0 (not known) until it is set. Read or set it at least once every 49 days (overflow of millis()). More...

#include <TinyCTSTimeSource.h>

Inheritance diagram for tiny_cts::TinyCTSClockSource:
tiny_cts::TinyCTSTimeSource

Public Member Functions

void clear ()
uint64_t getTimeMs () override
 The current UTC time in milliseconds since 1970-01-01. It must not block.
bool isSet () const
void setTime (uint32_t unixSeconds, uint16_t milliseconds=0)
bool setTimeMs (uint64_t unixMs) override
 Set the current UTC time, e.g. when a client writes the Current Time characteristic. The default implementation does not support this.

Protected Attributes

uint32_t _lastMillis = 0
uint64_t _timeMs = 0

Detailed Description

A software clock: you set the UTC time (from an RTC, a GPS, ...) and it keeps counting with millis(). The time is 0 (not known) until it is set. Read or set it at least once every 49 days (overflow of millis()).

Member Function Documentation

◆ getTimeMs()

uint64_t tiny_cts::TinyCTSClockSource::getTimeMs ( )
inlineoverridevirtual

The current UTC time in milliseconds since 1970-01-01. It must not block.

Returns
The time or 0 as long as it is not known.

Implements tiny_cts::TinyCTSTimeSource.

◆ setTimeMs()

bool tiny_cts::TinyCTSClockSource::setTimeMs ( uint64_t unixMs)
inlineoverridevirtual

Set the current UTC time, e.g. when a client writes the Current Time characteristic. The default implementation does not support this.

Returns
true if the time was set.

Reimplemented from tiny_cts::TinyCTSTimeSource.


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