- uint8_t keyCnt=0;
- uint8_t bitCnt=0;
- uint8_t ByteCnt=0;
- size_t startIdx = ans + 6; //start after preamble
- for (size_t idx = 0; idx<size-6; idx++){
- if ((idx+1) % 5 == 0){
- //spacer bit - should be 0
- if (DemodBuffer[startIdx+idx] != 0) {
- if (g_debugMode) PrintAndLog("Error spacer not 0: %d, pos: %d",DemodBuffer[startIdx+idx],startIdx+idx);
+ size_t startIdx = ans + 6; //start after 6 bit preamble
+
+ uint8_t bits_no_spacer[90];
+ //so as to not mess with raw DemodBuffer copy to a new sample array
+ memcpy(bits_no_spacer, DemodBuffer + startIdx, 90);
+ // remove the 18 (90/5=18) parity bits (down to 72 bits (96-6-18=72))
+ size_t bitLen = removeParity(bits_no_spacer, 0, 5, 3, 90); //source, startloc, paritylen, ptype, length_to_run
+ if (bitLen != 72) {
+ if (g_debugMode) PrintAndLog("Error gProxII: spacer removal did not produce 72 bits: %u, start: %u", bitLen, startIdx);