12static constexpr size_t HEADER_SIZE = 10;
13static constexpr uint8_t FRAME_START_1 = 0xA5;
14static constexpr uint8_t FRAME_START_2 = 0x01;
16static constexpr size_t LEN_POS = 7;
17static constexpr size_t CRC_POS = 8;
18static constexpr size_t MAX_FRAME_SIZE = 255;
20static constexpr uint8_t FLAG_NO_ACK = 0x00;
21static constexpr uint8_t FLAG_WANT_ACK = 0x01;
22static constexpr uint8_t TYPE_DATA = 0x21;
23static constexpr uint8_t TYPE_REPLY = 0x23;
25static constexpr uint8_t CLASS_COMMAND = 0x0A;
26static constexpr uint8_t CLASS_NETWORK = 0x0B;
27static constexpr uint8_t CLASS_STATUS = 0x0C;
29static constexpr uint8_t CLASS_REPLY = 0x80;
32static constexpr uint16_t ATTR_POWER = 0x0001;
33static constexpr uint16_t ATTR_SETPOINT_C100 = 0x0002;
34static constexpr uint16_t ATTR_INDOOR_TEMP_C100 = 0x0003;
35static constexpr uint16_t ATTR_FAN_SPEED = 0x0005;
36static constexpr uint16_t ATTR_SWING_VERTICAL = 0x0011;
37static constexpr uint16_t ATTR_MODE = 0x0012;
38static constexpr uint16_t ATTR_ECO = 0x0013;
39static constexpr uint16_t ATTR_DISPLAY = 0x001E;
40static constexpr uint16_t ATTR_BEEPER = 0x0025;
41static constexpr uint16_t ATTR_FAN_AUTO = 0x0073;
42static constexpr uint16_t ATTR_FAN_EXTRA_1 = 0x0224;
43static constexpr uint16_t ATTR_FAN_EXTRA_2 = 0x0225;
44static constexpr uint16_t ATTR_SETPOINT_F = 0x0227;
46static constexpr uint8_t SWING_ON = 0x01;
47static constexpr uint8_t SWING_OFF = 0x08;
67 uint16_t
id()
const {
return this->
id_; }
83 uint8_t class_2,
const uint8_t *body,
size_t len);
Walks the attribute list in a status body. Stops at the first ID whose size is unknown.
bool stopped_on_unknown() const
True when the walk stopped early on an ID of unknown size.
bool next()
Moves to the next attribute. Returns false at the end of the body or at an unknown ID.
AttributeReader(const uint8_t *data, size_t len)
std::vector< uint8_t > & out
uint8_t * put_attr(uint8_t *p, uint16_t id, uint8_t value)
Writes a one-byte attribute (2-byte ID, then the value) at p. Returns the new end.
bool checksum_valid(const uint8_t *frame, size_t len)
FrameLengthU8< LengthField{.offset=LEN_POS}> FrameLength
size_t build_frame(uint8_t *out, uint8_t flags, uint8_t type, uint8_t seq, uint8_t ack, uint8_t class_1, uint8_t class_2, const uint8_t *body, size_t len)
Builds a frame into out, which must hold HEADER_SIZE + 2 + len bytes. Returns the frame length.
uint16_t frame_crc(const uint8_t *frame, size_t len)
CRC-16/XMODEM over a whole frame, skipping the two checksum bytes at offset 8.
constexpr uint8_t * put_be16(uint8_t *dst, uint16_t value)
Write the low 16, 24 or 32 bits of value to dst, most significant byte first (be) or least significan...
constexpr uint16_t encode_uint16(uint8_t msb, uint8_t lsb)
Encode a 16-bit value given the most and least significant byte.
Whole-frame length: the field counts every byte of the frame, header included.
FrameFormat option: the shortest frame, when that is more than its header and length field.
offset: where the length field starts, counted from the first header byte.