13 if (frame ==
nullptr) {
15 ESP_LOGV(TAG,
"Skipping byte 0x%02X while looking for header",
byte);
29 uint8_t header = frame[0];
30 uint8_t data_h = frame[1];
31 uint8_t data_l = frame[2];
34 uint8_t computed_checksum = (header + data_h + data_l) & 0xFF;
36 ESP_LOGV(TAG,
"Data: Header=0x%02X, Data_H=0x%02X, Data_L=0x%02X, Checksum=0x%02X", header, data_h, data_l,
checksum);
39 ESP_LOGW(TAG,
"Checksum mismatch: received 0x%02X, expected 0x%02X",
checksum, computed_checksum);
size_t length() const
Number of bytes of the partial frame; 0 after a frame is returned and while looking for a header.
const uint8_t * feed(uint8_t c)
Feed one byte; returns the completed frame, header included, valid until the next call,...
void resync()
For a frame the caller rejected (bad checksum): drop its first byte and realign on a header in the re...
bool parse_data_(const uint8_t *frame)
FrameReader< FRAME_SIZE, HEADER_BYTE > reader_
void dump_config() override
void publish_state(float state)
Publish a new state to the front-end.
bool read_available(F &&on_byte)
Same as read_available_chunks(), calling on_byte(uint8_t) once per byte.
ESPHOME_LOG_TAG(TAG, "ds1603l.sensor")
constexpr uint16_t encode_uint16(uint8_t msb, uint8_t lsb)
Encode a 16-bit value given the most and least significant byte.