+int CmdHF14AReader(const char *Cmd) {
+ uint32_t cm = ISO14A_CONNECT;
+ bool disconnectAfter = true;
+
+ int cmdp = 0;
+ while(param_getchar(Cmd, cmdp) != 0x00) {
+ switch(param_getchar(Cmd, cmdp)) {
+ case 'h':
+ case 'H':
+ PrintAndLog("Usage: hf 14a reader [k|x] [3]");
+ PrintAndLog(" k keep the field active after command executed");
+ PrintAndLog(" x just drop the signal field");
+ PrintAndLog(" 3 ISO14443-3 select only (skip RATS)");
+ return 0;
+ case '3':
+ cm |= ISO14A_NO_RATS;
+ break;
+ case 'k':
+ case 'K':
+ disconnectAfter = false;
+ break;
+ case 'x':
+ case 'X':
+ cm &= ~ISO14A_CONNECT;
+ break;
+ default:
+ PrintAndLog("Unknown command.");
+ return 1;
+ }
+
+ cmdp++;
+ }
+
+ if (!disconnectAfter)
+ cm |= ISO14A_NO_DISCONNECT;
+
+ UsbCommand c = {CMD_READER_ISO_14443a, {cm, 0, 0}};
+ SendCommand(&c);
+
+ if (ISO14A_CONNECT & cm) {
+ UsbCommand resp;
+ WaitForResponse(CMD_ACK,&resp);
+
+ iso14a_card_select_t card;
+ memcpy(&card, (iso14a_card_select_t *)resp.d.asBytes, sizeof(iso14a_card_select_t));
+
+ uint64_t select_status = resp.arg[0]; // 0: couldn't read, 1: OK, with ATS, 2: OK, no ATS, 3: proprietary Anticollision
+
+ if(select_status == 0) {
+ PrintAndLog("iso14443a card select failed");
+ return 1;
+ }
+
+ if(select_status == 3) {
+ PrintAndLog("Card doesn't support standard iso14443-3 anticollision");
+ PrintAndLog("ATQA : %02x %02x", card.atqa[1], card.atqa[0]);
+ return 1;
+ }
+
+ PrintAndLog(" UID : %s", sprint_hex(card.uid, card.uidlen));
+ PrintAndLog("ATQA : %02x %02x", card.atqa[1], card.atqa[0]);
+ PrintAndLog(" SAK : %02x [%" PRIu64 "]", card.sak, resp.arg[0]);
+ if(card.ats_len >= 3) { // a valid ATS consists of at least the length byte (TL) and 2 CRC bytes
+ PrintAndLog(" ATS : %s", sprint_hex(card.ats, card.ats_len));
+ }
+ if (!disconnectAfter) {
+ PrintAndLog("Card is selected. You can now start sending commands");
+ }
+ }
+
+ if (disconnectAfter) {
+ PrintAndLog("Field dropped.");
+ }
+
+ return 0;
+}
+
+int CmdHF14AInfo(const char *Cmd)