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