ESPHome  2024.10.2
aeha_protocol.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "remote_base.h"
4 
5 #include <vector>
6 
7 namespace esphome {
8 namespace remote_base {
9 
10 struct AEHAData {
11  uint16_t address;
12  std::vector<uint8_t> data;
13 
14  bool operator==(const AEHAData &rhs) const { return address == rhs.address && data == rhs.data; }
15 };
16 
17 class AEHAProtocol : public RemoteProtocol<AEHAData> {
18  public:
19  void encode(RemoteTransmitData *dst, const AEHAData &data) override;
20  optional<AEHAData> decode(RemoteReceiveData src) override;
21  void dump(const AEHAData &data) override;
22 
23  private:
24  std::string format_data_(const std::vector<uint8_t> &data);
25 };
26 
28 
29 template<typename... Ts> class AEHAAction : public RemoteTransmitterActionBase<Ts...> {
30  public:
31  TEMPLATABLE_VALUE(uint16_t, address)
32  TEMPLATABLE_VALUE(std::vector<uint8_t>, data)
33  TEMPLATABLE_VALUE(uint32_t, carrier_frequency);
34 
35  void set_data(const std::vector<uint8_t> &data) { data_ = data; }
36  void encode(RemoteTransmitData *dst, Ts... x) override {
37  AEHAData data{};
38  data.address = this->address_.value(x...);
39  data.data = this->data_.value(x...);
40  dst->set_carrier_frequency(this->carrier_frequency_.value(x...));
41  AEHAProtocol().encode(dst, data);
42  }
43 };
44 
45 } // namespace remote_base
46 } // namespace esphome
bool operator==(const AEHAData &rhs) const
Definition: aeha_protocol.h:14
void set_carrier_frequency(uint32_t carrier_frequency)
Definition: remote_base.h:34
DECLARE_REMOTE_PROTOCOL(AEHA) template< typename... Ts > class AEHAAction
Definition: aeha_protocol.h:27
uint16_t x
Definition: tt21100.cpp:17
std::vector< uint8_t > data
Definition: aeha_protocol.h:12
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7
void encode(RemoteTransmitData *dst, const AEHAData &data) override