9static const char *
const KEYS =
"0123456789*#";
40 uint64_t mask = 1LL << start;
41 for (
int i = 0; i <
length; i++, mask <<= 1) {
50 uint64_t mask = 1LL << start;
51 for (
int i = 0; i <
length; i++, mask <<= 1) {
68 ESP_LOGV(TAG,
"received %d-bit value: %llx",
count, value);
70 trigger->trigger(
count, value);
73 buf_append_printf(tag_buf,
sizeof(tag_buf), 0,
"%" PRIu32,
static_cast<uint32_t>((value >> 1) & 0xffffff));
74 ESP_LOGD(TAG,
"received 26-bit tag: %s", tag_buf);
76 ESP_LOGW(TAG,
"invalid parity");
80 trigger->trigger(tag_buf);
81 }
else if (
count == 34) {
83 buf_append_printf(tag_buf,
sizeof(tag_buf), 0,
"%" PRIu32,
static_cast<uint32_t>((value >> 1) & 0xffffffff));
84 ESP_LOGD(TAG,
"received 34-bit tag: %s", tag_buf);
86 ESP_LOGW(TAG,
"invalid parity");
90 trigger->trigger(tag_buf);
91 }
else if (
count == 37) {
93 buf_append_printf(tag_buf,
sizeof(tag_buf), 0,
"%" PRIu64,
static_cast<uint64_t
>((value >> 1) & 0x7ffffffff));
94 ESP_LOGD(TAG,
"received 37-bit tag: %s", tag_buf);
96 ESP_LOGW(TAG,
"invalid parity");
100 trigger->trigger(tag_buf);
101 }
else if (
count == 4) {
103 trigger->trigger(value);
105 uint8_t
key = KEYS[value];
108 }
else if (
count == 8) {
109 if ((value ^ 0xf0) >> 4 == (value & 0xf)) {
112 trigger->trigger(value);
114 uint8_t
key = KEYS[value];
119 ESP_LOGD(TAG,
"received unknown %d-bit value: %llx",
count, value);
124 ESP_LOGCONFIG(TAG,
"Wiegand reader:");
125 LOG_PIN(
" D0 pin: ", this->
d0_pin_);
126 LOG_PIN(
" D1 pin: ", this->
d1_pin_);
void attach_interrupt(void(*func)(T *), T *arg, gpio::InterruptType type) const
ISRInternalGPIOPin to_isr() const
void send_key_(uint8_t key)
InternalGPIOPin * d1_pin_
void dump_config() override
std::vector< WiegandKeyTrigger * > key_triggers_
InternalGPIOPin * d0_pin_
std::vector< WiegandTagTrigger * > tag_triggers_
std::vector< WiegandRawTrigger * > raw_triggers_
bool check_eparity(uint64_t value, int start, int length)
ESPHOME_LOG_TAG(TAG, "wiegand")
bool check_oparity(uint64_t value, int start, int length)
uint32_t IRAM_ATTR HOT millis()
static void d0_gpio_intr(WiegandStore *arg)
static void d1_gpio_intr(WiegandStore *arg)
volatile uint32_t last_bit_time