ESPHome  2023.5.5
airthings_wave_plus.h
Go to the documentation of this file.
1 #pragma once
2 
3 #ifdef USE_ESP32
4 
5 #include <esp_gattc_api.h>
6 #include <algorithm>
7 #include <iterator>
11 #include "esphome/core/component.h"
12 #include "esphome/core/log.h"
13 
14 namespace esphome {
15 namespace airthings_wave_plus {
16 
17 static const char *const SERVICE_UUID = "b42e1c08-ade7-11e4-89d3-123b93f75cba";
18 static const char *const CHARACTERISTIC_UUID = "b42e2a68-ade7-11e4-89d3-123b93f75cba";
19 
21  public:
23 
24  void dump_config() override;
25  void update() override;
26 
27  void gattc_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_t gattc_if,
28  esp_ble_gattc_cb_param_t *param) override;
29 
31  void set_radon(sensor::Sensor *radon) { radon_sensor_ = radon; }
32  void set_radon_long_term(sensor::Sensor *radon_long_term) { radon_long_term_sensor_ = radon_long_term; }
33  void set_humidity(sensor::Sensor *humidity) { humidity_sensor_ = humidity; }
35  void set_co2(sensor::Sensor *co2) { co2_sensor_ = co2; }
36  void set_tvoc(sensor::Sensor *tvoc) { tvoc_sensor_ = tvoc; }
37 
38  protected:
39  bool is_valid_radon_value_(uint16_t radon);
40  bool is_valid_voc_value_(uint16_t voc);
41  bool is_valid_co2_value_(uint16_t co2);
42 
43  void read_sensors_(uint8_t *value, uint16_t value_len);
44  void request_read_values_();
45 
53 
54  uint16_t handle_;
57 
59  uint8_t version;
60  uint8_t humidity;
61  uint8_t ambientLight;
62  uint8_t unused01;
63  uint16_t radon;
64  uint16_t radon_lt;
65  uint16_t temperature;
66  uint16_t pressure;
67  uint16_t co2;
68  uint16_t voc;
69  };
70 };
71 
72 } // namespace airthings_wave_plus
73 } // namespace esphome
74 
75 #endif // USE_ESP32
float pressure
Definition: qmp6988.h:72
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_
float temperature
Definition: qmp6988.h:71
void set_temperature(sensor::Sensor *temperature)
This class simplifies creating components that periodically check a state.
Definition: component.h:282
void set_radon_long_term(sensor::Sensor *radon_long_term)
Definition: a4988.cpp:4
void read_sensors_(uint8_t *value, uint16_t value_len)
Base-class for all sensors.
Definition: sensor.h:57