ESPHome 2025.9.0-dev
Loading...
Searching...
No Matches
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
13namespace esphome {
14namespace 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 void set_battery(sensor::Sensor *battery) { battery_ = battery; }
26 void set_illuminance(sensor::Sensor *illuminance) { illuminance_ = illuminance; }
27
28 protected:
29 uint16_t char_handle_;
30 std::unique_ptr<Am43Encoder> encoder_;
31 std::unique_ptr<Am43Decoder> decoder_;
36 // The AM43 often gets into a state where it spams loads of battery update
37 // notifications. Here we will limit to no more than every 10s.
39};
40
41} // namespace am43
42} // namespace esphome
43
44#endif
This class simplifies creating components that periodically check a state.
Definition component.h:425
void update() override
std::unique_ptr< Am43Decoder > decoder_
Definition am43_sensor.h:31
void set_battery(sensor::Sensor *battery)
Definition am43_sensor.h:25
void set_illuminance(sensor::Sensor *illuminance)
Definition am43_sensor.h:26
void gattc_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_t gattc_if, esp_ble_gattc_cb_param_t *param) override
sensor::Sensor * illuminance_
Definition am43_sensor.h:34
void setup() override
sensor::Sensor * battery_
Definition am43_sensor.h:33
void dump_config() override
std::unique_ptr< Am43Encoder > encoder_
Definition am43_sensor.h:30
uint8_t last_battery_update_
Definition am43_sensor.h:38
Base-class for all sensors.
Definition sensor.h:59
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7