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