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

Settings and values of a TinyCTSServer. Use TinyCTSServer, which adds the Bluetooth part. More...

#include <TinyCTSServerBase.h>

Inheritance diagram for tiny_cts::TinyCTSServerBase:
tiny_cts::TinyCTSServer tiny_cts::TinyCTSServer tiny_cts::TinyCTSServer tiny_cts::TinyCTSServer

Public Member Functions

void enableTimeSetting (bool requireEncryption=true)
 Allow the clients to set the time of the time source by writing the Current Time (and the time zone by writing the Local Time Information). Needs a time source that implements setTimeMs(). Call it before begin().
uint32_t getTimeSetCount () const
 The number of times that a client has set the time.
void setNotifyInterval (uint32_t ms)
 Notify the subscribed clients regularly in process(). 0 (default): only when the time was set or the time zone changed. The specification asks for a notification when the time changes by a larger step: use a long interval, e.g. 60000 ms.
void setReferenceInfo (uint8_t source, uint8_t accuracy=255)
 Where the time comes from and how exact it is (125 ms steps).
void setTimeIsLocal (bool local)
 The Current Time contains the local time (UTC + the offsets of the Local Time Information) instead of UTC (default). Some clients expect the local time. Call it before begin().
void setTimeZone (int utcOffsetMinutes, int dstMinutes=0)
 The time zone that is offered in the Local Time Information.

Protected Member Functions

size_t currentTimeValue (uint8_t reason, uint8_t *out)
size_t localTimeValue (uint8_t *out) const
bool notifyDue ()
virtual void onReferenceChanged ()
virtual void onTimeZoneChanged ()
size_t referenceTimeValue (uint8_t *out) const
bool setTimeFromWrite (const uint8_t *data, size_t len)
bool setTimeZoneFromWrite (const uint8_t *data, size_t len)

Protected Attributes

bool _encrypted = true
TinyCTSLocalTimeInfo _info
uint32_t _lastNotify = 0
uint32_t _notifyMs = 0
TinyCTSReferenceTimeInfo _ref
uint32_t _setCount = 0
bool _settable = false
TinyCTSTimeSource * _source = nullptr
bool _timeIsLocal = false

Detailed Description

Settings and values of a TinyCTSServer. Use TinyCTSServer, which adds the Bluetooth part.

Member Function Documentation

◆ currentTimeValue()

size_t tiny_cts::TinyCTSServerBase::currentTimeValue ( uint8_t reason,
uint8_t * out )
inlineprotected

The value of the Current Time: 10 bytes. While the time is not known, the date is unknown (all 0).

◆ enableTimeSetting()

void tiny_cts::TinyCTSServerBase::enableTimeSetting ( bool requireEncryption = true)
inline

Allow the clients to set the time of the time source by writing the Current Time (and the time zone by writing the Local Time Information). Needs a time source that implements setTimeMs(). Call it before begin().

Parameters
requireEncryptionThe clients must be paired (encrypted connection). Use false only in a trusted environment: everybody who is near the device can change the time!

◆ notifyDue()

bool tiny_cts::TinyCTSServerBase::notifyDue ( )
inlineprotected

true if the notification interval is over (and starts the next one).

◆ onReferenceChanged()

virtual void tiny_cts::TinyCTSServerBase::onReferenceChanged ( )
inlineprotectedvirtual

The Reference Time Information has changed.

Reimplemented in tiny_cts::TinyCTSServer, tiny_cts::TinyCTSServer, and tiny_cts::TinyCTSServer.

◆ onTimeZoneChanged()

virtual void tiny_cts::TinyCTSServerBase::onTimeZoneChanged ( )
inlineprotectedvirtual

The Local Time Information has changed: update the characteristic.

Reimplemented in tiny_cts::TinyCTSServer, tiny_cts::TinyCTSServer, tiny_cts::TinyCTSServer, and tiny_cts::TinyCTSServer.

◆ setTimeFromWrite()

bool tiny_cts::TinyCTSServerBase::setTimeFromWrite ( const uint8_t * data,
size_t len )
inlineprotected

A client wrote the Current Time.

Returns
true if the time source was set.

◆ setTimeZone()

void tiny_cts::TinyCTSServerBase::setTimeZone ( int utcOffsetMinutes,
int dstMinutes = 0 )
inline

The time zone that is offered in the Local Time Information.

Parameters
utcOffsetMinutesThe standard time zone, e.g. 60 for CET.
dstMinutesThe summer time offset now: 0, 30, 60 or 120.

◆ setTimeZoneFromWrite()

bool tiny_cts::TinyCTSServerBase::setTimeZoneFromWrite ( const uint8_t * data,
size_t len )
inlineprotected

A client wrote the Local Time Information.

Returns
true if the time zone was changed.

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