9static const char *
const TAG =
"iaqcore";
19 SensorData(
const uint8_t *buffer) {
22 this->resistance =
encode_uint32(buffer[3], buffer[4], buffer[5], buffer[6]);
29 ESP_LOGD(TAG,
"Communication failed!");
36 uint8_t buffer[
sizeof(SensorData)];
39 ESP_LOGD(TAG,
"Read failed");
45 SensorData data(buffer);
47 switch (data.status) {
52 ESP_LOGI(TAG,
"Warming up");
55 ESP_LOGI(TAG,
"Busy");
58 ESP_LOGE(TAG,
"Error");
68 if (this->
co2_ !=
nullptr) {
71 if (this->
tvoc_ !=
nullptr) {
79 if (this->
co2_ !=
nullptr) {
82 if (this->
tvoc_ !=
nullptr) {
88 ESP_LOGCONFIG(TAG,
"AMS iAQ Core:");
90 LOG_UPDATE_INTERVAL(
this);
92 ESP_LOGE(TAG,
"Communication with AMS iAQ Core failed!");
94 LOG_SENSOR(
" ",
"CO2", this->
co2_);
95 LOG_SENSOR(
" ",
"TVOC", this->
tvoc_);
virtual void mark_failed()
Mark this component as failed.
void status_set_warning(const char *message="unspecified")
void status_clear_warning()
ErrorCode write(const uint8_t *data, size_t len, bool stop=true)
writes an array of bytes to a device using an I2CBus
ErrorCode read_register(uint8_t a_register, uint8_t *data, size_t len, bool stop=true)
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.