paulo-raca/YetAnotherArduinoWiegandLibrary

How can I extract Facility Code and Card Number ?

MetriciRO opened this issue · 1 comments

First of all, thank you for this library. It worked like a charm right out of the box.

I am reading a RFID card using an ESP32 and a Bosch ARD-AYK12 - RFID Proximity Reader.

I read a card and the ID I get is 0D9030. But the Wiegand access controller returns 000000036912, which, based on this Wiegand calculator, is the Card Number.

How can I get the Card Number and Facility Number separately ?
Thank you.

Hello, I'm glad it worked for you

By convention, the 26-bit wiegand code has 8bits for facility code, 16 bits for the card number and 2 bits for parity (which the library strips automatically.

All you have to do is split the value returned accordingly, something like this

byte[] returnedValue = {0x06, 0x90, 0x30};
uint16_t facility_code = returnedValue[0];
uint16_t card_number = (returnedValue[1] << 8) | returnedValue[2];
--- OR ---
uint32_t returnedValue = 0x069030;
uint16_t facility_code = returnedValue >> 16;
uint16_t card_number = returnedValue & 0xFFFF;