ESPHome 2025.5.0
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 {
6namespace remote_base {
7
8struct NECData {
9 uint16_t address;
10 uint16_t command;
12
13 bool operator==(const NECData &rhs) const { return address == rhs.address && command == rhs.command; }
14};
15
16class NECProtocol : public RemoteProtocol<NECData> {
17 public:
18 void encode(RemoteTransmitData *dst, const NECData &data) override;
20 void dump(const NECData &data) override;
21};
22
23DECLARE_REMOTE_PROTOCOL(NEC)
24
25template<typename... Ts> class NECAction : public RemoteTransmitterActionBase<Ts...> {
26 public:
27 TEMPLATABLE_VALUE(uint16_t, address)
28 TEMPLATABLE_VALUE(uint16_t, command)
29 TEMPLATABLE_VALUE(uint16_t, command_repeats)
30
31 void encode(RemoteTransmitData *dst, Ts... x) override {
32 NECData data{};
33 data.address = this->address_.value(x...);
34 data.command = this->command_.value(x...);
35 data.command_repeats = this->command_repeats_.value(x...);
36 NECProtocol().encode(dst, data);
37 }
38};
39
40} // namespace remote_base
41} // namespace esphome
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
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7
bool operator==(const NECData &rhs) const
uint16_t x
Definition tt21100.cpp:5