ESPHome 2025.5.0
Loading...
Searching...
No Matches
keeloq_protocol.h
Go to the documentation of this file.
1#pragma once
2
4#include "remote_base.h"
5
6namespace esphome {
7namespace remote_base {
8
9struct KeeloqData {
10 uint32_t encrypted; // 32 bit encrypted field
11 uint32_t address; // 28 bit serial number
12 uint8_t command; // Button Status S2-S1-S0-S3
13 bool repeat; // Repeated command bit
14 bool vlow; // Battery status bit
15
16 bool operator==(const KeeloqData &rhs) const {
17 // Treat 0x10 as a special, wildcard button press
18 // This allows us to match on just the address if wanted.
19 if (address != rhs.address) {
20 return false;
21 }
22 return (rhs.command == 0x10 || command == rhs.command);
23 }
24};
25
26class KeeloqProtocol : public RemoteProtocol<KeeloqData> {
27 public:
28 void encode(RemoteTransmitData *dst, const KeeloqData &data) override;
30 void dump(const KeeloqData &data) override;
31};
32
33DECLARE_REMOTE_PROTOCOL(Keeloq)
34
35template<typename... Ts> class KeeloqAction : public RemoteTransmitterActionBase<Ts...> {
36 public:
37 TEMPLATABLE_VALUE(uint32_t, address)
38 TEMPLATABLE_VALUE(uint32_t, encrypted)
39 TEMPLATABLE_VALUE(uint8_t, command)
40 TEMPLATABLE_VALUE(bool, vlow)
41
42 void encode(RemoteTransmitData *dst, Ts... x) override {
43 KeeloqData data{};
44 data.address = this->address_.value(x...);
45 data.encrypted = this->encrypted_.value(x...);
46 data.command = this->command_.value(x...);
47 data.vlow = this->vlow_.value(x...);
48 KeeloqProtocol().encode(dst, data);
49 }
50};
51
52} // namespace remote_base
53} // namespace esphome
uint8_t address
Definition bl0906.h:4
void dump(const KeeloqData &data) override
void encode(RemoteTransmitData *dst, const KeeloqData &data) override
optional< KeeloqData > decode(RemoteReceiveData src) override
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7
bool operator==(const KeeloqData &rhs) const
uint16_t x
Definition tt21100.cpp:5