+int usage_hf_emv_sim(void){
+ PrintAndLog("Simulates a EMV contactless card");
+ PrintAndLog("Usage: hf emv sim [h]");
+ PrintAndLog("Options:");
+ PrintAndLog(" h : this help");
+ PrintAndLog("");
+ PrintAndLog("Samples:");
+ PrintAndLog(" hf emv sim");
+ return 0;
+}
+
+int CmdHfEmvTest(const char *Cmd) {
+ char cmdp = param_getchar(Cmd, 0);
+ if ( cmdp == 'h' || cmdp == 'H') return usage_hf_emv_test();
+
+ UsbCommand c = {CMD_EMV_TEST, {0, 0, 0}};
+ clearCommandBuffer();
+ SendCommand(&c);
+ UsbCommand resp;
+ if (!WaitForResponseTimeout(CMD_ACK, &resp, 2000)) {
+ PrintAndLog("Command execute time-out");
+ return 1;
+ }
+ uint8_t isOK = resp.arg[0] & 0xff;
+ PrintAndLog("isOk: %02x", isOK);
+ return 0;
+}
+
+int CmdHfEmvReadRecord(const char *Cmd) {
+ char cmdp = param_getchar(Cmd, 0);
+ if ((strlen(Cmd)<3) || cmdp == 'h' || cmdp == 'H') return usage_hf_emv_readrecord();
+
+ uint8_t record = param_get8(Cmd, 0);
+ uint8_t sfi = param_getchar(Cmd, 1);
+ if(record > 32){
+ PrintAndLog("Record must be less than 32");
+ return 1;
+ }
+ PrintAndLog("--record no:%02x SFI:%02x ", record, sfi);
+
+ UsbCommand c = {CMD_EMV_READ_RECORD, {record, sfi, 0}};
+ clearCommandBuffer();
+ SendCommand(&c);
+ UsbCommand resp;
+ if (!WaitForResponseTimeout(CMD_ACK, &resp, 2000)) {
+ PrintAndLog("Command execute timeout");
+ return 1;
+ }
+ uint8_t isOK = resp.arg[0] & 0xff;
+ PrintAndLog("isOk:%02x", isOK);
+ return 0;
+}
+
+int CmdHfEmvClone(const char *Cmd) {
+ char cmdp = param_getchar(Cmd, 0);
+ if ((strlen(Cmd)<3) || cmdp == 'h' || cmdp == 'H') return usage_hf_emv_clone();
+
+ uint8_t record = param_get8(Cmd, 0);
+ uint8_t sfi = param_get8(Cmd, 1);
+ if(record > 32){
+ PrintAndLog("Record must be less than 32");
+ return 1;
+ }
+ UsbCommand c = {CMD_EMV_CLONE, {sfi, record, 0}};
+ clearCommandBuffer();
+ SendCommand(&c);
+ UsbCommand resp;
+ if (!WaitForResponseTimeout(CMD_ACK, &resp, 2000)) {
+ PrintAndLog("Command execute timeout");
+ return 1;
+ }
+ uint8_t isOK = resp.arg[0] & 0xff;
+ PrintAndLog("isOk:%02x", isOK);
+ return 0;
+}