ESPHome  2024.10.2
am43_sensor.h
Go to the documentation of this file.
1 #pragma once
2 
8 
9 #ifdef USE_ESP32
10 
11 #include <esp_gattc_api.h>
12 
13 namespace esphome {
14 namespace am43 {
15 
17 
19  public:
20  void setup() override;
21  void update() override;
22  void gattc_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_t gattc_if,
23  esp_ble_gattc_cb_param_t *param) override;
24  void dump_config() override;
25  float get_setup_priority() const override { return setup_priority::DATA; }
26  void set_battery(sensor::Sensor *battery) { battery_ = battery; }
27  void set_illuminance(sensor::Sensor *illuminance) { illuminance_ = illuminance; }
28 
29  protected:
30  uint16_t char_handle_;
31  std::unique_ptr<Am43Encoder> encoder_;
32  std::unique_ptr<Am43Decoder> decoder_;
33  bool logged_in_;
36  uint8_t current_sensor_;
37  // The AM43 often gets into a state where it spams loads of battery update
38  // notifications. Here we will limit to no more than every 10s.
40 };
41 
42 } // namespace am43
43 } // namespace esphome
44 
45 #endif
std::unique_ptr< Am43Decoder > decoder_
Definition: am43_sensor.h:32
const float DATA
For components that import data from directly connected sensors like DHT.
Definition: component.cpp:19
void gattc_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_t gattc_if, esp_ble_gattc_cb_param_t *param) override
Definition: am43_sensor.cpp:26
This class simplifies creating components that periodically check a state.
Definition: component.h:283
void set_battery(sensor::Sensor *battery)
Definition: am43_sensor.h:26
uint8_t current_sensor_
Definition: am43_sensor.h:36
uint8_t last_battery_update_
Definition: am43_sensor.h:39
void update() override
Definition: am43_sensor.cpp:98
void dump_config() override
Definition: am43_sensor.cpp:12
void set_illuminance(sensor::Sensor *illuminance)
Definition: am43_sensor.h:27
sensor::Sensor * battery_
Definition: am43_sensor.h:34
sensor::Sensor * illuminance_
Definition: am43_sensor.h:35
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7
void setup() override
Definition: am43_sensor.cpp:18
Base-class for all sensors.
Definition: sensor.h:57
std::unique_ptr< Am43Encoder > encoder_
Definition: am43_sensor.h:31
float get_setup_priority() const override
Definition: am43_sensor.h:25
uint16_t char_handle_
Definition: am43_sensor.h:30