14 static const char *
const TAG =
"gcja5";
19 const uint32_t now =
millis();
61 ESP_LOGV(TAG,
"Have 32 bytes but not good data. Skipping.");
72 for (uint8_t i = 1; i < 30; i++)
75 ESP_LOGVV(TAG,
"Checksum packet was (0x%02X), calculated checksum was (0x%02X)", this->
rx_message_[30], crc);
81 return (((uint32_t) this->
rx_message_[start_index + 3]) << 24) |
82 (((uint32_t) this->
rx_message_[start_index + 2]) << 16) |
87 return (((uint32_t) this->
rx_message_[start_index + 1]) << 8) | ((uint32_t) this->
rx_message_[start_index]);
91 ESP_LOGVV(TAG,
"GCJA5 Data: ");
92 for (uint8_t i = 0; i < 32; i++) {
93 ESP_LOGVV(TAG,
" %u: 0b" BYTE_TO_BINARY_PATTERN
" (0x%02X)", i + 1, BYTE_TO_BINARY(this->
rx_message_[i]),
98 ESP_LOGVV(TAG,
"Discarding bad packet - failed checks.");
101 ESP_LOGVV(TAG,
"Good packet found.");
108 ESP_LOGI(TAG,
"GCJA5 Status");
109 ESP_LOGI(TAG,
"Overall Status : %i", (status >> 6) & 0x03);
110 ESP_LOGI(TAG,
"PD Status : %i", (status >> 4) & 0x03);
111 ESP_LOGI(TAG,
"LD Status : %i", (status >> 2) & 0x03);
112 ESP_LOGI(TAG,
"Fan Status : %i", (status >> 0) & 0x03);
void status_set_warning(const char *message="unspecified")
sensor::Sensor * pmc_2_5_sensor_
sensor::Sensor * pmc_10_0_sensor_
uint32_t last_transmission_
uint32_t get_32_bit_uint_(uint8_t start_index)
uint32_t IRAM_ATTR HOT millis()
uint16_t get_16_bit_uint_(uint8_t start_index)
bool read_byte(uint8_t *data)
sensor::Sensor * pmc_5_0_sensor_
void publish_state(float state)
Publish a new state to the front-end.
sensor::Sensor * pm_1_0_sensor_
bool calculate_checksum_()
void dump_config() override
Implementation of SPI Controller mode.
std::vector< uint8_t > rx_message_
sensor::Sensor * pmc_1_0_sensor_
sensor::Sensor * pm_2_5_sensor_
sensor::Sensor * pmc_0_3_sensor_
sensor::Sensor * pmc_0_5_sensor_
sensor::Sensor * pm_10_0_sensor_