+ // add formatlength
+ num_to_bytebits(fmtlen, 8, pre);
+
+ // add facilitycode, cardnumber and wiegand parity bits
+ if ( fmtlen == 26 ) {
+ uint8_t wiegand[24];
+ num_to_bytebits(fc, 8, wiegand);
+ num_to_bytebits(cn, 16, wiegand+8);
+ wiegand_add_parity(pre+8, wiegand, sizeof(wiegand));
+ } else {
+ uint8_t wiegand[48];
+ num_to_bytebits(fc, 16, wiegand);
+ num_to_bytebits(cn, 32, wiegand+16);
+ wiegand_add_parity(pre+8, wiegand, sizeof(wiegand));
+ }
+
+ // add AWID 4bit parity
+ size_t bitLen = addParity(pre, bits+8, 66, 4, 1);