47 _ref.accuracy = accuracy;
68 _encrypted = requireEncryption;
85 uint64_t ms = _source !=
nullptr ? _source->getTimeMs() : 0;
88 if (_timeIsLocal) ms +=
static_cast<int64_t
>(_info.utcOffsetMinutes()) * 60000;
94 size_t localTimeValue(uint8_t* out)
const {
return _info.encode(out); }
96 size_t referenceTimeValue(uint8_t* out)
const {
return _ref.encode(out); }
105 if (_source ==
nullptr || !_settable)
return false;
107 if (_timeIsLocal) ms -=
static_cast<int64_t
>(_info.utcOffsetMinutes()) * 60000;
108 if (!_source->setTimeMs(ms))
return false;
119 if (!_settable || !TinyCTSLocalTimeInfo::decode(data, len, info))
return false;
126 if (_source ==
nullptr || _notifyMs == 0)
return false;
127 uint32_t now = TINY_CTS_MILLIS();
128 if (
static_cast<uint32_t
>(now - _lastNotify) < _notifyMs)
return false;
136 uint32_t _notifyMs = 0;
137 uint32_t _lastNotify = 0;
138 uint32_t _setCount = 0;
139 bool _timeIsLocal =
false;
140 bool _settable =
false;
141 bool _encrypted =
true;
Time sources of the TinyCTSServer: the interface, a software clock, the system clock and an adapter f...
The data of the Bluetooth Current Time Service (CTS, 0x1805): UUIDs and the encoding of the character...
Settings and values of a TinyCTSServer. Use TinyCTSServer, which adds the Bluetooth part.
Definition TinyCTSServerBase.h:22
bool setTimeZoneFromWrite(const uint8_t *data, size_t len)
Definition TinyCTSServerBase.h:117
uint32_t getTimeSetCount() const
The number of times that a client has set the time.
Definition TinyCTSServerBase.h:72
bool setTimeFromWrite(const uint8_t *data, size_t len)
Definition TinyCTSServerBase.h:102
void setTimeZone(int utcOffsetMinutes, int dstMinutes=0)
The time zone that is offered in the Local Time Information.
Definition TinyCTSServerBase.h:39
void setTimeIsLocal(bool local)
The Current Time contains the local time (UTC + the offsets of the Local Time Information) instead of...
Definition TinyCTSServerBase.h:56
virtual void onReferenceChanged()
Definition TinyCTSServerBase.h:78
bool notifyDue()
Definition TinyCTSServerBase.h:125
virtual void onTimeZoneChanged()
Definition TinyCTSServerBase.h:76
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 b...
Definition TinyCTSServerBase.h:66
void setReferenceInfo(uint8_t source, uint8_t accuracy=255)
Where the time comes from and how exact it is (125 ms steps).
Definition TinyCTSServerBase.h:45
size_t currentTimeValue(uint8_t reason, uint8_t *out)
Definition TinyCTSServerBase.h:84
void setNotifyInterval(uint32_t ms)
Notify the subscribed clients regularly in process(). 0 (default): only when the time was set or the ...
Definition TinyCTSServerBase.h:32
Abstract base class of the time sources: an object that knows the current UTC time.
Definition TinyCTSTimeSource.h:51
The Current Time characteristic (0x2A2B): 10 bytes with the date and time (Exact Time 256),...
Definition TinyCTSTypes.h:68
static TinyCTSCurrentTime fromUnixMs(uint64_t unixMs, uint8_t reason=0)
The characteristic for a time in ms since 1970-01-01.
Definition TinyCTSTypes.h:90
bool toUnixMs(uint64_t &unixMs) const
The time in ms since 1970-01-01.
Definition TinyCTSTypes.h:115
static bool decode(const uint8_t *data, size_t len, TinyCTSCurrentTime &t)
Read the characteristic. Some devices send the 9 bytes of the Exact Time 256 without the adjust reaso...
Definition TinyCTSTypes.h:153
size_t encode(uint8_t *out) const
Write the 10 bytes.
Definition TinyCTSTypes.h:134
The Local Time Information characteristic (0x2A0F): the time zone and the daylight saving time (DST) ...
Definition TinyCTSTypes.h:173
static TinyCTSLocalTimeInfo fromMinutes(int utcOffsetMinutes, int dstMinutes=0)
From the offsets in minutes.
Definition TinyCTSTypes.h:186
The Reference Time Information characteristic (0x2A14): where the time of the server comes from,...
Definition TinyCTSTypes.h:227