move idteck to its own file

This commit is contained in:
Philippe Teuwen
2020-09-28 21:09:26 +02:00
parent a3282b940b
commit 4e10c9ec0a
10 changed files with 178 additions and 107 deletions

View File

@@ -1277,73 +1277,6 @@ int PSKDemod(int clk, int invert, int maxErr, bool verbose) {
return PM3_SUCCESS;
}
int demodIdteck(bool verbose) {
(void) verbose; // unused so far
if (PSKDemod(0, 0, 100, false) != PM3_SUCCESS) {
PrintAndLogEx(DEBUG, "DEBUG: Error - Idteck PSKDemod failed");
return PM3_ESOFT;
}
size_t size = DemodBufferLen;
//get binary from PSK1 wave
int idx = detectIdteck(DemodBuffer, &size);
if (idx < 0) {
if (idx == -1)
PrintAndLogEx(DEBUG, "DEBUG: Error - Idteck: not enough samples");
else if (idx == -2)
PrintAndLogEx(DEBUG, "DEBUG: Error - Idteck: just noise");
else if (idx == -3)
PrintAndLogEx(DEBUG, "DEBUG: Error - Idteck: preamble not found");
else if (idx == -4)
PrintAndLogEx(DEBUG, "DEBUG: Error - Idteck: size not correct: %zu", size);
else
PrintAndLogEx(DEBUG, "DEBUG: Error - Idteck: idx: %d", idx);
// if didn't find preamble try again inverting
if (PSKDemod(0, 1, 100, false) != PM3_SUCCESS) {
PrintAndLogEx(DEBUG, "DEBUG: Error - Idteck PSKDemod failed");
return PM3_ESOFT;
}
idx = detectIdteck(DemodBuffer, &size);
if (idx < 0) {
if (idx == -1)
PrintAndLogEx(DEBUG, "DEBUG: Error - Idteck: not enough samples");
else if (idx == -2)
PrintAndLogEx(DEBUG, "DEBUG: Error - Idteck: just noise");
else if (idx == -3)
PrintAndLogEx(DEBUG, "DEBUG: Error - Idteck: preamble not found");
else if (idx == -4)
PrintAndLogEx(DEBUG, "DEBUG: Error - Idteck: size not correct: %zu", size);
else
PrintAndLogEx(DEBUG, "DEBUG: Error - Idteck: idx: %d", idx);
return PM3_ESOFT;
}
}
setDemodBuff(DemodBuffer, 64, idx);
//got a good demod
uint32_t id = 0;
uint32_t raw1 = bytebits_to_byte(DemodBuffer, 32);
uint32_t raw2 = bytebits_to_byte(DemodBuffer + 32, 32);
//parity check (TBD)
//checksum check (TBD)
//output
PrintAndLogEx(SUCCESS, "IDTECK Tag Found: Card ID %u , Raw: %08X%08X", id, raw1, raw2);
return PM3_SUCCESS;
}
/*
static int CmdIdteckDemod(const char *Cmd) {
(void)Cmd; // Cmd is not used so far
return demodIdteck();
}
*/
// by marshmellow
// takes 3 arguments - clock, invert, maxErr as integers
// attempts to demodulate nrz only