6 namespace airthings_wave_plus {
8 static const char *
const TAG =
"airthings_wave_plus";
11 esp_ble_gattc_cb_param_t *param) {
13 case ESP_GATTC_OPEN_EVT: {
14 if (param->open.status == ESP_GATT_OK) {
15 ESP_LOGI(TAG,
"Connected successfully!");
20 case ESP_GATTC_DISCONNECT_EVT: {
21 ESP_LOGW(TAG,
"Disconnected!");
25 case ESP_GATTC_SEARCH_CMPL_EVT: {
40 case ESP_GATTC_READ_CHAR_EVT: {
41 if (param->read.conn_id != this->parent()->get_conn_id())
43 if (param->read.status != ESP_GATT_OK) {
44 ESP_LOGW(TAG,
"Error reading char at handle %d, status=%d", param->read.handle, param->read.status);
47 if (param->read.handle == this->handle_) {
62 ESP_LOGD(TAG,
"version = %d", value->version);
64 if (value->version == 1) {
65 ESP_LOGD(TAG,
"ambient light = %d", value->ambientLight);
88 ESP_LOGE(TAG,
"Invalid payload version (%d != 1, newer version or not a Wave Plus?)", value->version);
102 ESP_LOGW(TAG,
"Reconnecting to device");
106 ESP_LOGW(TAG,
"Connection in progress");
113 ESP_GATT_AUTH_REQ_NONE);
115 ESP_LOGW(TAG,
"Error sending read request for sensor, status=%d",
status);
131 service_uuid_(esp32_ble_tracker::ESPBTUUID::from_raw(SERVICE_UUID)),
sensor::Sensor * radon_sensor_
bool is_valid_co2_value_(uint16_t co2)
std::string to_string() const
void gattc_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_t gattc_if, esp_ble_gattc_cb_param_t *param) override
esp32_ble_tracker::ESPBTUUID sensors_data_characteristic_uuid_
bool is_valid_voc_value_(uint16_t voc)
esp32_ble_tracker::ESPBTUUID service_uuid_
This class simplifies creating components that periodically check a state.
sensor::Sensor * co2_sensor_
void dump_config() override
sensor::Sensor * radon_long_term_sensor_
void set_enabled(bool enabled)
sensor::Sensor * pressure_sensor_
void publish_state(float state)
Publish a new state to the front-end.
void request_read_values_()
sensor::Sensor * temperature_sensor_
sensor::Sensor * humidity_sensor_
BLECharacteristic * get_characteristic(espbt::ESPBTUUID service, espbt::ESPBTUUID chr)
void read_sensors_(uint8_t *value, uint16_t value_len)
sensor::Sensor * tvoc_sensor_
bool is_valid_radon_value_(uint16_t radon)
espbt::ClientState node_state