diff --git a/armsrc/iso15693.c b/armsrc/iso15693.c index 66539c807..9ead4c117 100644 --- a/armsrc/iso15693.c +++ b/armsrc/iso15693.c @@ -1853,7 +1853,7 @@ void BruteforceIso15693Afi(uint32_t speed) { Dbprintf("NoAFI UID = %s", iso15693_sprintUID(NULL, recv + 2)); } else { DbpString("Failed to select card"); - reply_ng(CMD_ACK, PM3_ESOFT, NULL, 0); + reply_ng(CMD_HF_ISO15693_FINDAFI, PM3_ESOFT, NULL, 0); switch_off(); return; } @@ -1881,10 +1881,8 @@ void BruteforceIso15693Afi(uint32_t speed) { Dbprintf("AFI = %i UID = %s", i, iso15693_sprintUID(NULL, recv + 2)); } - aborted = BUTTON_PRESS(); - + aborted = BUTTON_PRESS() && data_available(); if (aborted) { - DbpString("button pressed, aborting.."); break; } } @@ -1893,9 +1891,9 @@ void BruteforceIso15693Afi(uint32_t speed) { switch_off(); if (aborted) { - reply_ng(CMD_ACK, PM3_EOPABORTED, NULL, 0); + reply_ng(CMD_HF_ISO15693_FINDAFI, PM3_EOPABORTED, NULL, 0); } else { - reply_ng(CMD_ACK, PM3_SUCCESS, NULL, 0); + reply_ng(CMD_HF_ISO15693_FINDAFI, PM3_SUCCESS, NULL, 0); } } diff --git a/client/src/cmdhf15.c b/client/src/cmdhf15.c index 1fd1fb034..b69d1447c 100644 --- a/client/src/cmdhf15.c +++ b/client/src/cmdhf15.c @@ -35,6 +35,7 @@ #include "cmddata.h" // getsamples #include "fileutils.h" // savefileEML #include "cliparser.h" +#include "util_posix.h" // msleep #define FrameSOF Iso15693FrameSOF #define Logic0 Iso15693Logic0 @@ -1151,28 +1152,43 @@ static int CmdHF15FindAfi(const char *Cmd) { arg_param_begin, arg_param_end }; - CLIExecWithReturn(ctx, Cmd, argtable, false); + CLIExecWithReturn(ctx, Cmd, argtable, true); CLIParserFree(ctx); - PrintAndLogEx(SUCCESS, "press pm3-button to cancel"); - + PrintAndLogEx(INFO, "click " _GREEN_("pm3 button") " or press " _GREEN_("Enter") " to exit"); clearCommandBuffer(); PacketResponseNG resp; SendCommandMIX(CMD_HF_ISO15693_FINDAFI, strtol(Cmd, NULL, 0), 0, 0, NULL, 0); - uint32_t timeout = 0; - while (!WaitForResponseTimeout(CMD_ACK, &resp, 2000)) { - timeout++; + for (;;) { + + if (kbd_enter_pressed()) { + SendCommandNG(CMD_BREAK_LOOP, NULL, 0); + PrintAndLogEx(DEBUG, "User aborted"); + msleep(300); + break; + } + + uint32_t timeout = 0; + if (WaitForResponseTimeout(CMD_HF_ISO15693_FINDAFI, &resp, 2000)){ + if (resp.status == PM3_EOPABORTED) { + PrintAndLogEx(DEBUG, "Button pressed, user aborted"); + break; + } + } else { + timeout++; + + // should be done in about 2 minutes + if (timeout > 180) { + PrintAndLogEx(WARNING, "\nNo response from Proxmark3. Aborting..."); + break; + } - // should be done in about 2 minutes - if (timeout > 180) { - PrintAndLogEx(WARNING, "\nNo response from Proxmark3. Aborting..."); - DropField(); - return PM3_ETIMEOUT; } } DropField(); + PrintAndLogEx(INFO, "Done"); return resp.status; // PM3_EOPABORTED or PM3_SUCCESS }