ESPHome 2026.11.0-dev
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::remote_base {
7
8struct KeeloqData {
9 uint32_t encrypted; // 32 bit encrypted field
10 uint32_t address; // 28 bit serial number
11 uint8_t command; // Button Status S2-S1-S0-S3
12 bool repeat{true}; // Repeated command bit
13 bool vlow; // Battery status bit
14 uint16_t suffix{0}; // Optional bits after the 66-bit HCS301 word
15 uint8_t suffix_bits{0};
16
17 // Jarolift TDEF sends 8 group bits after the 64-bit word where the HCS301 has vlow and repeat.
18 void set_group(uint8_t group) {
19 this->vlow = group & 0x01;
20 this->repeat = group & 0x02;
21 this->suffix = group >> 2;
22 this->suffix_bits = 6;
23 }
24 // Only a Jarolift TDEF frame (suffix_bits == 6) carries a group; check suffix_bits before using it.
25 uint8_t group() const { return static_cast<uint8_t>((this->suffix << 2) | (this->repeat << 1) | this->vlow); }
26
27 bool operator==(const KeeloqData &rhs) const {
28 // 0x10 matches any command. The suffix is not compared: the binary sensor does not take it.
29 if (address != rhs.address) {
30 return false;
31 }
32 return (rhs.command == 0x10 || command == rhs.command);
33 }
34};
35
36class KeeloqProtocol : public RemoteProtocol<KeeloqData> {
37 public:
38 void encode(RemoteTransmitData *dst, const KeeloqData &data);
39 optional<KeeloqData> decode(RemoteReceiveData src);
40 void dump(const KeeloqData &data);
41};
42
43DECLARE_REMOTE_PROTOCOL(Keeloq)
44
45} // namespace esphome::remote_base
void encode(RemoteTransmitData *dst, const KeeloqData &data)
optional< KeeloqData > decode(RemoteReceiveData src)
void dump(const KeeloqData &data)
const void * src
Definition hal.h:68
static void uint32_t
bool operator==(const KeeloqData &rhs) const