ESPHome 2026.5.0b1
Loading...
Searching...
No Matches
am43_base.h
Go to the documentation of this file.
1#pragma once
2
4#include "esphome/core/log.h"
5
6namespace esphome::am43 {
7
8static const uint16_t AM43_SERVICE_UUID = 0xFE50;
9static const uint16_t AM43_CHARACTERISTIC_UUID = 0xFE51;
10//
11// Tuya identifiers, only to detect and warn users as they are incompatible.
12static const uint16_t AM43_TUYA_SERVICE_UUID = 0x1910;
13static const uint16_t AM43_TUYA_CHARACTERISTIC_UUID = 0x2b11;
14
15struct Am43Packet {
16 uint8_t length;
17 uint8_t data[24];
18};
19
20static const uint8_t CMD_GET_BATTERY_LEVEL = 0xA2;
21static const uint8_t CMD_GET_LIGHT_LEVEL = 0xAA;
22static const uint8_t CMD_GET_POSITION = 0xA7;
23static const uint8_t CMD_SEND_PIN = 0x17;
24static const uint8_t CMD_SET_STATE = 0x0A;
25static const uint8_t CMD_SET_POSITION = 0x0D;
26static const uint8_t CMD_NOTIFY_POSITION = 0xA1;
27
28static const uint8_t RESPONSE_ACK = 0x5A;
29static const uint8_t RESPONSE_NACK = 0xA5;
30
47
49 public:
50 void decode(const uint8_t *data, uint16_t length);
51 bool has_battery_level() { return this->has_battery_level_; }
52 bool has_light_level() { return this->has_light_level_; }
55 bool has_position() { return this->has_position_; }
56 bool has_pin_response() { return this->has_pin_response_; }
57
58 union {
59 uint8_t position_;
64 uint8_t pin_ok_;
65 };
66
67 protected:
74};
75
76} // namespace esphome::am43
void decode(const uint8_t *data, uint16_t length)
Definition am43_base.cpp:76
Am43Packet * get_send_pin_request(uint16_t pin)
Definition am43_base.cpp:24
Am43Packet * get_set_position_request(uint8_t position)
Definition am43_base.cpp:46
Am43Packet * get_open_request()
Definition am43_base.cpp:31
Am43Packet * encode_(uint8_t command, uint8_t *data, uint8_t length)
Definition am43_base.cpp:59
Am43Packet * get_light_level_request()
Definition am43_base.cpp:14
Am43Packet * get_stop_request()
Definition am43_base.cpp:41
Am43Packet * get_position_request()
Definition am43_base.cpp:19
Am43Packet * get_battery_level_request()
Definition am43_base.cpp:9
Am43Packet * get_close_request()
Definition am43_base.cpp:36
float position
Definition cover.h:0
uint16_t length
Definition tt21100.cpp:0