ESPHome 2026.11.0b6
Loading...
Searching...
No Matches
alpha3.h
Go to the documentation of this file.
1#pragma once
2
7
8#ifdef USE_ESP32
9
10#include <esp_gattc_api.h>
11
12namespace esphome::alpha3 {
13
15
16static const espbt::ESPBTUUID ALPHA3_GENI_SERVICE_UUID = espbt::ESPBTUUID::from_uint16(0xfe5d);
17static const espbt::ESPBTUUID ALPHA3_GENI_CHARACTERISTIC_UUID = espbt::ESPBTUUID::from_raw(
18 {0xa9, 0x7b, 0xb8, 0x85, 0x00, 0x1a, 0x28, 0xaa, 0x2a, 0x43, 0x6e, 0x03, 0xd1, 0xff, 0x9c, 0x85});
19static const int16_t GENI_RESPONSE_HEADER_LENGTH = 13;
20static const size_t GENI_RESPONSE_TYPE_LENGTH = 8;
21
22static const uint8_t GENI_RESPONSE_TYPE_FLOW_HEAD[GENI_RESPONSE_TYPE_LENGTH] = {31, 0, 1, 48, 1, 0, 0, 24};
23static const int16_t GENI_RESPONSE_FLOW_OFFSET = 0;
24static const int16_t GENI_RESPONSE_HEAD_OFFSET = 4;
25
26static const uint8_t GENI_RESPONSE_TYPE_POWER[GENI_RESPONSE_TYPE_LENGTH] = {44, 0, 1, 0, 1, 0, 0, 37};
27static const int16_t GENI_RESPONSE_VOLTAGE_AC_OFFSET = 0;
28static const int16_t GENI_RESPONSE_VOLTAGE_DC_OFFSET = 4;
29static const int16_t GENI_RESPONSE_CURRENT_OFFSET = 8;
30static const int16_t GENI_RESPONSE_POWER_OFFSET = 12;
31static const int16_t GENI_RESPONSE_MOTOR_POWER_OFFSET = 16; // not sure
32static const int16_t GENI_RESPONSE_MOTOR_SPEED_OFFSET = 20;
33
35 SUB_SENSOR(flow)
36 SUB_SENSOR(head)
37 SUB_SENSOR(power)
38 SUB_SENSOR(current)
39 SUB_SENSOR(speed)
40 SUB_SENSOR(voltage)
41
42 public:
43 void setup() override;
44 void update() override;
45 void gattc_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_t gattc_if,
46 esp_ble_gattc_cb_param_t *param) override;
47 void dump_config() override;
48
49 protected:
50 uint16_t geni_handle_;
53 uint8_t response_type_[GENI_RESPONSE_TYPE_LENGTH];
54 uint8_t buffer_[4];
55 void extract_publish_sensor_value_(const uint8_t *response, int16_t length, int16_t response_offset,
56 int16_t value_offset, sensor::Sensor *sensor, float factor);
57 void handle_geni_response_(const uint8_t *response, uint16_t length);
58 void send_request_(uint8_t *request, size_t len);
59 bool is_current_response_type_(const uint8_t *response_type);
60};
61} // namespace esphome::alpha3
62
63#endif
virtual void setup()
Where the component's initialization should happen.
Definition component.cpp:84
This class simplifies creating components that periodically check a state.
Definition component.h:532
uint8_t buffer_[4]
Definition alpha3.h:54
void handle_geni_response_(const uint8_t *response, uint16_t length)
Definition alpha3.cpp:56
bool is_current_response_type_(const uint8_t *response_type)
Definition alpha3.cpp:52
uint8_t response_type_[GENI_RESPONSE_TYPE_LENGTH]
Definition alpha3.h:53
void send_request_(uint8_t *request, size_t len)
Definition alpha3.cpp:155
int16_t response_length_
Definition alpha3.h:51
int16_t response_offset_
Definition alpha3.h:52
void extract_publish_sensor_value_(const uint8_t *response, int16_t length, int16_t response_offset, int16_t value_offset, sensor::Sensor *sensor, float factor)
Definition alpha3.cpp:24
uint16_t geni_handle_
Definition alpha3.h:50
Base-class for all sensors.
Definition sensor.h:48
int speed
Definition fan.h:3
const void size_t len
Definition hal.h:68