24#include "../utilities.h"
112 current_ = &data_[DATA_BYTES - 1];
113 mask_ = INITIAL_MASK;
129 return count_ == FRAME_BITS;
146 uint32_t data = data24_;
149 if (parity1_ != parity(PARITY1_HIGH_BIT_INDEX, data))
return false;
152 if (parity2_ == parity(PARITY2_HIGH_BIT_INDEX, data))
return false;
190 if (count_ == PARITY1_BIT_FRAME_INDEX)
192 else if (count_ == PARITY2_BIT_FRAME_INDEX)
200 mask_ = INITIAL_MASK;
223 if (count_ == PARITY1_BIT_FRAME_INDEX)
226 else if (count_ == PARITY2_BIT_FRAME_INDEX)
236 mask_ = INITIAL_MASK;
246 static constexpr uint8_t FRAME_BITS = 26;
247 static constexpr uint8_t PARITY1_BIT_FRAME_INDEX = 0;
248 static constexpr uint8_t PARITY2_BIT_FRAME_INDEX = 25;
250 static constexpr uint8_t PARITY_BITS_COUNT = 12;
251 static constexpr uint8_t PARITY1_HIGH_BIT_INDEX = 23;
252 static constexpr uint8_t PARITY2_HIGH_BIT_INDEX = 11;
254 static constexpr uint8_t INITIAL_MASK = 0x80;
255 static constexpr uint8_t DATA_BYTES =
DATA_BITS / 8;
257 static bool parity(uint8_t start, uint32_t buffer)
260 uint8_t size = PARITY_BITS_COUNT;
261 uint32_t mask = 1UL << start;
264 if (buffer & mask) ++count;
277 uint8_t data_[DATA_BYTES];
Supporting class for the Wiegand 26 bits protocol (used by many access control devices).
Wiegand()
Construct a new Wiegand instance to be sued by an access control device.
bool available_() const
Check if data is available, i.e.
DATA_TYPE get_data_() const
Get data read from access control device.
static constexpr uint8_t DATA_BITS
The actual number of bits of data in DATA_TYPE.
void reset_()
Reset current read state of this instance.
bool valid_() const
Check if current data is valid, i.e.
void reset()
Reset current read state of this instance.
void on_falling_data0()
Your device shall call this method whenever DATA0 line level is falling to 0, which means a 0 bit mus...
void on_falling_data1()
Your device shall call this method whenever DATA1 line level is falling to 0, which means a 1 bit mus...
uint32_t DATA_TYPE
The data type used to return data read from the access control device.
Defines utility classes to implement various protocols used in several devices, like Wiegand.
Defines all API for all external devices supported by FastArduino.