LF: rework internal APIs
This commit is contained in:
@@ -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)) {
|
||||
|
||||
Reference in New Issue
Block a user