mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-07-05 20:41:34 -07:00
Make demodulation threshold for Legic configurable
This adds a new parameter to the "hw sethfthresh" command.
This commit is contained in:
parent
dbfd8b7a6d
commit
43b257ddb4
4 changed files with 18 additions and 9 deletions
|
@ -1563,6 +1563,7 @@ static void PacketReceived(PacketCommandNG *packet) {
|
|||
case CMD_HF_ISO14443A_SET_THRESHOLDS: {
|
||||
FpgaDownloadAndGo(FPGA_BITSTREAM_HF);
|
||||
FpgaSendCommand(FPGA_CMD_SET_EDGE_DETECT_THRESHOLD, (packet->data.asBytes[0] & 0x3f) | ((packet->data.asBytes[1] & 0x3f) << 6));
|
||||
LegicRfSetThreshold((uint32_t)packet->data.asBytes[2]);
|
||||
break;
|
||||
}
|
||||
case CMD_HF_ISO14443A_SNIFF: {
|
||||
|
|
|
@ -64,7 +64,7 @@ static uint32_t last_frame_end; /* ts of last bit of previews rx or tx frame */
|
|||
#define LEGIC_CARD_MEMSIZE 1024 /* The largest Legic Prime card is 1k */
|
||||
#define WRITE_LOWERLIMIT 4 /* UID and MCC are not writable */
|
||||
|
||||
#define INPUT_THRESHOLD 8 /* heuristically determined, lower values */
|
||||
static uint32_t input_threshold = 8; /* heuristically determined, lower values */
|
||||
/* lead to detecting false ack during write */
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -129,7 +129,7 @@ static bool rx_bit(void) {
|
|||
int32_t power = (MAX(ABS(sum_ci), ABS(sum_cq)) + (MIN(ABS(sum_ci), ABS(sum_cq)) >> 1));
|
||||
|
||||
// compare average (power / 8) to threshold
|
||||
return ((power >> 3) > INPUT_THRESHOLD);
|
||||
return ((power >> 3) > input_threshold);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -566,3 +566,8 @@ OUT:
|
|||
switch_off();
|
||||
StopTicks();
|
||||
}
|
||||
|
||||
void LegicRfSetThreshold(uint32_t threshold)
|
||||
{
|
||||
input_threshold = threshold;
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ void LegicRfInfo(void);
|
|||
int LegicRfReaderEx(uint16_t offset, uint16_t len, uint8_t iv);
|
||||
void LegicRfReader(uint16_t offset, uint16_t len, uint8_t iv);
|
||||
void LegicRfWriter(uint16_t offset, uint16_t len, uint8_t iv, const uint8_t *data);
|
||||
void LegicRfSetThreshold(uint32_t threshold);
|
||||
|
||||
legic_card_select_t *getLegicCardInfo(void);
|
||||
#endif /* __LEGICRF_H */
|
||||
|
|
|
@ -747,20 +747,22 @@ static int CmdSetHFThreshold(const char *Cmd) {
|
|||
|
||||
CLIParserContext *ctx;
|
||||
CLIParserInit(&ctx, "hw sethfthresh",
|
||||
"Set thresholds in HF/14a mode.",
|
||||
"hw sethfthresh -i 20 -t 7"
|
||||
"Set thresholds in HF/14a and Legic mode.",
|
||||
"hw sethfthresh -t 7 -i 20 -l 8"
|
||||
);
|
||||
|
||||
void *argtable[] = {
|
||||
arg_param_begin,
|
||||
arg_int0("i", "high", "<dec>", "high threshold, used in sniff mode (def 20)"),
|
||||
arg_int0("t", "thresh", "<dec>", "threshold, used in reader mode (def 7)"),
|
||||
arg_int0("t", "thresh", "<dec>", "threshold, used in 14a reader mode (def 7)"),
|
||||
arg_int0("i", "high", "<dec>", "high threshold, used in 14a sniff mode (def 20)"),
|
||||
arg_int0("l", "legic", "<dec>", "threshold used in Legic mode (def 8)"),
|
||||
arg_param_end
|
||||
};
|
||||
CLIExecWithReturn(ctx, Cmd, argtable, true);
|
||||
uint8_t params[2];
|
||||
params[1] = arg_get_int_def(ctx, 1, 20);
|
||||
params[0] = arg_get_int_def(ctx, 2, 7);
|
||||
uint8_t params[3];
|
||||
params[0] = arg_get_int_def(ctx, 1, 7);
|
||||
params[1] = arg_get_int_def(ctx, 2, 20);
|
||||
params[2] = arg_get_int_def(ctx, 3, 8);
|
||||
CLIParserFree(ctx);
|
||||
|
||||
if ((params[0]<1) || (params[0]>63) || (params[1]<1) || (params[1]>63)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue