From dfb7eaf061339b0caab7db8d3f80bdc96e5cc2c3 Mon Sep 17 00:00:00 2001 From: Philippe Teuwen Date: Mon, 28 Sep 2020 11:50:20 +0200 Subject: [PATCH] LF: rework internal APIs --- client/src/cmddata.c | 196 +++++++++++++++------------- client/src/cmddata.h | 15 ++- client/src/cmdlf.c | 44 +++---- client/src/cmdlfawid.c | 17 +-- client/src/cmdlfawid.h | 2 +- client/src/cmdlfcotag.c | 9 +- client/src/cmdlfcotag.h | 2 +- client/src/cmdlfem4x.c | 56 +++++--- client/src/cmdlfem4x.h | 4 +- client/src/cmdlffdx.c | 2 +- client/src/cmdlfgallagher.c | 20 +-- client/src/cmdlfgallagher.h | 2 +- client/src/cmdlfguard.c | 19 +-- client/src/cmdlfguard.h | 2 +- client/src/cmdlfhid.c | 16 ++- client/src/cmdlfhid.h | 2 +- client/src/cmdlfindala.c | 54 +++++--- client/src/cmdlfindala.h | 9 +- client/src/cmdlfio.c | 15 ++- client/src/cmdlfio.h | 2 +- client/src/cmdlfjablotron.c | 20 +-- client/src/cmdlfjablotron.h | 2 +- client/src/cmdlfkeri.c | 18 +-- client/src/cmdlfkeri.h | 2 +- client/src/cmdlfmotorola.c | 20 +-- client/src/cmdlfmotorola.h | 2 +- client/src/cmdlfnedap.c | 19 ++- client/src/cmdlfnedap.h | 2 +- client/src/cmdlfnexwatch.c | 10 +- client/src/cmdlfnexwatch.h | 2 +- client/src/cmdlfnoralsy.c | 19 +-- client/src/cmdlfnoralsy.h | 2 +- client/src/cmdlfpac.c | 18 +-- client/src/cmdlfpac.h | 2 +- client/src/cmdlfparadox.c | 17 ++- client/src/cmdlfparadox.h | 2 +- client/src/cmdlfpresco.c | 20 +-- client/src/cmdlfpresco.h | 2 +- client/src/cmdlfpyramid.c | 16 ++- client/src/cmdlfpyramid.h | 2 +- client/src/cmdlfsecurakey.c | 18 +-- client/src/cmdlfsecurakey.h | 2 +- client/src/cmdlft55xx.c | 75 +++++------ client/src/cmdlfti.c | 14 +- client/src/cmdlfti.h | 2 +- client/src/cmdlfverichip_disabled.c | 18 +-- client/src/cmdlfverichip_disabled.h | 2 +- client/src/cmdlfviking.c | 18 ++- client/src/cmdlfviking.h | 2 +- client/src/cmdlfvisa2000.c | 17 ++- client/src/cmdlfvisa2000.h | 2 +- 51 files changed, 468 insertions(+), 387 deletions(-) diff --git a/client/src/cmddata.c b/client/src/cmddata.c index d85733370..ffeb7f965 100644 --- a/client/src/cmddata.c +++ b/client/src/cmddata.c @@ -557,27 +557,11 @@ static int CmdConvertBitStream(const char *Cmd) { //verbose will print results and demoding messages //emSearch will auto search for EM410x format in bitstream //askType switches decode: ask/raw = 0, ask/manchester = 1 -int ASKDemod_ext(const char *Cmd, bool verbose, bool emSearch, uint8_t askType, bool *stCheck) { - int invert = 0; - int clk = 0; - int maxErr = 100; - size_t maxLen = 0; +int ASKDemod_ext(int clk, int invert, int maxErr, size_t maxLen, bool amplify, bool verbose, bool emSearch, uint8_t askType, bool *stCheck) { uint8_t askamp = 0; - char amp = tolower(param_getchar(Cmd, 0)); - - sscanf(Cmd, "%i %i %i %zu %c", &clk, &invert, &maxErr, &maxLen, &); if (!maxLen) maxLen = pm3_capabilities.bigbuf_size; - if (invert != 0 && invert != 1) { - PrintAndLogEx(WARNING, "Invalid argument: %s", Cmd); - return PM3_EINVARG; - } - - if (clk == 1) { - invert = 1; - clk = 0; - } uint8_t *bits = calloc(MAX_GRAPH_TRACE_LEN, sizeof(uint8_t)); if (bits == NULL) { return PM3_EMALLOC; @@ -597,7 +581,7 @@ int ASKDemod_ext(const char *Cmd, bool verbose, bool emSearch, uint8_t askType, int foundclk = 0; //amplify signal before ST check - if (amp == 'a') { + if (amplify) { askAmp(bits, BitLen); } @@ -658,9 +642,9 @@ int ASKDemod_ext(const char *Cmd, bool verbose, bool emSearch, uint8_t askType, free(bits); return PM3_SUCCESS; } -int ASKDemod(const char *Cmd, bool verbose, bool emSearch, uint8_t askType) { +int ASKDemod(int clk, int invert, int maxErr, size_t maxLen, bool amplify, bool verbose, bool emSearch, uint8_t askType) { bool st = false; - return ASKDemod_ext(Cmd, verbose, emSearch, askType, &st); + return ASKDemod_ext(clk, invert, maxErr, maxLen, amplify, verbose, emSearch, askType, &st); } //by marshmellow @@ -670,19 +654,36 @@ int ASKDemod(const char *Cmd, bool verbose, bool emSearch, uint8_t askType) { static int Cmdaskmandemod(const char *Cmd) { char cmdp = tolower(param_getchar(Cmd, 0)); if (strlen(Cmd) > 45 || cmdp == 'h') return usage_data_rawdemod_am(); - - bool st = true; - if (Cmd[0] == 's') - return ASKDemod_ext(Cmd++, true, true, 1, &st); - else if (Cmd[1] == 's') - return ASKDemod_ext(Cmd += 2, true, true, 1, &st); - - return ASKDemod(Cmd, true, true, 1); + bool st = false; + if (Cmd[0] == 's') { + st = true; + Cmd++; + } else if (Cmd[1] == 's') { + st = true; + Cmd+=2; + } + int clk = 0; + int invert = 0; + int maxErr = 100; + size_t maxLen = 0; + bool amplify = false; + char amp = tolower(param_getchar(Cmd, 0)); + sscanf(Cmd, "%i %i %i %zu %c", &clk, &invert, &maxErr, &maxLen, &); + amplify = amp == 'a'; + if (clk == 1) { + invert = 1; + clk = 0; + } + if (invert != 0 && invert != 1) { + PrintAndLogEx(WARNING, "Invalid value for invert: %i", invert); + return PM3_EINVARG; + } + return ASKDemod_ext(clk, invert, maxErr, maxLen, amplify, true, true, 1, &st); } //by marshmellow //manchester decode -//stricktly take 10 and 01 and convert to 0 and 1 +//strictly take 10 and 01 and convert to 0 and 1 static int Cmdmandecoderaw(const char *Cmd) { size_t size = 0; int high = 0, low = 0; @@ -785,10 +786,8 @@ static int CmdBiphaseDecodeRaw(const char *Cmd) { //by marshmellow // - ASK Demod then Biphase decode GraphBuffer samples -int ASKbiphaseDemod(const char *Cmd, bool verbose) { +int ASKbiphaseDemod(int offset, int clk, int invert, int maxErr, bool verbose) { //ask raw demod GraphBuffer first - int offset = 0, clk = 0, invert = 0, maxErr = 50; - sscanf(Cmd, "%i %i %i %i", &offset, &clk, &invert, &maxErr); uint8_t BitStream[MAX_DEMOD_BUF_LEN]; size_t size = getFromGraphBuf(BitStream); @@ -828,16 +827,33 @@ int ASKbiphaseDemod(const char *Cmd, bool verbose) { static int Cmdaskbiphdemod(const char *Cmd) { char cmdp = tolower(param_getchar(Cmd, 0)); if (strlen(Cmd) > 25 || cmdp == 'h') return usage_data_rawdemod_ab(); - - return ASKbiphaseDemod(Cmd, true); + int offset = 0, clk = 0, invert = 0, maxErr = 50; + sscanf(Cmd, "%i %i %i %i", &offset, &clk, &invert, &maxErr); + return ASKbiphaseDemod(offset, clk, invert, maxErr, true); } //by marshmellow - see ASKDemod static int Cmdaskrawdemod(const char *Cmd) { char cmdp = tolower(param_getchar(Cmd, 0)); if (strlen(Cmd) > 25 || cmdp == 'h') return usage_data_rawdemod_ar(); - - return ASKDemod(Cmd, true, false, 0); + bool st = false; + int clk = 0; + int invert = 0; + int maxErr = 100; + size_t maxLen = 0; + bool amplify = false; + char amp = tolower(param_getchar(Cmd, 0)); + sscanf(Cmd, "%i %i %i %zu %c", &clk, &invert, &maxErr, &maxLen, &); + amplify = amp == 'a'; + if (clk == 1) { + invert = 1; + clk = 0; + } + if (invert != 0 && invert != 1) { + PrintAndLogEx(WARNING, "Invalid value for invert: %i", invert); + return PM3_EINVARG; + } + return ASKDemod_ext(clk, invert, maxErr, maxLen, amplify, true, false, 0, &st); } int AutoCorrelate(const int *in, int *out, size_t len, size_t window, bool SaveGrph, bool verbose) { @@ -1140,24 +1156,8 @@ static char *GetFSKType(uint8_t fchigh, uint8_t fclow, uint8_t invert) { //fsk raw demod and print binary //takes 4 arguments - Clock, invert, fchigh, fclow //defaults: clock = 50, invert=1, fchigh=10, fclow=8 (RF/10 RF/8 (fsk2a)) -int FSKrawDemod(const char *Cmd, bool verbose) { +int FSKrawDemod(uint8_t rfLen, uint8_t invert, uint8_t fchigh, uint8_t fclow, bool verbose) { //raw fsk demod no manchester decoding no start bit finding just get binary from wave - uint8_t rfLen, invert, fchigh, fclow; - - //set defaults - //set options from parameters entered with the command - rfLen = param_get8(Cmd, 0); - invert = param_get8(Cmd, 1); - fchigh = param_get8(Cmd, 2); - fclow = param_get8(Cmd, 3); - - if (strlen(Cmd) > 0 && strlen(Cmd) <= 2) { - if (rfLen == 1) { - invert = 1; //if invert option only is used - rfLen = 0; - } - } - if (getSignalProperties()->isnoise) return PM3_ESOFT; @@ -1218,26 +1218,27 @@ out: static int CmdFSKrawdemod(const char *Cmd) { char cmdp = tolower(param_getchar(Cmd, 0)); if (strlen(Cmd) > 20 || cmdp == 'h') return usage_data_rawdemod_fs(); + uint8_t rfLen, invert, fchigh, fclow; - return FSKrawDemod(Cmd, true); + //set defaults + //set options from parameters entered with the command + rfLen = param_get8(Cmd, 0); + invert = param_get8(Cmd, 1); + fchigh = param_get8(Cmd, 2); + fclow = param_get8(Cmd, 3); + + if (strlen(Cmd) > 0 && strlen(Cmd) <= 2) { + if (rfLen == 1) { + invert = 1; //if invert option only is used + rfLen = 0; + } + } + return FSKrawDemod(rfLen, invert, fchigh, fclow, true); } //by marshmellow //attempt to psk1 demod graph buffer -int PSKDemod(const char *Cmd, bool verbose) { - int invert = 0, clk = 0, maxErr = 100; - - sscanf(Cmd, "%i %i %i", &clk, &invert, &maxErr); - - if (clk == 1) { - invert = 1; - clk = 0; - } - if (invert != 0 && invert != 1) { - if (g_debugMode || verbose) PrintAndLogEx(WARNING, "Invalid argument: %s", Cmd); - return PM3_EINVARG; - } - +int PSKDemod(int clk, int invert, int maxErr, bool verbose) { if (getSignalProperties()->isnoise) return PM3_ESOFT; @@ -1276,9 +1277,9 @@ int PSKDemod(const char *Cmd, bool verbose) { return PM3_SUCCESS; } -int demodIdteck(void) { - - if (PSKDemod("", false) != 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; } @@ -1300,7 +1301,7 @@ int demodIdteck(void) { PrintAndLogEx(DEBUG, "DEBUG: Error - Idteck: idx: %d", idx); // if didn't find preamble try again inverting - if (PSKDemod("1", false) != PM3_SUCCESS) { + if (PSKDemod(0, 1, 100, false) != PM3_SUCCESS) { PrintAndLogEx(DEBUG, "DEBUG: Error - Idteck PSKDemod failed"); return PM3_ESOFT; } @@ -1347,20 +1348,9 @@ static int CmdIdteckDemod(const char *Cmd) { // takes 3 arguments - clock, invert, maxErr as integers // attempts to demodulate nrz only // prints binary found and saves in demodbuffer for further commands -int NRZrawDemod(const char *Cmd, bool verbose) { +int NRZrawDemod(int clk, int invert, int maxErr, bool verbose) { int errCnt = 0, clkStartIdx = 0; - int invert = 0, clk = 0, maxErr = 100; - sscanf(Cmd, "%i %i %i", &clk, &invert, &maxErr); - if (clk == 1) { - invert = 1; - clk = 0; - } - - if (invert != 0 && invert != 1) { - PrintAndLogEx(WARNING, "(NRZrawDemod) Invalid argument: %s", Cmd); - return PM3_EINVARG; - } if (getSignalProperties()->isnoise) return PM3_ESOFT; @@ -1409,8 +1399,18 @@ int NRZrawDemod(const char *Cmd, bool verbose) { static int CmdNRZrawDemod(const char *Cmd) { char cmdp = tolower(param_getchar(Cmd, 0)); if (strlen(Cmd) > 16 || cmdp == 'h') return usage_data_rawdemod_nr(); + int invert = 0, clk = 0, maxErr = 100; + sscanf(Cmd, "%i %i %i", &clk, &invert, &maxErr); + if (clk == 1) { + invert = 1; + clk = 0; + } - return NRZrawDemod(Cmd, true); + if (invert != 0 && invert != 1) { + PrintAndLogEx(WARNING, "(NRZrawDemod) Invalid argument: %s", Cmd); + return PM3_EINVARG; + } + return NRZrawDemod(clk, invert, maxErr, true); } // by marshmellow @@ -1420,8 +1420,17 @@ static int CmdNRZrawDemod(const char *Cmd) { int CmdPSK1rawDemod(const char *Cmd) { char cmdp = tolower(param_getchar(Cmd, 0)); if (strlen(Cmd) > 16 || cmdp == 'h') return usage_data_rawdemod_p1(); - - int ans = PSKDemod(Cmd, true); + int clk = 0, invert = 0, maxErr = 100; + sscanf(Cmd, "%i %i %i", &clk, &invert, &maxErr); + if (clk == 1) { + invert = 1; + clk = 0; + } + if (invert != 0 && invert != 1) { + PrintAndLogEx(WARNING, "Invalid value for invert: %i", invert); + return PM3_EINVARG; + } + int ans = PSKDemod(clk, invert, maxErr, true); //output if (ans != PM3_SUCCESS) { if (g_debugMode) PrintAndLogEx(ERR, "Error demoding: %d", ans); @@ -1438,8 +1447,17 @@ int CmdPSK1rawDemod(const char *Cmd) { static int CmdPSK2rawDemod(const char *Cmd) { char cmdp = tolower(param_getchar(Cmd, 0)); if (strlen(Cmd) > 16 || cmdp == 'h') return usage_data_rawdemod_p2(); - - int ans = PSKDemod(Cmd, true); + int clk = 0, invert = 0, maxErr = 100; + sscanf(Cmd, "%i %i %i", &clk, &invert, &maxErr); + if (clk == 1) { + invert = 1; + clk = 0; + } + if (invert != 0 && invert != 1) { + PrintAndLogEx(WARNING, "Invalid value for invert: %i", invert); + return PM3_EINVARG; + } + int ans = PSKDemod(clk, invert, maxErr, true); if (ans != PM3_SUCCESS) { if (g_debugMode) PrintAndLogEx(ERR, "Error demoding: %d", ans); return PM3_ESOFT; diff --git a/client/src/cmddata.h b/client/src/cmddata.h index acda950a5..aecce229a 100644 --- a/client/src/cmddata.h +++ b/client/src/cmddata.h @@ -59,12 +59,13 @@ int CmdNorm(const char *Cmd); int CmdPlot(const char *Cmd); // used by cmd lf cotag int CmdSave(const char *Cmd); // used by cmd auto int CmdTuneSamples(const char *Cmd); // used by cmd lf hw -int ASKbiphaseDemod(const char *Cmd, bool verbose); // used by cmd lf em4x, lf fdx, lf guard, lf jablotron, lf nedap, lf t55xx -int ASKDemod(const char *Cmd, bool verbose, bool emSearch, uint8_t askType); // used by cmd lf em4x, lf t55xx, lf viking -int ASKDemod_ext(const char *Cmd, bool verbose, bool emSearch, uint8_t askType, bool *stCheck); // used by cmd lf, lf em4x, lf noralsy, le presco, lf securekey, lf t55xx, lf visa2k -int FSKrawDemod(const char *Cmd, bool verbose); // used by cmd lf, lf em4x, lf t55xx -int PSKDemod(const char *Cmd, bool verbose); // used by cmd lf em4x, lf indala, lf keri, lf nexwatch, lf t55xx -int NRZrawDemod(const char *Cmd, bool verbose); // used by cmd lf pac, lf t55xx + +int ASKbiphaseDemod(int offset, int clk, int invert, int maxErr, bool verbose); // used by cmd lf em4x, lf fdx, lf guard, lf jablotron, lf nedap, lf t55xx +int ASKDemod(int clk, int invert, int maxErr, size_t maxLen, bool amplify, bool verbose, bool emSearch, uint8_t askType); // used by cmd lf em4x, lf t55xx, lf viking +int ASKDemod_ext(int clk, int invert, int maxErr, size_t maxLen, bool amplify, bool verbose, bool emSearch, uint8_t askType, bool *stCheck); // used by cmd lf, lf em4x, lf noralsy, le presco, lf securekey, lf t55xx, lf visa2k +int FSKrawDemod(uint8_t rfLen, uint8_t invert, uint8_t fchigh, uint8_t fclow, bool verbose); // used by cmd lf, lf em4x, lf t55xx +int PSKDemod(int clk, int invert, int maxErr, bool verbose); // used by cmd lf em4x, lf indala, lf keri, lf nexwatch, lf t55xx +int NRZrawDemod(int clk, int invert, int maxErr, bool verbose); // used by cmd lf pac, lf t55xx void printDemodBuff(void); @@ -79,7 +80,7 @@ int getSamplesEx(uint32_t start, uint32_t end, bool verbose); void setClockGrid(uint32_t clk, int offset); int directionalThreshold(const int *in, int *out, size_t len, int8_t up, int8_t down); int AskEdgeDetect(const int *in, int *out, int len, int threshold); -int demodIdteck(void); +int demodIdteck(bool verbose); #define MAX_DEMOD_BUF_LEN (1024*128) extern uint8_t DemodBuffer[MAX_DEMOD_BUF_LEN]; diff --git a/client/src/cmdlf.c b/client/src/cmdlf.c index bcc980db4..113ca90be 100644 --- a/client/src/cmdlf.c +++ b/client/src/cmdlf.c @@ -1445,27 +1445,27 @@ int CmdLFfind(const char *Cmd) { } } - if (demodVisa2k() == PM3_SUCCESS) { PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("Visa2000 ID") " found!"); goto out;} - if (demodHID() == PM3_SUCCESS) { PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("HID Prox ID") " found!"); goto out;} - if (demodAWID() == PM3_SUCCESS) { PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("AWID ID") " found!"); goto out;} - if (demodIOProx() == PM3_SUCCESS) { PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("IO Prox ID") " found!"); goto out;} - if (demodParadox() == PM3_SUCCESS) { PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("Paradox ID") " found!"); goto out;} - if (demodNexWatch() == PM3_SUCCESS) { PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("NexWatch ID") " found!"); goto out;} - if (demodIndala() == PM3_SUCCESS) { PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("Indala ID") " found!"); goto out;} - if (demodEM410x() == PM3_SUCCESS) { PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("EM410x ID") " found!"); goto out;} + if (demodVisa2k(true) == PM3_SUCCESS) { PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("Visa2000 ID") " found!"); goto out;} + if (demodHID(true) == PM3_SUCCESS) { PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("HID Prox ID") " found!"); goto out;} + if (demodAWID(true) == PM3_SUCCESS) { PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("AWID ID") " found!"); goto out;} + if (demodIOProx(true) == PM3_SUCCESS) { PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("IO Prox ID") " found!"); goto out;} + if (demodParadox(true) == PM3_SUCCESS) { PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("Paradox ID") " found!"); goto out;} + if (demodNexWatch(true) == PM3_SUCCESS) { PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("NexWatch ID") " found!"); goto out;} + if (demodIndala(true) == PM3_SUCCESS) { PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("Indala ID") " found!"); goto out;} + if (demodEM410x(true) == PM3_SUCCESS) { PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("EM410x ID") " found!"); goto out;} if (demodFDX(true) == PM3_SUCCESS) { PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("FDX-B ID") " found!"); goto out;} - if (demodGuard() == PM3_SUCCESS) { PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("Guardall G-Prox II ID") " found!"); goto out; } - if (demodIdteck() == PM3_SUCCESS) { PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("Idteck ID") " found!"); goto out;} - if (demodJablotron() == PM3_SUCCESS) { PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("Jablotron ID") " found!"); goto out;} - if (demodNedap() == PM3_SUCCESS) { PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("NEDAP ID") " found!"); goto out;} - if (demodNoralsy() == PM3_SUCCESS) { PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("Noralsy ID") " found!"); goto out;} - if (demodKeri() == PM3_SUCCESS) { PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("KERI ID") " found!"); goto out;} - if (demodPac() == PM3_SUCCESS) { PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("PAC/Stanley ID") " found!"); goto out;} - if (demodPresco() == PM3_SUCCESS) { PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("Presco ID") " found!"); goto out;} - if (demodPyramid() == PM3_SUCCESS) { PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("Pyramid ID") " found!"); goto out;} - if (demodSecurakey() == PM3_SUCCESS) { PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("Securakey ID") " found!"); goto out;} - if (demodViking() == PM3_SUCCESS) { PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("Viking ID") " found!"); goto out;} - if (demodGallagher() == PM3_SUCCESS) { PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("GALLAGHER ID") " found!"); goto out;} + if (demodGuard(true) == PM3_SUCCESS) { PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("Guardall G-Prox II ID") " found!"); goto out; } + if (demodIdteck(true) == PM3_SUCCESS) { PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("Idteck ID") " found!"); goto out;} + if (demodJablotron(true) == PM3_SUCCESS) { PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("Jablotron ID") " found!"); goto out;} + if (demodNedap(true) == PM3_SUCCESS) { PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("NEDAP ID") " found!"); goto out;} + if (demodNoralsy(true) == PM3_SUCCESS) { PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("Noralsy ID") " found!"); goto out;} + if (demodKeri(true) == PM3_SUCCESS) { PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("KERI ID") " found!"); goto out;} + if (demodPac(true) == PM3_SUCCESS) { PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("PAC/Stanley ID") " found!"); goto out;} + if (demodPresco(true) == PM3_SUCCESS) { PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("Presco ID") " found!"); goto out;} + if (demodPyramid(true) == PM3_SUCCESS) { PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("Pyramid ID") " found!"); goto out;} + if (demodSecurakey(true) == PM3_SUCCESS) { PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("Securakey ID") " found!"); goto out;} + if (demodViking(true) == PM3_SUCCESS) { PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("Viking ID") " found!"); goto out;} + if (demodGallagher(true) == PM3_SUCCESS) { PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("GALLAGHER ID") " found!"); goto out;} // if (demodTI() == PM3_SUCCESS) { PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("Texas Instrument ID") " found!"); goto out;} // if (demodFermax() == PM3_SUCCESS) { PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("Fermax ID") " found!"); goto out;} @@ -1486,14 +1486,14 @@ int CmdLFfind(const char *Cmd) { //fsk if (GetFskClock("", false)) { - if (FSKrawDemod("", true) == PM3_SUCCESS) { + if (FSKrawDemod(0, 0, 0, 0, true) == PM3_SUCCESS) { PrintAndLogEx(NORMAL, "\nUnknown FSK Modulated Tag found!"); goto out; } } bool st = true; - if (ASKDemod_ext("0 0 0", true, false, 1, &st) == PM3_SUCCESS) { + if (ASKDemod_ext(0, 0, 0, 0, false, true, false, 1, &st) == PM3_SUCCESS) { PrintAndLogEx(NORMAL, "\nUnknown ASK Modulated and Manchester encoded Tag found!"); PrintAndLogEx(NORMAL, "if it does not look right it could instead be ASK/Biphase - try " _YELLOW_("'data rawdemod ab'")); goto out; diff --git a/client/src/cmdlfawid.c b/client/src/cmdlfawid.c index 765c7e9c6..b22d0adb0 100644 --- a/client/src/cmdlfawid.c +++ b/client/src/cmdlfawid.c @@ -196,9 +196,8 @@ static int CmdAWIDWatch(const char *Cmd) { //by marshmellow //AWID Prox demod - FSK2a RF/50 with preamble of 00000001 (always a 96 bit data stream) //print full AWID Prox ID and some bit format details if found -static int CmdAWIDDemod(const char *Cmd) { - (void)Cmd; // Cmd is not used so far - +int demodAWID(bool verbose) { + (void) verbose; // unused so far uint8_t *bits = calloc(MAX_GRAPH_TRACE_LEN, sizeof(uint8_t)); if (bits == NULL) { PrintAndLogEx(DEBUG, "DEBUG: Error - AWID failed to allocate memory"); @@ -337,10 +336,16 @@ static int CmdAWIDDemod(const char *Cmd) { return PM3_SUCCESS; } +static int CmdAWIDDemod(const char *Cmd) { + (void)Cmd; // Cmd is not used so far + return demodAWID(true); +} + // this read is the "normal" read, which download lf signal and tries to demod here. static int CmdAWIDRead(const char *Cmd) { + (void)Cmd; // Cmd is not used so far lf_read(false, 12000); - return CmdAWIDDemod(Cmd); + return demodAWID(true); } static int CmdAWIDSim(const char *Cmd) { @@ -605,7 +610,3 @@ int getAWIDBits(uint8_t fmtlen, uint32_t fc, uint32_t cn, uint8_t *bits) { return PM3_SUCCESS; } - -int demodAWID(void) { - return CmdAWIDDemod(""); -} diff --git a/client/src/cmdlfawid.h b/client/src/cmdlfawid.h index 80645e9b9..11a235aea 100644 --- a/client/src/cmdlfawid.h +++ b/client/src/cmdlfawid.h @@ -15,7 +15,7 @@ int CmdLFAWID(const char *Cmd); -int demodAWID(void); +int demodAWID(bool verbose); int getAWIDBits(uint8_t fmtlen, uint32_t fc, uint32_t cn, uint8_t *bits); #endif diff --git a/client/src/cmdlfcotag.c b/client/src/cmdlfcotag.c index b0160e335..21a3b5786 100644 --- a/client/src/cmdlfcotag.c +++ b/client/src/cmdlfcotag.c @@ -37,7 +37,8 @@ static int usage_lf_cotag_read(void) { // COTAG demod should be able to use GraphBuffer, // when data load samples -int demodCOTAG(void) { +int demodCOTAG(bool verbose) { + (void) verbose; // unused so far uint8_t bits[COTAG_BITS] = {0}; size_t bitlen = COTAG_BITS; @@ -73,8 +74,8 @@ int demodCOTAG(void) { } static int CmdCOTAGDemod(const char *Cmd) { - (void)Cmd; - return demodCOTAG(); + (void)Cmd; // Cmd is not used so far + return demodCOTAG(true); } // When reading a COTAG. // 0 = HIGH/LOW signal - maxlength bigbuff @@ -118,7 +119,7 @@ static int CmdCOTAGRead(const char *Cmd) { case 1: { memcpy(DemodBuffer, resp.data.asBytes, resp.length); DemodBufferLen = resp.length; - return demodCOTAG(); + return demodCOTAG(true); } } return PM3_SUCCESS; diff --git a/client/src/cmdlfcotag.h b/client/src/cmdlfcotag.h index d7b5bc331..4ebacc37e 100644 --- a/client/src/cmdlfcotag.h +++ b/client/src/cmdlfcotag.h @@ -18,6 +18,6 @@ #endif int CmdLFCOTAG(const char *Cmd); -int demodCOTAG(void); +int demodCOTAG(bool verbose); int readCOTAGUid(void); #endif diff --git a/client/src/cmdlfem4x.c b/client/src/cmdlfem4x.c index 3b00686b1..ae35245ae 100644 --- a/client/src/cmdlfem4x.c +++ b/client/src/cmdlfem4x.c @@ -390,15 +390,14 @@ int AskEm410xDecode(bool verbose, uint32_t *hi, uint64_t *lo) { return PM3_SUCCESS; } -int AskEm410xDemod(const char *Cmd, uint32_t *hi, uint64_t *lo, bool verbose) { +int AskEm410xDemod(int clk, int invert, int maxErr, size_t maxLen, bool amplify, uint32_t *hi, uint64_t *lo, bool verbose) { bool st = true; // em410x simulation etc uses 0/1 as signal data. This must be converted in order to demod it back again if (isGraphBitstream()) { convertGraphFromBitstream(); } - - if (ASKDemod_ext(Cmd, false, false, 1, &st) != PM3_SUCCESS) + if (ASKDemod_ext(clk, invert, maxErr, maxLen, amplify, false, false, 1, &st) != PM3_SUCCESS) return PM3_ESOFT; return AskEm410xDecode(verbose, hi, lo); } @@ -423,14 +422,27 @@ static int CmdEM410xWatch(const char *Cmd) { //takes 3 arguments - clock, invert and maxErr as integers //attempts to demodulate ask while decoding manchester //prints binary found and saves in graphbuffer for further commands +int demodEM410x(bool verbose) { + (void) verbose; // unused so far + uint32_t hi = 0; + uint64_t lo = 0; + return AskEm410xDemod(0, 0, 100, 0, false, &hi, &lo, true); +} + static int CmdEM410xDemod(const char *Cmd) { char cmdp = tolower(param_getchar(Cmd, 0)); if (strlen(Cmd) > 10 || cmdp == 'h') return usage_lf_em410x_demod(); uint32_t hi = 0; uint64_t lo = 0; - - if (AskEm410xDemod(Cmd, &hi, &lo, true) != PM3_SUCCESS) + int clk = 0; + int invert = 0; + int maxErr = 100; + size_t maxLen = 0; + char amp = tolower(param_getchar(Cmd, 0)); + sscanf(Cmd, "%i %i %i %zu %c", &clk, &invert, &maxErr, &maxLen, &); + bool amplify = amp == 'a'; + if (AskEm410xDemod(clk, invert, maxErr, maxLen, amplify, &hi, &lo, true) != PM3_SUCCESS) return PM3_ESOFT; g_em410xid = lo; @@ -439,8 +451,20 @@ static int CmdEM410xDemod(const char *Cmd) { // this read is the "normal" read, which download lf signal and tries to demod here. static int CmdEM410xRead(const char *Cmd) { + char cmdp = tolower(param_getchar(Cmd, 0)); + if (strlen(Cmd) > 10 || cmdp == 'h') return usage_lf_em410x_demod(); + + uint32_t hi = 0; + uint64_t lo = 0; + int clk = 0; + int invert = 0; + int maxErr = 100; + size_t maxLen = 0; + char amp = tolower(param_getchar(Cmd, 0)); + sscanf(Cmd, "%i %i %i %zu %c", &clk, &invert, &maxErr, &maxLen, &); + bool amplify = amp == 'a'; lf_read(false, 12288); - return CmdEM410xDemod(Cmd); + return AskEm410xDemod(clk, invert, maxErr, maxLen, amplify, &hi, &lo, true); } // emulate an EM410X tag @@ -735,7 +759,7 @@ static bool detectFSK(void) { return false; } // demod - int ans = FSKrawDemod("0 0", false); + int ans = FSKrawDemod(0, 0, 0, 0, false); if (ans != PM3_SUCCESS) { PrintAndLogEx(DEBUG, "DEBUG: Error - EM: FSK Demod failed"); return false; @@ -751,12 +775,12 @@ static bool detectPSK(void) { } //demod //try psk1 -- 0 0 6 (six errors?!?) - ans = PSKDemod("0 0 6", false); + ans = PSKDemod(0, 0, 6, false); if (ans != PM3_SUCCESS) { PrintAndLogEx(DEBUG, "DEBUG: Error - EM: PSK1 Demod failed"); //try psk1 inverted - ans = PSKDemod("0 1 6", false); + ans = PSKDemod(0, 1, 6, false); if (ans != PM3_SUCCESS) { PrintAndLogEx(DEBUG, "DEBUG: Error - EM: PSK1 inverted Demod failed"); return false; @@ -769,7 +793,7 @@ static bool detectPSK(void) { // try manchester - NOTE: ST only applies to T55x7 tags. static bool detectASK_MAN(void) { bool stcheck = false; - if (ASKDemod_ext("0 0 0", false, false, 1, &stcheck) != PM3_SUCCESS) { + if (ASKDemod_ext(0, 0, 0, 0, false, false, false, 1, &stcheck) != PM3_SUCCESS) { PrintAndLogEx(DEBUG, "DEBUG: Error - EM: ASK/Manchester Demod failed"); return false; } @@ -777,11 +801,11 @@ static bool detectASK_MAN(void) { } static bool detectASK_BI(void) { - int ans = ASKbiphaseDemod("0 0 1", false); + int ans = ASKbiphaseDemod(0, 0, 1, 50, false); if (ans != PM3_SUCCESS) { PrintAndLogEx(DEBUG, "DEBUG: Error - EM: ASK/biphase normal demod failed"); - ans = ASKbiphaseDemod("0 1 1", false); + ans = ASKbiphaseDemod(0, 1, 1, 50, false); if (ans != PM3_SUCCESS) { PrintAndLogEx(DEBUG, "DEBUG: Error - EM: ASK/biphase inverted demod failed"); return false; @@ -790,11 +814,11 @@ static bool detectASK_BI(void) { return true; } static bool detectNRZ(void) { - int ans = NRZrawDemod("0 0 1", false); + int ans = NRZrawDemod(0, 0, 1, false); if (ans != PM3_SUCCESS) { PrintAndLogEx(DEBUG, "DEBUG: Error - EM: NRZ normal demod failed"); - ans = NRZrawDemod("0 1 1", false); + ans = NRZrawDemod(0, 1, 1, false); if (ans != PM3_SUCCESS) { PrintAndLogEx(DEBUG, "DEBUG: Error - EM: NRZ inverted demod failed"); return false; @@ -1411,7 +1435,3 @@ int CmdLFEM4X(const char *Cmd) { clearCommandBuffer(); return CmdsParse(CommandTable, Cmd); } - -int demodEM410x(void) { - return CmdEM410xDemod(""); -} diff --git a/client/src/cmdlfem4x.h b/client/src/cmdlfem4x.h index 62ecafa23..7dc9a27be 100644 --- a/client/src/cmdlfem4x.h +++ b/client/src/cmdlfem4x.h @@ -15,11 +15,11 @@ int CmdLFEM4X(const char *Cmd); -int demodEM410x(void); +int demodEM410x(bool verbose); bool EM4x05IsBlock0(uint32_t *word); void printEM410x(uint32_t hi, uint64_t id); int AskEm410xDecode(bool verbose, uint32_t *hi, uint64_t *lo); -int AskEm410xDemod(const char *Cmd, uint32_t *hi, uint64_t *lo, bool verbose); +int AskEm410xDemod(int clk, int invert, int maxErr, size_t maxLen, bool amplify, uint32_t *hi, uint64_t *lo, bool verbose); #endif diff --git a/client/src/cmdlffdx.c b/client/src/cmdlffdx.c index 431ec8216..14e6389d5 100644 --- a/client/src/cmdlffdx.c +++ b/client/src/cmdlffdx.c @@ -220,7 +220,7 @@ static int CmdFDXBdemodBI(const char *Cmd) { int demodFDX(bool verbose) { //Differential Biphase / di-phase (inverted biphase) //get binary from ask wave - if (ASKbiphaseDemod("0 32 1 100", false) != PM3_SUCCESS) { + if (ASKbiphaseDemod(0, 32, 1, 100, false) != PM3_SUCCESS) { PrintAndLogEx(DEBUG, "DEBUG: Error - FDX-B ASKbiphaseDemod failed"); return PM3_ESOFT; } diff --git a/client/src/cmdlfgallagher.c b/client/src/cmdlfgallagher.c index 3a717bc61..43db532a9 100644 --- a/client/src/cmdlfgallagher.c +++ b/client/src/cmdlfgallagher.c @@ -67,11 +67,10 @@ static void descramble(uint8_t *arr, uint8_t len) { } //see ASK/MAN Demod for what args are accepted -static int CmdGallagherDemod(const char *Cmd) { - - (void)Cmd; +int demodGallagher(bool verbose) { + (void) verbose; // unused so far bool st = true; - if (ASKDemod_ext("32 0 0 0", false, false, 1, &st) != PM3_SUCCESS) { + if (ASKDemod_ext(32, 0, 100, 0, false, false, false, 1, &st) != PM3_SUCCESS) { PrintAndLogEx(DEBUG, "DEBUG: Error - GALLAGHER: ASKDemod failed"); return PM3_ESOFT; } @@ -134,9 +133,15 @@ static int CmdGallagherDemod(const char *Cmd) { return PM3_SUCCESS; } +static int CmdGallagherDemod(const char *Cmd) { + (void)Cmd; // Cmd is not used so far + return demodGallagher(true); +} + static int CmdGallagherRead(const char *Cmd) { + (void)Cmd; // Cmd is not used so far lf_read(false, 4096 * 2 + 20); - return CmdGallagherDemod(Cmd); + return demodGallagher(true); } static int CmdGallagherClone(const char *Cmd) { @@ -222,8 +227,3 @@ int detectGallagher(uint8_t *dest, size_t *size) { //return start position return (int)startIdx; } - -int demodGallagher(void) { - return CmdGallagherDemod(""); -} - diff --git a/client/src/cmdlfgallagher.h b/client/src/cmdlfgallagher.h index 0ee2a72b3..e3e7a8caa 100644 --- a/client/src/cmdlfgallagher.h +++ b/client/src/cmdlfgallagher.h @@ -14,7 +14,7 @@ int CmdLFGallagher(const char *Cmd); -int demodGallagher(void); +int demodGallagher(bool verbose); int detectGallagher(uint8_t *dest, size_t *size); #endif diff --git a/client/src/cmdlfguard.c b/client/src/cmdlfguard.c index 83a34d5fe..1ab8df3d8 100644 --- a/client/src/cmdlfguard.c +++ b/client/src/cmdlfguard.c @@ -65,12 +65,11 @@ static int usage_lf_guard_sim(void) { //WARNING: if it fails during some points it will destroy the DemodBuffer data // but will leave the GraphBuffer intact. //if successful it will push askraw data back to demod buffer ready for emulation -static int CmdGuardDemod(const char *Cmd) { - (void)Cmd; // Cmd is not used so far - +int demodGuard(bool verbose) { + (void) verbose; // unused so far //Differential Biphase //get binary from ask wave - if (ASKbiphaseDemod("0 64 0 0", false) != PM3_SUCCESS) { + if (ASKbiphaseDemod(0, 64, 0, 0, false) != PM3_SUCCESS) { PrintAndLogEx(DEBUG, "DEBUG: Error - gProxII ASKbiphaseDemod failed"); return PM3_ESOFT; } @@ -150,9 +149,15 @@ static int CmdGuardDemod(const char *Cmd) { return PM3_SUCCESS; } +static int CmdGuardDemod(const char *Cmd) { + (void)Cmd; // Cmd is not used so far + return demodGuard(true); +} + static int CmdGuardRead(const char *Cmd) { + (void)Cmd; // Cmd is not used so far lf_read(false, 10000); - return CmdGuardDemod(Cmd); + return demodGuard(true); } static int CmdGuardClone(const char *Cmd) { @@ -290,10 +295,6 @@ int detectGProxII(uint8_t *bits, size_t *size) { return -5; //spacer bits not found - not a valid gproxII } -int demodGuard(void) { - return CmdGuardDemod(""); -} - // Works for 26bits. int getGuardBits(uint8_t fmtlen, uint32_t fc, uint32_t cn, uint8_t *guardBits) { diff --git a/client/src/cmdlfguard.h b/client/src/cmdlfguard.h index 3d923a7fe..132b45853 100644 --- a/client/src/cmdlfguard.h +++ b/client/src/cmdlfguard.h @@ -13,6 +13,6 @@ int CmdLFGuard(const char *Cmd); int detectGProxII(uint8_t *bits, size_t *size); -int demodGuard(void); +int demodGuard(bool verbose); int getGuardBits(uint8_t fmtlen, uint32_t fc, uint32_t cn, uint8_t *guardBits); #endif diff --git a/client/src/cmdlfhid.c b/client/src/cmdlfhid.c index d73235788..383243523 100644 --- a/client/src/cmdlfhid.c +++ b/client/src/cmdlfhid.c @@ -152,8 +152,8 @@ static int sendTry(uint8_t format_idx, wiegand_card_t *card, uint32_t delay, boo //by marshmellow (based on existing demod + holiman's refactor) //HID Prox demod - FSK RF/50 with preamble of 00011101 (then manchester encoded) //print full HID Prox ID and some bit format details if found -static int CmdHIDDemod(const char *Cmd) { - (void)Cmd; // Cmd is not used so far +int demodHID(bool verbose) { + (void) verbose; // unused so far // HID simulation etc uses 0/1 as signal data. This must be converted in order to demod it back again if (isGraphBitstream()) { @@ -261,10 +261,16 @@ static int CmdHIDDemod(const char *Cmd) { return PM3_SUCCESS; } +static int CmdHIDDemod(const char *Cmd) { + (void)Cmd; // Cmd is not used so far + return demodHID(true); +} + // this read is the "normal" read, which download lf signal and tries to demod here. static int CmdHIDRead(const char *Cmd) { + (void)Cmd; // Cmd is not used so far lf_read(false, 12000); - return CmdHIDDemod(Cmd); + return demodHID(true); } // this read loops on device side. @@ -562,7 +568,3 @@ int CmdLFHID(const char *Cmd) { clearCommandBuffer(); return CmdsParse(CommandTable, Cmd); } - -int demodHID(void) { - return CmdHIDDemod(""); -} diff --git a/client/src/cmdlfhid.h b/client/src/cmdlfhid.h index 5ae2d7753..3c4b6e1f1 100644 --- a/client/src/cmdlfhid.h +++ b/client/src/cmdlfhid.h @@ -15,6 +15,6 @@ int CmdLFHID(const char *Cmd); -int demodHID(void); +int demodHID(bool verbose); #endif diff --git a/client/src/cmdlfindala.c b/client/src/cmdlfindala.c index 94500dbcf..7c29c1eba 100644 --- a/client/src/cmdlfindala.c +++ b/client/src/cmdlfindala.c @@ -151,25 +151,17 @@ static void decodeHeden2L(uint8_t *bits) { // Indala 26 bit decode // by marshmellow, martinbeier // optional arguments - same as PSKDemod (clock & invert & maxerr) -static int CmdIndalaDemod(const char *Cmd) { - - char cmdp = tolower(param_getchar(Cmd, 0)); - if (cmdp == 'h') return usage_lf_indala_demod(); - - int ans; - if (strlen(Cmd) > 0) - ans = PSKDemod(Cmd, true); - else - ans = PSKDemod("32", true); - +int demodIndalaEx(int clk, int invert, int maxErr, bool verbose) { + (void) verbose; // unused so far + int ans = PSKDemod(clk, invert, maxErr, true); if (ans != PM3_SUCCESS) { PrintAndLogEx(DEBUG, "DEBUG: Error - Indala can't demod signal: %d", ans); return PM3_ESOFT; } - uint8_t invert = 0; + uint8_t inv = 0; size_t size = DemodBufferLen; - int idx = detectIndala(DemodBuffer, &size, &invert); + int idx = detectIndala(DemodBuffer, &size, &inv); if (idx < 0) { if (idx == -1) PrintAndLogEx(DEBUG, "DEBUG: Error - Indala: not enough samples"); @@ -281,6 +273,29 @@ static int CmdIndalaDemod(const char *Cmd) { return PM3_SUCCESS; } +int demodIndala(bool verbose) { + return demodIndalaEx(32, 0, 100, verbose); +} + +static int CmdIndalaDemod(const char *Cmd) { + + char cmdp = tolower(param_getchar(Cmd, 0)); + if (cmdp == 'h') return usage_lf_indala_demod(); + + int clk = 32, invert = 0, maxErr = 100; + if (strlen(Cmd) > 0) { + sscanf(Cmd, "%i %i %i", &clk, &invert, &maxErr); + } + if (clk == 1) { + invert = 1; + clk = 0; + } + if (invert != 0 && invert != 1) { + PrintAndLogEx(WARNING, "Invalid value for invert: %i", invert); + return PM3_EINVARG; + } + return demodIndalaEx(clk, invert, maxErr, true); +} // older alternative indala demodulate (has some positives and negatives) // returns false positives more often - but runs against more sets of samples // poor psk signal can be difficult to demod this approach might succeed when the other fails @@ -485,8 +500,15 @@ static int CmdIndalaDemodAlt(const char *Cmd) { // this read is the "normal" read, which download lf signal and tries to demod here. static int CmdIndalaRead(const char *Cmd) { + char cmdp = tolower(param_getchar(Cmd, 0)); + if (cmdp == 'h') return usage_lf_indala_demod(); + + int clk = 32, invert = 0, maxErr = 100; + if (strlen(Cmd) > 0) { + sscanf(Cmd, "%i %i %i", &clk, &invert, &maxErr); + } lf_read(false, 30000); - return CmdIndalaDemod(Cmd); + return demodIndalaEx(clk, invert, maxErr, true); } static int CmdIndalaSim(const char *Cmd) { @@ -865,7 +887,3 @@ out: return (int) idx; } - -int demodIndala(void) { - return CmdIndalaDemod(""); -} diff --git a/client/src/cmdlfindala.h b/client/src/cmdlfindala.h index 65ed29e61..4ae858901 100644 --- a/client/src/cmdlfindala.h +++ b/client/src/cmdlfindala.h @@ -15,10 +15,11 @@ int CmdLFINDALA(const char *Cmd); int detectIndala(uint8_t *dest, size_t *size, uint8_t *invert); -int detectIndala26(uint8_t *bitStream, size_t *size, uint8_t *invert); -int detectIndala64(uint8_t *bitStream, size_t *size, uint8_t *invert); -int detectIndala224(uint8_t *bitStream, size_t *size, uint8_t *invert); -int demodIndala(void); +//int detectIndala26(uint8_t *bitStream, size_t *size, uint8_t *invert); +//int detectIndala64(uint8_t *bitStream, size_t *size, uint8_t *invert); +//int detectIndala224(uint8_t *bitStream, size_t *size, uint8_t *invert); +int demodIndalaEx(int clk, int invert, int maxErr, bool verbose); +int demodIndala(bool verbose); int getIndalaBits(uint8_t fc, uint16_t cn, uint8_t *bits); #endif diff --git a/client/src/cmdlfio.c b/client/src/cmdlfio.c index 1c3b676f6..729970246 100644 --- a/client/src/cmdlfio.c +++ b/client/src/cmdlfio.c @@ -95,8 +95,8 @@ static int CmdIOProxWatch(const char *Cmd) { //by marshmellow //IO-Prox demod - FSK RF/64 with preamble of 000000001 //print ioprox ID and some format details -static int CmdIOProxDemod(const char *Cmd) { - (void)Cmd; // Cmd is not used so far +int demodIOProx(bool verbose) { + (void) verbose; // unused so far int idx = 0, retval = PM3_SUCCESS; uint8_t bits[MAX_GRAPH_TRACE_LEN] = {0}; size_t size = getFromGraphBuf(bits); @@ -190,10 +190,15 @@ static int CmdIOProxDemod(const char *Cmd) { return retval; } +static int CmdIOProxDemod(const char *Cmd) { + (void)Cmd; // Cmd is not used so far + return demodIOProx(true); +} // this read is the "normal" read, which download lf signal and tries to demod here. static int CmdIOProxRead(const char *Cmd) { + (void)Cmd; // Cmd is not used so far lf_read(false, 12000); - return CmdIOProxDemod(Cmd); + return demodIOProx(true); } static int CmdIOProxSim(const char *Cmd) { uint16_t cn = 0; @@ -311,10 +316,6 @@ int CmdLFIO(const char *Cmd) { return CmdsParse(CommandTable, Cmd); } -int demodIOProx(void) { - return CmdIOProxDemod(""); -} - //Index map //0 10 20 30 40 50 60 //| | | | | | | diff --git a/client/src/cmdlfio.h b/client/src/cmdlfio.h index cb3a514be..4b3085c4f 100644 --- a/client/src/cmdlfio.h +++ b/client/src/cmdlfio.h @@ -8,7 +8,7 @@ int CmdLFIO(const char *Cmd); -int demodIOProx(void); +int demodIOProx(bool verbose); int getIOProxBits(uint8_t version, uint8_t fc, uint16_t cn, uint8_t *bits); #endif diff --git a/client/src/cmdlfjablotron.c b/client/src/cmdlfjablotron.c index a831436e2..9005743bf 100644 --- a/client/src/cmdlfjablotron.c +++ b/client/src/cmdlfjablotron.c @@ -78,16 +78,11 @@ static uint64_t getJablontronCardId(uint64_t rawcode) { return id; } -//see ASKDemod for what args are accepted -static int CmdJablotronDemod(const char *Cmd) { - (void)Cmd; // Cmd is not used so far - return demodJablotron(); -} - -int demodJablotron(void) { +int demodJablotron(bool verbose) { + (void) verbose; // unused so far //Differential Biphase / di-phase (inverted biphase) //get binary from ask wave - if (ASKbiphaseDemod("0 64 1 0", false) != PM3_SUCCESS) { + if (ASKbiphaseDemod(0, 64, 1, 0, false) != PM3_SUCCESS) { if (g_debugMode) PrintAndLogEx(DEBUG, "DEBUG: Error - Jablotron ASKbiphaseDemod failed"); return PM3_ESOFT; } @@ -137,9 +132,16 @@ int demodJablotron(void) { return PM3_SUCCESS; } +//see ASKDemod for what args are accepted +static int CmdJablotronDemod(const char *Cmd) { + (void)Cmd; // Cmd is not used so far + return demodJablotron(true); +} + static int CmdJablotronRead(const char *Cmd) { + (void)Cmd; // Cmd is not used so far lf_read(false, 16000); - return demodJablotron(); + return demodJablotron(true); } static int CmdJablotronClone(const char *Cmd) { diff --git a/client/src/cmdlfjablotron.h b/client/src/cmdlfjablotron.h index da4de291f..bdfe99982 100644 --- a/client/src/cmdlfjablotron.h +++ b/client/src/cmdlfjablotron.h @@ -13,7 +13,7 @@ int CmdLFJablotron(const char *Cmd); -int demodJablotron(void); +int demodJablotron(bool verbose); int detectJablotron(uint8_t *bits, size_t *size); int getJablotronBits(uint64_t fullcode, uint8_t *bits); diff --git a/client/src/cmdlfkeri.c b/client/src/cmdlfkeri.c index a0edff920..eafa53648 100644 --- a/client/src/cmdlfkeri.c +++ b/client/src/cmdlfkeri.c @@ -135,14 +135,10 @@ static int CmdKeriMSScramble(KeriMSScramble_t Action, uint32_t *FC, uint32_t *ID return PM3_SUCCESS; } -static int CmdKeriDemod(const char *Cmd) { - (void)Cmd; // Cmd is not used so far - return demodKeri(); -} +int demodKeri(bool verbose) { + (void) verbose; // unused so far -int demodKeri(void) { - - if (PSKDemod("", false) != PM3_SUCCESS) { + if (PSKDemod(0, 0, 100, false) != PM3_SUCCESS) { PrintAndLogEx(DEBUG, "DEBUG: Error - KERI: PSK1 Demod failed"); return PM3_ESOFT; } @@ -212,9 +208,15 @@ int demodKeri(void) { return PM3_SUCCESS; } +static int CmdKeriDemod(const char *Cmd) { + (void)Cmd; // Cmd is not used so far + return demodKeri(true); +} + static int CmdKeriRead(const char *Cmd) { + (void)Cmd; // Cmd is not used so far lf_read(false, 10000); - return CmdKeriDemod(Cmd); + return demodKeri(true); } static int CmdKeriClone(const char *Cmd) { diff --git a/client/src/cmdlfkeri.h b/client/src/cmdlfkeri.h index 2e1ada11f..210eb23f2 100644 --- a/client/src/cmdlfkeri.h +++ b/client/src/cmdlfkeri.h @@ -13,7 +13,7 @@ int CmdLFKeri(const char *Cmd); -int demodKeri(void); +int demodKeri(bool verbose); int detectKeri(uint8_t *dest, size_t *size, bool *invert); #endif diff --git a/client/src/cmdlfmotorola.c b/client/src/cmdlfmotorola.c index 5cad8028c..7deec0590 100644 --- a/client/src/cmdlfmotorola.c +++ b/client/src/cmdlfmotorola.c @@ -28,16 +28,10 @@ static int CmdHelp(const char *Cmd); -//see PSKDemod for what args are accepted -static int CmdMotorolaDemod(const char *Cmd) { - (void)Cmd; - return demodMotorola(); -} - -int demodMotorola(void) { - +int demodMotorola(bool verbose) { + (void) verbose; // unused so far //PSK1 - if (PSKDemod("32 1", true) != PM3_SUCCESS) { + if (PSKDemod(32, 1, 100, true) != PM3_SUCCESS) { PrintAndLogEx(DEBUG, "DEBUG: Error - Motorola: PSK Demod failed"); return PM3_ESOFT; } @@ -124,6 +118,12 @@ int demodMotorola(void) { return PM3_SUCCESS; } +//see PSKDemod for what args are accepted +static int CmdMotorolaDemod(const char *Cmd) { + (void)Cmd; + return demodMotorola(true); +} + static int CmdMotorolaRead(const char *Cmd) { // Motorola Flexpass seem to work at 74 kHz // and take about 4400 samples to befor modulating @@ -145,7 +145,7 @@ static int CmdMotorolaRead(const char *Cmd) { sc.divisor = LF_DIVISOR_125; sc.samples_to_skip = 0; lf_config(&sc); - return demodMotorola(); + return demodMotorola(true); } static int CmdMotorolaClone(const char *Cmd) { diff --git a/client/src/cmdlfmotorola.h b/client/src/cmdlfmotorola.h index 682193ebc..f74741bf2 100644 --- a/client/src/cmdlfmotorola.h +++ b/client/src/cmdlfmotorola.h @@ -14,7 +14,7 @@ int CmdLFMotorola(const char *Cmd); -int demodMotorola(void); +int demodMotorola(bool verbose); int detectMotorola(uint8_t *dest, size_t *size); int readMotorolaUid(void); #endif diff --git a/client/src/cmdlfnedap.c b/client/src/cmdlfnedap.c index 8fd01ff9f..58b7ad575 100644 --- a/client/src/cmdlfnedap.c +++ b/client/src/cmdlfnedap.c @@ -107,15 +107,14 @@ static uint8_t isEven_64_63(const uint8_t *data) { // 8 } //NEDAP demod - ASK/Biphase (or Diphase), RF/64 with preamble of 1111111110 (always a 128 bit data stream) -static int CmdLFNedapDemod(const char *Cmd) { - (void)Cmd; // Cmd is not used so far - +int demodNedap(bool verbose) { + (void) verbose; // unused so far uint8_t data[16], buffer[7], r0, r1, r2, r3, r4, r5, idxC1, idxC2, idxC3, idxC4, idxC5, fixed0, fixed1, unk1, unk2, subtype; // 4 bits size_t size, offset = 0; uint16_t checksum, customerCode; // 12 bits uint32_t badgeId; // max 99999 - if (ASKbiphaseDemod("0 64 1 0", false) != PM3_SUCCESS) { + if (ASKbiphaseDemod(0, 64, 1, 0, false) != PM3_SUCCESS) { if (g_debugMode) PrintAndLogEx(DEBUG, "DEBUG: Error - NEDAP: ASK/Biphase Demod failed"); return PM3_ESOFT; } @@ -262,6 +261,10 @@ static int CmdLFNedapDemod(const char *Cmd) { return PM3_SUCCESS; } +static int CmdLFNedapDemod(const char *Cmd) { + (void)Cmd; // Cmd is not used so far + return demodNedap(true); +} /* Index map E E preamble enc tag type encrypted uid P d 33 d 90 d 04 d 71 d 40 d 45 d E7 P 1111111110 00101101000001011010001100100100001011010100110101100 1 0 00110011 0 10010000 0 00000100 0 01110001 0 01000000 0 01000101 0 11100111 1 @@ -307,8 +310,9 @@ lf t55xx wr b 4 d 4c0003ff */ static int CmdLFNedapRead(const char *Cmd) { + (void)Cmd; // Cmd is not used so far lf_read(false, 16000); - return CmdLFNedapDemod(Cmd); + return demodNedap(true); } static void NedapGen(uint8_t subType, uint16_t customerCode, uint32_t id, bool isLong, uint8_t *data) { // 8 or 16 @@ -554,8 +558,3 @@ int CmdLFNedap(const char *Cmd) { clearCommandBuffer(); return CmdsParse(CommandTable, Cmd); } - -int demodNedap(void) { - return CmdLFNedapDemod(""); -} - diff --git a/client/src/cmdlfnedap.h b/client/src/cmdlfnedap.h index fda0e130e..58e90954f 100644 --- a/client/src/cmdlfnedap.h +++ b/client/src/cmdlfnedap.h @@ -13,7 +13,7 @@ int CmdLFNedap(const char *Cmd); -int demodNedap(void); +int demodNedap(bool verbose); int detectNedap(uint8_t *dest, size_t *size); int getNedapBits(uint32_t cn, uint8_t *nedapBits); diff --git a/client/src/cmdlfnexwatch.c b/client/src/cmdlfnexwatch.c index 57f7ab03b..8eb44c39b 100644 --- a/client/src/cmdlfnexwatch.c +++ b/client/src/cmdlfnexwatch.c @@ -150,8 +150,9 @@ static int nexwatch_scamble(NexWatchScramble_t action, uint32_t *id, uint32_t *s return PM3_SUCCESS; } -int demodNexWatch(void) { - if (PSKDemod("", false) != PM3_SUCCESS) { +int demodNexWatch(bool verbose) { + (void) verbose; // unused so far + if (PSKDemod(0, 0, 100, false) != PM3_SUCCESS) { PrintAndLogEx(DEBUG, "DEBUG: Error - NexWatch can't demod signal"); return PM3_ESOFT; } @@ -259,14 +260,15 @@ int demodNexWatch(void) { static int CmdNexWatchDemod(const char *Cmd) { (void)Cmd; - return demodNexWatch(); + return demodNexWatch(true); } //by marshmellow //see ASKDemod for what args are accepted static int CmdNexWatchRead(const char *Cmd) { + (void)Cmd; lf_read(false, 20000); - return CmdNexWatchDemod(Cmd); + return demodNexWatch(true); } static int CmdNexWatchClone(const char *Cmd) { diff --git a/client/src/cmdlfnexwatch.h b/client/src/cmdlfnexwatch.h index a282a320e..2144db9b1 100644 --- a/client/src/cmdlfnexwatch.h +++ b/client/src/cmdlfnexwatch.h @@ -13,6 +13,6 @@ int CmdLFNEXWATCH(const char *Cmd); -int demodNexWatch(void); +int demodNexWatch(bool verbose); int detectNexWatch(uint8_t *dest, size_t *size, bool *invert); #endif diff --git a/client/src/cmdlfnoralsy.c b/client/src/cmdlfnoralsy.c index ab6884abc..de62f2236 100644 --- a/client/src/cmdlfnoralsy.c +++ b/client/src/cmdlfnoralsy.c @@ -62,12 +62,11 @@ static uint8_t noralsy_chksum(uint8_t *bits, uint8_t len) { } //see ASKDemod for what args are accepted -static int CmdNoralsyDemod(const char *Cmd) { - (void)Cmd; // Cmd is not used so far - +int demodNoralsy(bool verbose) { + (void) verbose; // unused so far //ASK / Manchester bool st = true; - if (ASKDemod_ext("32 0 0", false, false, 1, &st) != PM3_SUCCESS) { + if (ASKDemod_ext(32, 0, 0, 0, false, false, false, 1, &st) != PM3_SUCCESS) { if (g_debugMode) PrintAndLogEx(DEBUG, "DEBUG: Error - Noralsy: ASK/Manchester Demod failed"); return PM3_ESOFT; } @@ -132,9 +131,15 @@ static int CmdNoralsyDemod(const char *Cmd) { return PM3_SUCCESS; } +static int CmdNoralsyDemod(const char *Cmd) { + (void)Cmd; // Cmd is not used so far + return demodNoralsy(true); +} + static int CmdNoralsyRead(const char *Cmd) { + (void)Cmd; // Cmd is not used so far lf_read(false, 8000); - return CmdNoralsyDemod(Cmd); + return demodNoralsy(true); } static int CmdNoralsyClone(const char *Cmd) { @@ -291,7 +296,3 @@ int detectNoralsy(uint8_t *dest, size_t *size) { * * = unknown * **/ - -int demodNoralsy(void) { - return CmdNoralsyDemod(""); -} diff --git a/client/src/cmdlfnoralsy.h b/client/src/cmdlfnoralsy.h index f76accab7..6dec5005b 100644 --- a/client/src/cmdlfnoralsy.h +++ b/client/src/cmdlfnoralsy.h @@ -13,7 +13,7 @@ int CmdLFNoralsy(const char *Cmd); -int demodNoralsy(void); +int demodNoralsy(bool verbose); int detectNoralsy(uint8_t *dest, size_t *size); int getnoralsyBits(uint32_t id, uint16_t year, uint8_t *bits); diff --git a/client/src/cmdlfpac.c b/client/src/cmdlfpac.c index a35079794..211ddbca0 100644 --- a/client/src/cmdlfpac.c +++ b/client/src/cmdlfpac.c @@ -144,14 +144,10 @@ static void pacCardIdToRaw(uint8_t *outRawBytes, const char *cardId) { } //see NRZDemod for what args are accepted -static int CmdPacDemod(const char *Cmd) { - (void)Cmd; - return demodPac(); -} - -int demodPac(void) { +int demodPac(bool verbose) { + (void) verbose; // unused so far //NRZ - if (NRZrawDemod("", false) != PM3_SUCCESS) { + if (NRZrawDemod(0, 0, 100, false) != PM3_SUCCESS) { PrintAndLogEx(DEBUG, "DEBUG: Error - PAC: NRZ Demod failed"); return PM3_ESOFT; } @@ -188,9 +184,15 @@ int demodPac(void) { return retval; } +static int CmdPacDemod(const char *Cmd) { + (void)Cmd; + return demodPac(true); +} + static int CmdPacRead(const char *Cmd) { + (void)Cmd; lf_read(false, 4096 * 2 + 20); - return CmdPacDemod(Cmd); + return demodPac(true); } static int CmdPacClone(const char *Cmd) { diff --git a/client/src/cmdlfpac.h b/client/src/cmdlfpac.h index 3c9c4fbda..a2145051b 100644 --- a/client/src/cmdlfpac.h +++ b/client/src/cmdlfpac.h @@ -13,7 +13,7 @@ int CmdLFPac(const char *Cmd); -int demodPac(void); +int demodPac(bool verbose); int detectPac(uint8_t *dest, size_t *size); #endif diff --git a/client/src/cmdlfparadox.c b/client/src/cmdlfparadox.c index 1cf7c5c47..8fc3751c8 100644 --- a/client/src/cmdlfparadox.c +++ b/client/src/cmdlfparadox.c @@ -71,16 +71,12 @@ const uint8_t paradox_lut[] = { #define PARADOX_PREAMBLE_LEN 8 -static int CmdParadoxDemod(const char *Cmd) { - (void)Cmd; // Cmd is not used so far - return demodParadox(); -} - //by marshmellow //Paradox Prox demod - FSK2a RF/50 with preamble of 00001111 (then manchester encoded) //print full Paradox Prox ID and some bit format details if found -int demodParadox(void) { +int demodParadox(bool verbose) { + (void) verbose; // unused so far //raw fsk demod no manchester decoding no start bit finding just get binary from wave uint8_t bits[MAX_GRAPH_TRACE_LEN] = {0}; size_t size = getFromGraphBuf(bits); @@ -201,11 +197,18 @@ int demodParadox(void) { return PM3_SUCCESS; } + +static int CmdParadoxDemod(const char *Cmd) { + (void)Cmd; // Cmd is not used so far + return demodParadox(true); +} + //by marshmellow //see ASKDemod for what args are accepted static int CmdParadoxRead(const char *Cmd) { + (void)Cmd; // Cmd is not used so far lf_read(false, 10000); - return CmdParadoxDemod(Cmd); + return demodParadox(true); } static int CmdParadoxClone(const char *Cmd) { diff --git a/client/src/cmdlfparadox.h b/client/src/cmdlfparadox.h index 159d66da9..6e6d3a242 100644 --- a/client/src/cmdlfparadox.h +++ b/client/src/cmdlfparadox.h @@ -13,6 +13,6 @@ int CmdLFParadox(const char *Cmd); -int demodParadox(void); +int demodParadox(bool verbose); int detectParadox(uint8_t *dest, size_t *size, int *wave_start_idx); #endif diff --git a/client/src/cmdlfpresco.c b/client/src/cmdlfpresco.c index 051be2126..b960062ad 100644 --- a/client/src/cmdlfpresco.c +++ b/client/src/cmdlfpresco.c @@ -57,10 +57,10 @@ static int usage_lf_presco_sim(void) { } //see ASKDemod for what args are accepted -static int CmdPrescoDemod(const char *Cmd) { - (void)Cmd; // Cmd is not used so far +int demodPresco(bool verbose) { + (void) verbose; // unused so far bool st = true; - if (ASKDemod_ext("32 0 0 0 0 a", false, false, 1, &st) != PM3_SUCCESS) { + if (ASKDemod_ext(32, 0, 0, 0, true, false, false, 1, &st) != PM3_SUCCESS) { PrintAndLogEx(DEBUG, "DEBUG: Error Presco ASKDemod failed"); return PM3_ESOFT; } @@ -97,11 +97,17 @@ static int CmdPrescoDemod(const char *Cmd) { return PM3_SUCCESS; } +static int CmdPrescoDemod(const char *Cmd) { + (void)Cmd; // Cmd is not used so far + return demodPresco(true); +} + //see ASKDemod for what args are accepted static int CmdPrescoRead(const char *Cmd) { // Presco Number: 123456789 --> Sitecode 30 | usercode 8665 + (void)Cmd; // Cmd is not used so far lf_read(false, 12000); - return CmdPrescoDemod(Cmd); + return demodPresco(true); } // takes base 12 ID converts to hex @@ -178,6 +184,7 @@ static int CmdPrescoSim(const char *Cmd) { static command_t CommandTable[] = { {"help", CmdHelp, AlwaysAvailable, "This help"}, + {"demod", CmdPrescoDemod, AlwaysAvailable, "demodulate Presco tag from the GraphBuffer"}, {"read", CmdPrescoRead, IfPm3Lf, "Attempt to read and Extract tag data"}, {"clone", CmdPrescoClone, IfPm3Lf, "clone presco tag to T55x7 or Q5/T5555"}, {"sim", CmdPrescoSim, IfPm3Lf, "simulate presco tag"}, @@ -277,8 +284,3 @@ int getPrescoBits(uint32_t fullcode, uint8_t *prescoBits) { num_to_bytebits(fullcode, 32, prescoBits + 96); return PM3_SUCCESS; } - -int demodPresco(void) { - return CmdPrescoDemod(""); -} - diff --git a/client/src/cmdlfpresco.h b/client/src/cmdlfpresco.h index 098a98342..d90d6c573 100644 --- a/client/src/cmdlfpresco.h +++ b/client/src/cmdlfpresco.h @@ -13,7 +13,7 @@ int CmdLFPresco(const char *Cmd); -int demodPresco(void); +int demodPresco(bool verbose); int detectPresco(uint8_t *dest, size_t *size); int getPrescoBits(uint32_t fullcode, uint8_t *prescoBits); int getWiegandFromPresco(const char *Cmd, uint32_t *sitecode, uint32_t *usercode, uint32_t *fullcode, bool *Q5); diff --git a/client/src/cmdlfpyramid.c b/client/src/cmdlfpyramid.c index b4ad5564f..3d70d34db 100644 --- a/client/src/cmdlfpyramid.c +++ b/client/src/cmdlfpyramid.c @@ -64,14 +64,10 @@ static int usage_lf_pyramid_sim(void) { return PM3_SUCCESS; } -static int CmdPyramidDemod(const char *Cmd) { - (void)Cmd; // Cmd is not used so far - return demodPyramid(); -} - //Pyramid Prox demod - FSK RF/50 with preamble of 0000000000000001 (always a 128 bit data stream) //print full Farpointe Data/Pyramid Prox ID and some bit format details if found -int demodPyramid(void) { +int demodPyramid(bool verbose) { + (void) verbose; // unused so far //raw fsk demod no manchester decoding no start bit finding just get binary from wave uint8_t bits[MAX_GRAPH_TRACE_LEN] = {0}; size_t size = getFromGraphBuf(bits); @@ -213,9 +209,15 @@ int demodPyramid(void) { return PM3_SUCCESS; } +static int CmdPyramidDemod(const char *Cmd) { + (void)Cmd; // Cmd is not used so far + return demodPyramid(true); +} + static int CmdPyramidRead(const char *Cmd) { + (void)Cmd; // Cmd is not used so far lf_read(false, 15000); - return CmdPyramidDemod(Cmd); + return demodPyramid(true); } static int CmdPyramidClone(const char *Cmd) { diff --git a/client/src/cmdlfpyramid.h b/client/src/cmdlfpyramid.h index 2d717fbb3..b11c7da44 100644 --- a/client/src/cmdlfpyramid.h +++ b/client/src/cmdlfpyramid.h @@ -13,7 +13,7 @@ int CmdLFPyramid(const char *Cmd); -int demodPyramid(void); +int demodPyramid(bool verbose); int detectPyramid(uint8_t *dest, size_t *size, int *waveStartIdx); int getPyramidBits(uint32_t fc, uint32_t cn, uint8_t *pyramidBits); #endif diff --git a/client/src/cmdlfsecurakey.c b/client/src/cmdlfsecurakey.c index ea188ec3b..b5aab5fa8 100644 --- a/client/src/cmdlfsecurakey.c +++ b/client/src/cmdlfsecurakey.c @@ -38,17 +38,13 @@ static int usage_lf_securakey_clone(void) { return PM3_SUCCESS; } -static int CmdSecurakeyDemod(const char *Cmd) { - (void)Cmd; // Cmd is not used so far - return demodSecurakey(); -} - //see ASKDemod for what args are accepted -int demodSecurakey(void) { +int demodSecurakey(bool verbose) { + (void) verbose; // unused so far //ASK / Manchester bool st = false; - if (ASKDemod_ext("40 0 0", false, false, 1, &st) != PM3_SUCCESS) { + if (ASKDemod_ext(40, 0, 0, 0, false, false, false, 1, &st) != PM3_SUCCESS) { PrintAndLogEx(DEBUG, "DEBUG: Error - Securakey: ASK/Manchester Demod failed"); return PM3_ESOFT; } @@ -128,9 +124,15 @@ int demodSecurakey(void) { return PM3_SUCCESS; } +static int CmdSecurakeyDemod(const char *Cmd) { + (void)Cmd; // Cmd is not used so far + return demodSecurakey(true); +} + static int CmdSecurakeyRead(const char *Cmd) { + (void)Cmd; // Cmd is not used so far lf_read(false, 8000); - return CmdSecurakeyDemod(Cmd); + return demodSecurakey(true); } static int CmdSecurakeyClone(const char *Cmd) { diff --git a/client/src/cmdlfsecurakey.h b/client/src/cmdlfsecurakey.h index 229fd0047..48db37714 100644 --- a/client/src/cmdlfsecurakey.h +++ b/client/src/cmdlfsecurakey.h @@ -13,7 +13,7 @@ int CmdLFSecurakey(const char *Cmd); -int demodSecurakey(void); +int demodSecurakey(bool verbose); int detectSecurakey(uint8_t *dest, size_t *size); #endif diff --git a/client/src/cmdlft55xx.c b/client/src/cmdlft55xx.c index f6bc98983..15f5c1398 100644 --- a/client/src/cmdlft55xx.c +++ b/client/src/cmdlft55xx.c @@ -944,8 +944,6 @@ static int CmdT55xxReadBlock(const char *Cmd) { bool DecodeT55xxBlock(void) { - char buf[30] = {0x00}; - char *cmdStr = buf; int ans = 0; bool ST = config.ST; uint8_t bitRate[8] = {8, 16, 32, 40, 50, 64, 100, 128}; @@ -953,41 +951,33 @@ bool DecodeT55xxBlock(void) { switch (config.modulation) { case DEMOD_FSK: - snprintf(cmdStr, sizeof(buf), "%d %d", bitRate[config.bitrate], config.inverted); - ans = FSKrawDemod(cmdStr, false); + ans = FSKrawDemod(bitRate[config.bitrate], config.inverted, 0, 0, false); break; case DEMOD_FSK1: case DEMOD_FSK1a: - snprintf(cmdStr, sizeof(buf), "%d %d 8 5", bitRate[config.bitrate], config.inverted); - ans = FSKrawDemod(cmdStr, false); + ans = FSKrawDemod(bitRate[config.bitrate], config.inverted, 8, 5, false); break; case DEMOD_FSK2: case DEMOD_FSK2a: - snprintf(cmdStr, sizeof(buf), "%d %d 10 8", bitRate[config.bitrate], config.inverted); - ans = FSKrawDemod(cmdStr, false); + ans = FSKrawDemod(bitRate[config.bitrate], config.inverted, 10, 8, false); break; case DEMOD_ASK: - snprintf(cmdStr, sizeof(buf), "%d %d 1", bitRate[config.bitrate], config.inverted); - ans = ASKDemod_ext(cmdStr, false, false, 1, &ST); + ans = ASKDemod_ext(bitRate[config.bitrate], config.inverted, 1, 0, false, false, false, 1, &ST); break; case DEMOD_PSK1: - snprintf(cmdStr, sizeof(buf), "%d %d 6", bitRate[config.bitrate], config.inverted); - ans = PSKDemod(cmdStr, false); + ans = PSKDemod(bitRate[config.bitrate], config.inverted, 6, false); break; case DEMOD_PSK2: //inverted won't affect this case DEMOD_PSK3: //not fully implemented - snprintf(cmdStr, sizeof(buf), "%d 0 6", bitRate[config.bitrate]); - ans = PSKDemod(cmdStr, false); + ans = PSKDemod(bitRate[config.bitrate], 0, 6, false); psk1TOpsk2(DemodBuffer, DemodBufferLen); break; case DEMOD_NRZ: - snprintf(cmdStr, sizeof(buf), "%d %d 1", bitRate[config.bitrate], config.inverted); - ans = NRZrawDemod(cmdStr, false); + ans = NRZrawDemod(bitRate[config.bitrate], config.inverted, 1, false); break; case DEMOD_BI: case DEMOD_BIa: - snprintf(cmdStr, sizeof(buf), "0 %d %d 1", bitRate[config.bitrate], config.inverted); - ans = ASKbiphaseDemod(cmdStr, false); + ans = ASKbiphaseDemod(0, bitRate[config.bitrate], config.inverted, 1, false); break; default: return false; @@ -999,7 +989,8 @@ static bool DecodeT5555TraceBlock(void) { DemodBufferLen = 0x00; // According to datasheet. Always: RF/64, not inverted, Manchester - return (ASKDemod("64 0 1", false, false, 1) == PM3_SUCCESS); + bool st = false; + return (ASKDemod_ext(64, 0, 1, 0, false, false, false, 1, &st) == PM3_SUCCESS); } // sanity check. Don't use proxmark if it is offline and you didn't specify useGraphbuf @@ -1139,7 +1130,7 @@ bool tryDetectModulationEx(uint8_t downlink_mode, bool print_config, uint32_t wa ans = fskClocks(&fc1, &fc2, (uint8_t *)&clk, &firstClockEdge); if (ans && ((fc1 == 10 && fc2 == 8) || (fc1 == 8 && fc2 == 5))) { - if ((FSKrawDemod("0 0", false) == PM3_SUCCESS) && test(DEMOD_FSK, &tests[hits].offset, &bitRate, clk, &tests[hits].Q5)) { + if ((FSKrawDemod(0, 0, 0, 0, false) == PM3_SUCCESS) && test(DEMOD_FSK, &tests[hits].offset, &bitRate, clk, &tests[hits].Q5)) { tests[hits].modulation = DEMOD_FSK; if (fc1 == 8 && fc2 == 5) tests[hits].modulation = DEMOD_FSK1a; @@ -1152,7 +1143,7 @@ bool tryDetectModulationEx(uint8_t downlink_mode, bool print_config, uint32_t wa tests[hits].downlink_mode = downlink_mode; ++hits; } - if ((FSKrawDemod("0 1", false) == PM3_SUCCESS) && test(DEMOD_FSK, &tests[hits].offset, &bitRate, clk, &tests[hits].Q5)) { + if ((FSKrawDemod(0, 1, 0, 0, false) == PM3_SUCCESS) && test(DEMOD_FSK, &tests[hits].offset, &bitRate, clk, &tests[hits].Q5)) { tests[hits].modulation = DEMOD_FSK; if (fc1 == 8 && fc2 == 5) tests[hits].modulation = DEMOD_FSK1; @@ -1174,7 +1165,7 @@ bool tryDetectModulationEx(uint8_t downlink_mode, bool print_config, uint32_t wa // false = no emSearch // 1 = Ask/Man // st = true - if ((ASKDemod_ext("0 0 1", false, false, 1, &tests[hits].ST) == PM3_SUCCESS) && test(DEMOD_ASK, &tests[hits].offset, &bitRate, clk, &tests[hits].Q5)) { + if ((ASKDemod_ext(0, 0, 1, 0, false, false, false, 1, &tests[hits].ST) == PM3_SUCCESS) && test(DEMOD_ASK, &tests[hits].offset, &bitRate, clk, &tests[hits].Q5)) { tests[hits].modulation = DEMOD_ASK; tests[hits].bitrate = bitRate; tests[hits].inverted = false; @@ -1188,7 +1179,7 @@ bool tryDetectModulationEx(uint8_t downlink_mode, bool print_config, uint32_t wa // false = no emSearch // 1 = Ask/Man // st = true - if ((ASKDemod_ext("0 1 1", false, false, 1, &tests[hits].ST) == PM3_SUCCESS) && test(DEMOD_ASK, &tests[hits].offset, &bitRate, clk, &tests[hits].Q5)) { + if ((ASKDemod_ext(0, 1, 1, 0, false, false, false, 1, &tests[hits].ST) == PM3_SUCCESS) && test(DEMOD_ASK, &tests[hits].offset, &bitRate, clk, &tests[hits].Q5)) { tests[hits].modulation = DEMOD_ASK; tests[hits].bitrate = bitRate; tests[hits].inverted = true; @@ -1196,7 +1187,7 @@ bool tryDetectModulationEx(uint8_t downlink_mode, bool print_config, uint32_t wa tests[hits].downlink_mode = downlink_mode; ++hits; } - if ((ASKbiphaseDemod("0 0 0 2", false) == PM3_SUCCESS) && test(DEMOD_BI, &tests[hits].offset, &bitRate, clk, &tests[hits].Q5)) { + if ((ASKbiphaseDemod(0, 0, 0, 2, false) == PM3_SUCCESS) && test(DEMOD_BI, &tests[hits].offset, &bitRate, clk, &tests[hits].Q5)) { tests[hits].modulation = DEMOD_BI; tests[hits].bitrate = bitRate; tests[hits].inverted = false; @@ -1205,7 +1196,7 @@ bool tryDetectModulationEx(uint8_t downlink_mode, bool print_config, uint32_t wa tests[hits].downlink_mode = downlink_mode; ++hits; } - if ((ASKbiphaseDemod("0 0 1 2", false) == PM3_SUCCESS) && test(DEMOD_BIa, &tests[hits].offset, &bitRate, clk, &tests[hits].Q5)) { + if ((ASKbiphaseDemod(0, 0, 1, 2, false) == PM3_SUCCESS) && test(DEMOD_BIa, &tests[hits].offset, &bitRate, clk, &tests[hits].Q5)) { tests[hits].modulation = DEMOD_BIa; tests[hits].bitrate = bitRate; tests[hits].inverted = true; @@ -1217,7 +1208,7 @@ bool tryDetectModulationEx(uint8_t downlink_mode, bool print_config, uint32_t wa } clk = GetNrzClock("", false); if (clk > 8) { //clock of rf/8 is likely a false positive, so don't use it. - if ((NRZrawDemod("0 0 1", false) == PM3_SUCCESS) && test(DEMOD_NRZ, &tests[hits].offset, &bitRate, clk, &tests[hits].Q5)) { + if ((NRZrawDemod(0, 0, 1, false) == PM3_SUCCESS) && test(DEMOD_NRZ, &tests[hits].offset, &bitRate, clk, &tests[hits].Q5)) { tests[hits].modulation = DEMOD_NRZ; tests[hits].bitrate = bitRate; tests[hits].inverted = false; @@ -1227,7 +1218,7 @@ bool tryDetectModulationEx(uint8_t downlink_mode, bool print_config, uint32_t wa ++hits; } - if ((NRZrawDemod("0 1 1", false) == PM3_SUCCESS) && test(DEMOD_NRZ, &tests[hits].offset, &bitRate, clk, &tests[hits].Q5)) { + if ((NRZrawDemod(0, 1, 1, false) == PM3_SUCCESS) && test(DEMOD_NRZ, &tests[hits].offset, &bitRate, clk, &tests[hits].Q5)) { tests[hits].modulation = DEMOD_NRZ; tests[hits].bitrate = bitRate; tests[hits].inverted = true; @@ -1244,7 +1235,7 @@ bool tryDetectModulationEx(uint8_t downlink_mode, bool print_config, uint32_t wa save_restoreGB(GRAPH_SAVE); // skip first 160 samples to allow antenna to settle in (psk gets inverted occasionally otherwise) CmdLtrim("160"); - if ((PSKDemod("0 0 6", false) == PM3_SUCCESS) && test(DEMOD_PSK1, &tests[hits].offset, &bitRate, clk, &tests[hits].Q5)) { + if ((PSKDemod(0, 0, 6, false) == PM3_SUCCESS) && test(DEMOD_PSK1, &tests[hits].offset, &bitRate, clk, &tests[hits].Q5)) { tests[hits].modulation = DEMOD_PSK1; tests[hits].bitrate = bitRate; tests[hits].inverted = false; @@ -1253,7 +1244,7 @@ bool tryDetectModulationEx(uint8_t downlink_mode, bool print_config, uint32_t wa tests[hits].downlink_mode = downlink_mode; ++hits; } - if ((PSKDemod("0 1 6", false) == PM3_SUCCESS) && test(DEMOD_PSK1, &tests[hits].offset, &bitRate, clk, &tests[hits].Q5)) { + if ((PSKDemod(0, 1, 6, false) == PM3_SUCCESS) && test(DEMOD_PSK1, &tests[hits].offset, &bitRate, clk, &tests[hits].Q5)) { tests[hits].modulation = DEMOD_PSK1; tests[hits].bitrate = bitRate; tests[hits].inverted = true; @@ -1264,7 +1255,7 @@ bool tryDetectModulationEx(uint8_t downlink_mode, bool print_config, uint32_t wa } //ICEMAN: are these PSKDemod calls needed? // PSK2 - needs a call to psk1TOpsk2. - if (PSKDemod("0 0 6", false) == PM3_SUCCESS) { + if (PSKDemod(0, 0, 6, false) == PM3_SUCCESS) { psk1TOpsk2(DemodBuffer, DemodBufferLen); if (test(DEMOD_PSK2, &tests[hits].offset, &bitRate, clk, &tests[hits].Q5)) { tests[hits].modulation = DEMOD_PSK2; @@ -1277,7 +1268,7 @@ bool tryDetectModulationEx(uint8_t downlink_mode, bool print_config, uint32_t wa } } // inverse waves does not affect this demod // PSK3 - needs a call to psk1TOpsk2. - if (PSKDemod("0 0 6", false) == PM3_SUCCESS) { + if (PSKDemod(0, 0, 6, false) == PM3_SUCCESS) { psk1TOpsk2(DemodBuffer, DemodBufferLen); if (test(DEMOD_PSK3, &tests[hits].offset, &bitRate, clk, &tests[hits].Q5)) { tests[hits].modulation = DEMOD_PSK3; @@ -3414,12 +3405,12 @@ bool tryDetectP1(bool getData) { // try fsk clock detect. if successful it cannot be any other type of modulation... (in theory...) ans = fskClocks(&fc1, &fc2, (uint8_t *)&clk, &firstClockEdge); if (ans && ((fc1 == 10 && fc2 == 8) || (fc1 == 8 && fc2 == 5))) { - if ((FSKrawDemod("0 0", false) == PM3_SUCCESS) && + if ((FSKrawDemod(0, 0, 0, 0, false) == PM3_SUCCESS) && preambleSearchEx(DemodBuffer, preamble, sizeof(preamble), &DemodBufferLen, &startIdx, false) && (DemodBufferLen == 32 || DemodBufferLen == 64)) { return true; } - if ((FSKrawDemod("0 1", false) == PM3_SUCCESS) && + if ((FSKrawDemod(0, 1, 0, 0, false) == PM3_SUCCESS) && preambleSearchEx(DemodBuffer, preamble, sizeof(preamble), &DemodBufferLen, &startIdx, false) && (DemodBufferLen == 32 || DemodBufferLen == 64)) { return true; @@ -3430,26 +3421,26 @@ bool tryDetectP1(bool getData) { // try ask clock detect. it could be another type even if successful. clk = GetAskClock("", false); if (clk > 0) { - if ((ASKDemod_ext("0 0 1", false, false, 1, &st) == PM3_SUCCESS) && + if ((ASKDemod_ext(0, 0, 1, 0, false, false, false, 1, &st) == PM3_SUCCESS) && preambleSearchEx(DemodBuffer, preamble, sizeof(preamble), &DemodBufferLen, &startIdx, false) && (DemodBufferLen == 32 || DemodBufferLen == 64)) { return true; } st = true; - if ((ASKDemod_ext("0 1 1", false, false, 1, &st) == PM3_SUCCESS) && + if ((ASKDemod_ext(0, 1, 1, 0, false, false, false, 1, &st) == PM3_SUCCESS) && preambleSearchEx(DemodBuffer, preamble, sizeof(preamble), &DemodBufferLen, &startIdx, false) && (DemodBufferLen == 32 || DemodBufferLen == 64)) { return true; } - if ((ASKbiphaseDemod("0 0 0 2", false) == PM3_SUCCESS) && + if ((ASKbiphaseDemod(0, 0, 0, 2, false) == PM3_SUCCESS) && preambleSearchEx(DemodBuffer, preamble, sizeof(preamble), &DemodBufferLen, &startIdx, false) && (DemodBufferLen == 32 || DemodBufferLen == 64)) { return true; } - if ((ASKbiphaseDemod("0 0 1 2", false) == PM3_SUCCESS) && + if ((ASKbiphaseDemod(0, 0, 1, 2, false) == PM3_SUCCESS) && preambleSearchEx(DemodBuffer, preamble, sizeof(preamble), &DemodBufferLen, &startIdx, false) && (DemodBufferLen == 32 || DemodBufferLen == 64)) { return true; @@ -3459,12 +3450,12 @@ bool tryDetectP1(bool getData) { // try NRZ clock detect. it could be another type even if successful. clk = GetNrzClock("", false); //has the most false positives :( if (clk > 0) { - if ((NRZrawDemod("0 0 1", false) == PM3_SUCCESS) && + if ((NRZrawDemod(0, 0, 1, false) == PM3_SUCCESS) && preambleSearchEx(DemodBuffer, preamble, sizeof(preamble), &DemodBufferLen, &startIdx, false) && (DemodBufferLen == 32 || DemodBufferLen == 64)) { return true; } - if ((NRZrawDemod("0 1 1", false) == PM3_SUCCESS) && + if ((NRZrawDemod(0, 1, 1, false) == PM3_SUCCESS) && preambleSearchEx(DemodBuffer, preamble, sizeof(preamble), &DemodBufferLen, &startIdx, false) && (DemodBufferLen == 32 || DemodBufferLen == 64)) { return true; @@ -3479,20 +3470,20 @@ bool tryDetectP1(bool getData) { // save_restoreGB(GRAPH_SAVE); // skip first 160 samples to allow antenna to settle in (psk gets inverted occasionally otherwise) //CmdLtrim("160"); - if ((PSKDemod("0 0 6", false) == PM3_SUCCESS) && + if ((PSKDemod(0, 0, 6, false) == PM3_SUCCESS) && preambleSearchEx(DemodBuffer, preamble, sizeof(preamble), &DemodBufferLen, &startIdx, false) && (DemodBufferLen == 32 || DemodBufferLen == 64)) { //save_restoreGB(GRAPH_RESTORE); return true; } - if ((PSKDemod("0 1 6", false) == PM3_SUCCESS) && + if ((PSKDemod(0, 1, 6, false) == PM3_SUCCESS) && preambleSearchEx(DemodBuffer, preamble, sizeof(preamble), &DemodBufferLen, &startIdx, false) && (DemodBufferLen == 32 || DemodBufferLen == 64)) { //save_restoreGB(GRAPH_RESTORE); return true; } // PSK2 - needs a call to psk1TOpsk2. - if (PSKDemod("0 0 6", false) == PM3_SUCCESS) { + if (PSKDemod(0, 0, 6, false) == PM3_SUCCESS) { psk1TOpsk2(DemodBuffer, DemodBufferLen); if (preambleSearchEx(DemodBuffer, preamble, sizeof(preamble), &DemodBufferLen, &startIdx, false) && (DemodBufferLen == 32 || DemodBufferLen == 64)) { diff --git a/client/src/cmdlfti.c b/client/src/cmdlfti.c index a41c70d91..dc3aeddf1 100644 --- a/client/src/cmdlfti.c +++ b/client/src/cmdlfti.c @@ -23,8 +23,8 @@ static int CmdHelp(const char *Cmd); -static int CmdTIDemod(const char *Cmd) { - (void)Cmd; // Cmd is not used so far +int demodTI(bool verbose) { + (void) verbose; // unused so far /* MATLAB as follows: f_s = 2000000; % sampling frequency f_l = 123200; % low FSK tone @@ -271,6 +271,11 @@ out: return retval; } +static int CmdTIDemod(const char *Cmd) { + (void)Cmd; // Cmd is not used so far + return demodTI(true); +} + // read a TI tag and return its ID static int CmdTIRead(const char *Cmd) { (void)Cmd; // Cmd is not used so far @@ -317,8 +322,3 @@ int CmdLFTI(const char *Cmd) { clearCommandBuffer(); return CmdsParse(CommandTable, Cmd); } - -int demodTI(void) { - return CmdTIDemod(""); -} - diff --git a/client/src/cmdlfti.h b/client/src/cmdlfti.h index e185a1403..10865cb5f 100644 --- a/client/src/cmdlfti.h +++ b/client/src/cmdlfti.h @@ -15,5 +15,5 @@ int CmdLFTI(const char *Cmd); -int demodTI(void); +int demodTI(bool verbose); #endif diff --git a/client/src/cmdlfverichip_disabled.c b/client/src/cmdlfverichip_disabled.c index ee2de0846..e30b95ee8 100644 --- a/client/src/cmdlfverichip_disabled.c +++ b/client/src/cmdlfverichip_disabled.c @@ -38,14 +38,10 @@ static int usage_lf_verichip_clone(void) { } //see NRZDemod for what args are accepted -static int CmdVerichipDemod(const char *Cmd) { - (void)Cmd; - return demodVerichip(); -} - -int demodVerichip(void) { +int demodVerichip(bool verbose) { + (void) verbose; // unused so far //NRZ - if (NRZrawDemod("", false) != PM3_SUCCESS) { + if (NRZrawDemod(0, 0, 100, false) != PM3_SUCCESS) { PrintAndLogEx(DEBUG, "DEBUG: Error - VERICHIP: NRZ Demod failed"); return PM3_ESOFT; } @@ -81,9 +77,15 @@ int demodVerichip(void) { return PM3_SUCCESS; } +static int CmdVerichipDemod(const char *Cmd) { + (void)Cmd; + return demodVerichip(true); +} + static int CmdVerichipRead(const char *Cmd) { + (void)Cmd; lf_read(false, 4096 * 2 + 20); - return CmdVerichipDemod(Cmd); + return demodVerichip(true); } static int CmdVerichipClone(const char *Cmd) { diff --git a/client/src/cmdlfverichip_disabled.h b/client/src/cmdlfverichip_disabled.h index 4ddf6a5d1..875ae355c 100644 --- a/client/src/cmdlfverichip_disabled.h +++ b/client/src/cmdlfverichip_disabled.h @@ -13,7 +13,7 @@ int CmdLFVerichip(const char *Cmd); -int demodVerichip(void); +int demodVerichip(bool verbose); int detectVerichip(uint8_t *dest, size_t *size); #endif diff --git a/client/src/cmdlfviking.c b/client/src/cmdlfviking.c index 205ea94b3..4a5f534ab 100644 --- a/client/src/cmdlfviking.c +++ b/client/src/cmdlfviking.c @@ -53,14 +53,12 @@ static int usage_lf_viking_sim(void) { return PM3_SUCCESS; } -static int CmdVikingDemod(const char *Cmd) { - return demodViking(); -} - //see ASKDemod for what args are accepted -int demodViking(void) { +int demodViking(bool verbose) { + (void) verbose; // unused so far - if (ASKDemod("", false, false, 1) != PM3_SUCCESS) { + bool st = false; + if (ASKDemod_ext(0, 0, 100, 0, false, false, false, 1, &st) != PM3_SUCCESS) { PrintAndLogEx(DEBUG, "DEBUG: Error - Viking ASKDemod failed"); return PM3_ESOFT; } @@ -84,10 +82,16 @@ int demodViking(void) { return PM3_SUCCESS; } +static int CmdVikingDemod(const char *Cmd) { + (void)Cmd; + return demodViking(true); +} + //see ASKDemod for what args are accepted static int CmdVikingRead(const char *Cmd) { + (void)Cmd; lf_read(false, 10000); - return CmdVikingDemod(Cmd); + return demodViking(true); } static int CmdVikingClone(const char *Cmd) { diff --git a/client/src/cmdlfviking.h b/client/src/cmdlfviking.h index 156d57c7d..48d087256 100644 --- a/client/src/cmdlfviking.h +++ b/client/src/cmdlfviking.h @@ -13,7 +13,7 @@ int CmdLFViking(const char *Cmd); -int demodViking(void); +int demodViking(bool verbose); int detectViking(uint8_t *src, size_t *size); uint64_t getVikingBits(uint32_t id); diff --git a/client/src/cmdlfvisa2000.c b/client/src/cmdlfvisa2000.c index bd25d9d89..97f5dc48e 100644 --- a/client/src/cmdlfvisa2000.c +++ b/client/src/cmdlfvisa2000.c @@ -87,10 +87,6 @@ static uint8_t visa_parity(uint32_t id) { return par; } -static int CmdVisa2kDemod(const char *Cmd) { - (void)Cmd; // Cmd is not used so far - return demodVisa2k(); -} /** * * 56495332 00096ebd 00000077 —> tag id 618173 @@ -103,14 +99,15 @@ static int CmdVisa2kDemod(const char *Cmd) { * **/ //see ASKDemod for what args are accepted -int demodVisa2k(void) { +int demodVisa2k(bool verbose) { + (void) verbose; // unused so far save_restoreGB(GRAPH_SAVE); //CmdAskEdgeDetect(""); //ASK / Manchester bool st = true; - if (ASKDemod_ext("64 0 0", false, false, 1, &st) != PM3_SUCCESS) { + if (ASKDemod_ext(64, 0, 0, 0, false, false, false, 1, &st) != PM3_SUCCESS) { PrintAndLogEx(DEBUG, "DEBUG: Error - Visa2k: ASK/Manchester Demod failed"); save_restoreGB(GRAPH_RESTORE); return PM3_ESOFT; @@ -160,10 +157,16 @@ int demodVisa2k(void) { return PM3_SUCCESS; } +static int CmdVisa2kDemod(const char *Cmd) { + (void)Cmd; // Cmd is not used so far + return demodVisa2k(true); +} + // 64*96*2=12288 samples just in case we just missed the first preamble we can still catch 2 of them static int CmdVisa2kRead(const char *Cmd) { + (void)Cmd; // Cmd is not used so far lf_read(false, 20000); - return CmdVisa2kDemod(Cmd); + return demodVisa2k(true); } static int CmdVisa2kClone(const char *Cmd) { diff --git a/client/src/cmdlfvisa2000.h b/client/src/cmdlfvisa2000.h index 63e7fdc67..85e721357 100644 --- a/client/src/cmdlfvisa2000.h +++ b/client/src/cmdlfvisa2000.h @@ -14,7 +14,7 @@ int CmdLFVisa2k(const char *Cmd); int getvisa2kBits(uint64_t fullcode, uint8_t *bits); -int demodVisa2k(void); +int demodVisa2k(bool verbose); int detectVisa2k(uint8_t *dest, size_t *size); #endif