ESPHome  2024.10.2
radon_eye_rd200.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 radon_eye_rd200 {
16 
17 static const char *const SERVICE_UUID = "00001523-1212-efde-1523-785feabcd123";
18 static const char *const WRITE_CHARACTERISTIC_UUID = "00001524-1212-efde-1523-785feabcd123";
19 static const char *const READ_CHARACTERISTIC_UUID = "00001525-1212-efde-1523-785feabcd123";
20 
22  public:
23  RadonEyeRD200();
24 
25  void dump_config() override;
26  void update() override;
27 
28  void gattc_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_t gattc_if,
29  esp_ble_gattc_cb_param_t *param) override;
30 
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 
34  protected:
35  bool is_valid_radon_value_(float radon);
36 
37  void read_sensors_(uint8_t *value, uint16_t value_len);
38  void write_query_message_();
39  void request_read_values_();
40 
43 
44  uint16_t read_handle_;
45  uint16_t write_handle_;
49 
50  union RadonValue {
51  char chars[4];
52  float number;
53  };
54 };
55 
56 } // namespace radon_eye_rd200
57 } // namespace esphome
58 
59 #endif // USE_ESP32
void set_radon_long_term(sensor::Sensor *radon_long_term)
esp32_ble_tracker::ESPBTUUID service_uuid_
This class simplifies creating components that periodically check a state.
Definition: component.h:283
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_read_characteristic_uuid_
void set_radon(sensor::Sensor *radon)
esp32_ble_tracker::ESPBTUUID sensors_write_characteristic_uuid_
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7
void read_sensors_(uint8_t *value, uint16_t value_len)
Base-class for all sensors.
Definition: sensor.h:57