// Indala 26 bit decode // by marshmellow // optional arguments - same as PSKDemod (clock & invert & maxerr) int CmdIndalaDemod(const char *Cmd) { int ans; if (strlen(Cmd) > 0) ans = PSKDemod(Cmd, 0); else //default to RF/32 ans = PSKDemod("32", 0); if (!ans){ PrintAndLogEx(DEBUG, "DEBUG: Error - Indala can't demod signal: %d",ans); return 0; } uint8_t invert = 0; size_t size = DemodBufferLen; int idx = indala64decode(DemodBuffer, &size, &invert); if (idx < 0 || size != 64) { // try 224 indala invert = 0; size = DemodBufferLen; idx = indala224decode(DemodBuffer, &size, &invert); if (idx < 0 || size != 224) { PrintAndLogEx(DEBUG, "DEBUG: Error - Indala wrong size, expected [64|224] got: %d (startindex %i)", size, idx); return -1; } } setDemodBuf(DemodBuffer, size, (size_t)idx); setClockGrid(g_DemodClock, g_DemodStartIdx + (idx * g_DemodClock)); if (invert) { PrintAndLogEx(DEBUG, "DEBUG: Error - Indala had to invert bits"); for (size_t i = 0; i < size; i++) DemodBuffer[i] ^= 1; } //convert UID to HEX uint32_t uid1, uid2, uid3, uid4, uid5, uid6, uid7; uid1 = bytebits_to_byte(DemodBuffer,32); uid2 = bytebits_to_byte(DemodBuffer+32,32); if (DemodBufferLen == 64){ PrintAndLogEx(SUCCESS, "Indala Found - bitlength %d, UID = (0x%x%08x)\n%s", DemodBufferLen, uid1, uid2, sprint_bin_break(DemodBuffer,DemodBufferLen,32) ); } else { uid3 = bytebits_to_byte(DemodBuffer+64,32); uid4 = bytebits_to_byte(DemodBuffer+96,32); uid5 = bytebits_to_byte(DemodBuffer+128,32); uid6 = bytebits_to_byte(DemodBuffer+160,32); uid7 = bytebits_to_byte(DemodBuffer+192,32); PrintAndLogEx(SUCCESS, "Indala Found - bitlength %d, UID = (0x%x%08x%08x%08x%08x%08x%08x)\n%s", DemodBufferLen, uid1, uid2, uid3, uid4, uid5, uid6, uid7, sprint_bin_break(DemodBuffer, DemodBufferLen, 32) ); } if (g_debugMode){ PrintAndLogEx(DEBUG, "DEBUG: Indala - printing demodbuffer:"); printDemodBuff(); } return 1; }
int CmdPSKNexWatch(const char *Cmd) { if (!PSKDemod("", false)) return 0; uint8_t preamble[28] = {0,0,0,0,0,1,0,1,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; size_t startIdx = 0, size = DemodBufferLen; bool invert = false; if (!preambleSearch(DemodBuffer, preamble, sizeof(preamble), &size, &startIdx)){ // if didn't find preamble try again inverting if (!PSKDemod("1", false)) return 0; size = DemodBufferLen; if (!preambleSearch(DemodBuffer, preamble, sizeof(preamble), &size, &startIdx)) return 0; invert = true; } if (size != 128) return 0; setDemodBuf(DemodBuffer, size, startIdx+4); startIdx = 8+32; //4 = extra i added, 8 = preamble, 32 = reserved bits (always 0) //get ID uint32_t ID = 0; for (uint8_t wordIdx=0; wordIdx<4; wordIdx++){ for (uint8_t idx=0; idx<8; idx++){ ID = (ID << 1) | DemodBuffer[startIdx+wordIdx+(idx*4)]; } } //parity check (TBD) //checksum check (TBD) //output PrintAndLog("NexWatch ID: %d", ID); if (invert){ PrintAndLog("Had to Invert - probably NexKey"); for (uint8_t idx=0; idx<size; idx++) DemodBuffer[idx] ^= 1; } CmdPrintDemodBuff("x"); return 1; }