ESPHome 2026.6.0-dev
Loading...
Searching...
No Matches
nec_protocol.h
Go to the documentation of this file.
1#pragma once
2
3#include "remote_base.h"
4
5namespace esphome::remote_base {
6
7struct NECData {
8 uint16_t address;
9 uint16_t command;
11
12 bool operator==(const NECData &rhs) const { return address == rhs.address && command == rhs.command; }
13};
14
15class NECProtocol : public RemoteProtocol<NECData> {
16 public:
17 void encode(RemoteTransmitData *dst, const NECData &data) override;
18 optional<NECData> decode(RemoteReceiveData src) override;
19 void dump(const NECData &data) override;
20};
21
22DECLARE_REMOTE_PROTOCOL(NEC)
23
24template<typename... Ts> class NECAction : public RemoteTransmitterActionBase<Ts...> {
25 public:
26 TEMPLATABLE_VALUE(uint16_t, address)
27 TEMPLATABLE_VALUE(uint16_t, command)
28 TEMPLATABLE_VALUE(uint16_t, command_repeats)
29
30 void encode(RemoteTransmitData *dst, Ts... x) override {
31 NECData data{};
32 data.address = this->address_.value(x...);
33 data.command = this->command_.value(x...);
34 data.command_repeats = this->command_repeats_.value(x...);
35 NECProtocol().encode(dst, data);
36 }
37};
38
39} // namespace esphome::remote_base
uint8_t address
Definition bl0906.h:4
void dump(const NECData &data) override
void encode(RemoteTransmitData *dst, const NECData &data) override
optional< NECData > decode(RemoteReceiveData src) override
const void * src
Definition hal.h:64
bool operator==(const NECData &rhs) const
uint16_t x
Definition tt21100.cpp:5