diff --git a/armsrc/iso14443a.c b/armsrc/iso14443a.c index 743092c8b..8b166205e 100644 --- a/armsrc/iso14443a.c +++ b/armsrc/iso14443a.c @@ -852,11 +852,20 @@ void RAMFUNC SniffIso14443a(uint8_t param) { uint32_t rx_samples = 0; + uint16_t checker = 12000; + // loop and listen while (BUTTON_PRESS() == false) { WDT_HIT(); LED_A_ON(); + if (checker-- == 0) { + if (data_available()) { + break; + } + checker = 12000; + } + register int readBufDataP = data - dma->buf; register int dmaBufDataP = DMA_BUFFER_SIZE - AT91C_BASE_PDC_SSC->PDC_RCR; if (readBufDataP <= dmaBufDataP) { diff --git a/client/src/cmdhf14a.c b/client/src/cmdhf14a.c index 14ddfd60f..d2db2de42 100644 --- a/client/src/cmdhf14a.c +++ b/client/src/cmdhf14a.c @@ -1105,14 +1105,31 @@ int CmdHF14ASniff(const char *Cmd) { clearCommandBuffer(); SendCommandNG(CMD_HF_ISO14443A_SNIFF, (uint8_t *)¶m, sizeof(uint8_t)); - PrintAndLogEx(INFO, "Press " _GREEN_("pm3 button") " to abort sniffing"); - if (interactive) { + PrintAndLogEx(INFO, "Press " _GREEN_("pm3 button") " or " _GREEN_("") " to abort sniffing"); + PacketResponseNG resp; - WaitForResponse(CMD_HF_ISO14443A_SNIFF, &resp); + + bool keypress = kbd_enter_pressed(); + while (keypress == false) { + keypress = kbd_enter_pressed(); + + if (WaitForResponseTimeout(CMD_HF_ISO14443A_SNIFF, &resp, 500)) { + break; + } + } + + if (keypress) { + // inform device to break the sim loop since client has exited + SendCommandNG(CMD_BREAK_LOOP, NULL, 0); + WaitForResponse(CMD_HF_ISO14443A_SNIFF, &resp); + } + PrintAndLogEx(INFO, "Done!"); PrintAndLogEx(HINT, "Hint: Try `" _YELLOW_("hf 14a list")"` to view captured tracelog"); PrintAndLogEx(HINT, "Hint: Try `" _YELLOW_("trace save -h") "` to save tracelog for later analysing"); + } else { + PrintAndLogEx(INFO, "Press " _GREEN_("pm3 button") " to abort sniffing"); } return PM3_SUCCESS; }