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

The data of a TinyCTSClient. Use TinyCTSClient, which adds the Bluetooth part. More...

#include <TinyCTSClientBase.h>

Inheritance diagram for tiny_cts::TinyCTSClientBase:
tiny_cts::TinyCTSTimeSource tiny_cts::TinyCTSClient tiny_cts::TinyCTSClient tiny_cts::TinyCTSClient tiny_cts::TinyCTSClient

Public Member Functions

const TinyCTSCurrentTime & getCurrentTime () const
 The Current Time as it was sent by the device.
const std::string & getDeviceAddress () const
 The address of the device that was used.
const std::string & getDeviceName () const
 The name of the device that was used (empty before begin()).
const TinyCTSLocalTimeInfo & getLocalTimeInfo () const
 The time zone of the device (valid after update() if it has it).
std::tm getLocalTm ()
 The local time as std::tm, with the offsets of the device.
const TinyCTSReferenceTimeInfo & getReferenceTimeInfo () const
 Where the time of the device comes from.
uint32_t getTime ()
 The UTC time in seconds since 1970-01-01 (0 if not known).
uint64_t getTimeMs () override
 The UTC time in ms since 1970-01-01, extrapolated since the last update.
std::tm getTm ()
 The UTC time as std::tm.
void setLocalTimeInfo (const TinyCTSLocalTimeInfo &info)
 Tell the client the time zone of the device, if it does not have the Local Time Information. Used for the local time and, with setTimeIsLocal(), when the time is set.
void setTimeIsLocal (bool local)
 The Current Time of the device is the local time, not UTC.
Public Member Functions inherited from tiny_cts::TinyCTSTimeSource
virtual bool setTimeMs (uint64_t unixMs)
 Set the current UTC time, e.g. when a client writes the Current Time characteristic. The default implementation does not support this.

Protected Member Functions

bool isWanted (const std::string &address, const std::string &name) const
bool storeCurrentTime (const uint8_t *data, size_t len, uint32_t startMs, uint32_t endMs)
void storeLocalInfo (const uint8_t *data, size_t len)
void storeReferenceInfo (const uint8_t *data, size_t len)
size_t timeToWrite (uint64_t unixMs, uint8_t *out) const

Static Protected Member Functions

static bool equalsIgnoreCase (const std::string &a, const std::string &b)

Protected Attributes

std::string _address
TinyCTSCurrentTime _current
std::string _device
TinyCTSLocalTimeInfo _info
uint32_t _lastMillis = 0
std::string _name
TinyCTSReferenceTimeInfo _ref
bool _timeIsLocal = false
uint64_t _timeMs = 0

Detailed Description

The data of a TinyCTSClient. Use TinyCTSClient, which adds the Bluetooth part.

Member Function Documentation

◆ getTimeMs()

uint64_t tiny_cts::TinyCTSClientBase::getTimeMs ( )
inlineoverridevirtual

The UTC time in ms since 1970-01-01, extrapolated since the last update.

Returns
0 if the time has not been read.

Implements tiny_cts::TinyCTSTimeSource.

◆ isWanted()

bool tiny_cts::TinyCTSClientBase::isWanted ( const std::string & address,
const std::string & name ) const
inlineprotected

true if the device is the one that was asked for (address or name).

◆ storeCurrentTime()

bool tiny_cts::TinyCTSClientBase::storeCurrentTime ( const uint8_t * data,
size_t len,
uint32_t startMs,
uint32_t endMs )
inlineprotected

The Current Time was read.

Parameters
startMsmillis() before the request, endMs after the response: the time is valid in the middle.
Returns
false if the data is not a valid time.

◆ timeToWrite()

size_t tiny_cts::TinyCTSClientBase::timeToWrite ( uint64_t unixMs,
uint8_t * out ) const
inlineprotected

The 10 bytes to write to set the time of the device.


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