ESPHome  2022.6.2
am43.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.h:32
const float DATA
For components that import data from directly connected sensors like DHT.
Definition: component.cpp:18
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.cpp:26
bool logged_in_
Definition: am43.h:33
This class simplifies creating components that periodically check a state.
Definition: component.h:266
void set_battery(sensor::Sensor *battery)
Definition: am43.h:26
uint8_t current_sensor_
Definition: am43.h:36
uint8_t last_battery_update_
Definition: am43.h:39
void update() override
Definition: am43.cpp:96
void dump_config() override
Definition: am43.cpp:12
void set_illuminance(sensor::Sensor *illuminance)
Definition: am43.h:27
sensor::Sensor * battery_
Definition: am43.h:34
sensor::Sensor * illuminance_
Definition: am43.h:35
Definition: a4988.cpp:4
void setup() override
Definition: am43.cpp:18
Base-class for all sensors.
Definition: sensor.h:47
std::unique_ptr< Am43Encoder > encoder_
Definition: am43.h:31
float get_setup_priority() const override
Definition: am43.h:25
uint16_t char_handle_
Definition: am43.h:30