+
+ uint8_t bits[COTAG_BITS] = {0};
+ size_t bitlen = COTAG_BITS;
+ memcpy(bits, DemodBuffer, COTAG_BITS);
+
+ int err = manrawdecode(bits, &bitlen, 1);
+ if (err){
+ if (g_debugMode) PrintAndLog("DEBUG: Error - COTAG too many errors: %d", err);
+ return -1;
+ }
+
+ setDemodBuf(bits, bitlen, 0);
+
+ //got a good demod
+ uint16_t cn = bytebits_to_byteLSBF(bits+1, 16);
+ uint32_t fc = bytebits_to_byteLSBF(bits+1+16, 8);
+
+ /*
+ fc 161: 1010 0001 -> LSB 1000 0101
+ cn 33593 1000 0011 0011 1001 -> LSB 1001 1100 1100 0001
+ cccc cccc cccc cccc ffffffff
+ 0 1001 1100 1100 0001 1000 0101 0000 0000 100001010000000001111011100000011010000010000000000000000000000000000000000000000000000000000000100111001100000110000101000
+ 1001 1100 1100 0001 10000101
+ */
+ //PrintAndLog("COTAG Found: FC %u, CN: %u Raw: %08X%08X%08X", fc, cn); //, raw1 ,raw2, raw3);
+ PrintAndLog("COTAG Found: FC %u, CN: %u", fc, cn);
+ return 1;