- 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));
+ switch (fmtlen) {
+ case 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));
+ break;
+ }
+ case 34:{
+ uint8_t wiegand[32];
+ num_to_bytebits(fc, 8, wiegand);
+ num_to_bytebits(cn, 24, wiegand+8);
+ wiegand_add_parity(pre+8, wiegand, sizeof(wiegand));
+ break;
+ }
+ case 37:{
+ uint8_t wiegand[31];
+ num_to_bytebits(fc, 13, wiegand);
+ num_to_bytebits(cn, 18, wiegand+13);
+ wiegand_add_parity(pre+8, wiegand, sizeof(wiegand));
+ break;
+ }
+ case 50: {
+ 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));
+ break;
+ }