9static const char *
const TAG =
"iaqcore";
13static constexpr size_t SENSOR_DATA_LENGTH = 9;
21 SensorData(
const uint8_t *buffer) {
24 this->resistance =
encode_uint32(buffer[3], buffer[4], buffer[5], buffer[6]);
31 ESP_LOGD(TAG, ESP_LOG_MSG_COMM_FAIL);
38 uint8_t buffer[SENSOR_DATA_LENGTH];
41 ESP_LOGD(TAG,
"Read failed");
47 SensorData data(buffer);
49 switch (data.status) {
54 ESP_LOGI(TAG,
"Warming up");
57 ESP_LOGI(TAG,
"Busy");
60 ESP_LOGE(TAG,
"Error");
70 if (this->
co2_ !=
nullptr) {
73 if (this->
tvoc_ !=
nullptr) {
81 if (this->
co2_ !=
nullptr) {
84 if (this->
tvoc_ !=
nullptr) {
90 ESP_LOGCONFIG(TAG,
"AMS iAQ Core:");
92 LOG_UPDATE_INTERVAL(
this);
94 ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
96 LOG_SENSOR(
" ",
"CO2", this->
co2_);
97 LOG_SENSOR(
" ",
"TVOC", this->
tvoc_);
void mark_failed()
Mark this component as failed.
void status_set_warning(const char *message=nullptr)
void status_clear_warning()
ErrorCode write(const uint8_t *data, size_t len) const
writes an array of bytes to a device using an I2CBus
ErrorCode read_register(uint8_t a_register, uint8_t *data, size_t len)
reads an array of bytes from a specific register in the I²C device
void dump_config() override
void publish_state(float state)
Publish a new state to the front-end.
@ ERROR_OK
No error found during execution of method.
Providing packet encoding functions for exchanging data with a remote host.
constexpr uint32_t encode_uint32(uint8_t byte1, uint8_t byte2, uint8_t byte3, uint8_t byte4)
Encode a 32-bit value given four bytes in most to least significant byte order.
constexpr uint16_t encode_uint16(uint8_t msb, uint8_t lsb)
Encode a 16-bit value given the most and least significant byte.