10static const char *
const TAG =
"a02yyuw.sensor";
16 if (this->
buffer_.empty() && (data != 0xff))
27 float distance = (this->buffer_[1] << 8) + this->buffer_[2];
29 ESP_LOGV(TAG,
"Distance from sensor: %f mm", distance);
33 ESP_LOGW(TAG,
"Invalid data read from sensor: %s",
37 ESP_LOGW(TAG,
"checksum failed: %02x != %02x",
checksum, this->buffer_[3]);
39 this->buffer_.clear();
void dump_config() override
std::vector< uint8_t > buffer_
void publish_state(float state)
Publish a new state to the front-end.
bool read_byte(uint8_t *data)
Providing packet encoding functions for exchanging data with a remote host.
char * format_hex_pretty_to(char *buffer, size_t buffer_size, const uint8_t *data, size_t length, char separator)
Format byte array as uppercase hex to buffer (base implementation).
constexpr size_t format_hex_pretty_size(size_t byte_count)
Calculate buffer size needed for format_hex_pretty_to with separator: "XX:XX:...:XX\0".