The Current Time characteristic (0x2A2B): 10 bytes with the date and time (Exact Time 256), the day of week, fractions of a second and the reason for the last adjustment.
More...
#include <TinyCTSTypes.h>
|
| enum | AdjustReason : uint8_t { ManualUpdate = 1
, ExternalReference = 2
, TimeZoneChange = 4
, DstChange = 8
} |
| | Bits of adjustReason.
|
|
| size_t | encode (uint8_t *out) const |
| | Write the 10 bytes.
|
| bool | toUnixMs (uint64_t &unixMs) const |
| | The time in ms since 1970-01-01.
|
|
| 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 reason: this is accepted.
|
|
static TinyCTSCurrentTime | fromUnixMs (uint64_t unixMs, uint8_t reason=0) |
| | The characteristic for a time in ms since 1970-01-01.
|
|
|
uint8_t | adjustReason = 0 |
| | bits of AdjustReason
|
|
uint8_t | day = 0 |
| | 1-31, 0 = unknown
|
|
uint8_t | dayOfWeek = 0 |
| | 1 = Monday ... 7 = Sunday, 0 = unknown
|
|
uint8_t | fractions256 = 0 |
| | 1/256 seconds
|
|
uint8_t | hours = 0 |
| | 0-23
|
|
uint8_t | minutes = 0 |
| | 0-59
|
|
uint8_t | month = 0 |
| | 1-12, 0 = unknown
|
|
uint8_t | seconds = 0 |
| | 0-59
|
|
uint16_t | year = 0 |
| | 1582-9999, 0 = unknown
|
|
|
static constexpr size_t | Size = 10 |
| | Size of the encoded characteristic.
|
The Current Time characteristic (0x2A2B): 10 bytes with the date and time (Exact Time 256), the day of week, fractions of a second and the reason for the last adjustment.
Use fromUnixMs() and toUnixMs() to convert from and to the time in milliseconds since 1970-01-01. The conversion does not use the time zone: it is up to the user of the library if the date and time are UTC (default) or the local time (see TinyCTSServer::setTimeIsLocal()).
◆ decode()
| bool tiny_cts::TinyCTSCurrentTime::decode |
( |
const uint8_t * | data, |
|
|
size_t | len, |
|
|
TinyCTSCurrentTime & | t ) |
|
inlinestatic |
Read the characteristic. Some devices send the 9 bytes of the Exact Time 256 without the adjust reason: this is accepted.
- Returns
- false if the data is too short.
◆ encode()
| size_t tiny_cts::TinyCTSCurrentTime::encode |
( |
uint8_t * | out | ) |
const |
|
inline |
Write the 10 bytes.
- Returns
- 10
◆ toUnixMs()
| bool tiny_cts::TinyCTSCurrentTime::toUnixMs |
( |
uint64_t & | unixMs | ) |
const |
|
inline |
The time in ms since 1970-01-01.
- Parameters
-
- Returns
- false if the date is unknown or invalid (before 1970 included).
The documentation for this class was generated from the following file: