+// menu command to get and print all info known about any known 14b tag
+int CmdHF14Binfo(const char *Cmd){
+ char cmdp = param_getchar(Cmd, 0);
+ if (cmdp == 'h' || cmdp == 'H') return usage_hf_14b_info();
+
+ bool verbose = !((cmdp == 's') || (cmdp == 'S'));
+ return HF14BInfo(verbose);
+}
+
+bool HF14B_ST_Reader(bool verbose){
+
+ bool isSuccess = FALSE;
+
+ switch_on_field_14b();
+
+ // SRx get and print general info about SRx chip from UID
+ UsbCommand c = {CMD_ISO_14443B_COMMAND, {ISO14B_SELECT_SR, 0, 0}};
+ clearCommandBuffer();
+ SendCommand(&c);
+ UsbCommand resp;
+ if (!WaitForResponseTimeout(CMD_ACK, &resp, TIMEOUT)) {
+ if (verbose) PrintAndLog("timeout while waiting for reply.");
+ return FALSE;
+ }
+
+ iso14b_card_select_t card;
+ memcpy(&card, (iso14b_card_select_t *)resp.d.asBytes, sizeof(iso14b_card_select_t));
+
+ uint64_t status = resp.arg[0];
+
+ switch( status ){
+ case 0:
+ print_st_general_info(card.uid, card.uidlen);
+ isSuccess = TRUE;
+ break;
+ case 1:
+ if (verbose) PrintAndLog("iso14443-3 random chip id fail");
+ break;
+ case 2:
+ if (verbose) PrintAndLog("iso14443-3 ATTRIB fail");
+ break;
+ case 3:
+ if (verbose) PrintAndLog("iso14443-3 CRC fail");
+ break;
+ default:
+ if (verbose) PrintAndLog("iso14443b card select SRx failed");
+ break;
+ }
+
+ switch_off_field_14b();
+ return isSuccess;
+}
+
+bool HF14B_Std_Reader(bool verbose){
+
+ bool isSuccess = FALSE;
+
+ // 14b get and print UID only (general info)
+ UsbCommand c = {CMD_ISO_14443B_COMMAND, {ISO14B_CONNECT | ISO14B_SELECT_STD | ISO14B_DISCONNECT, 0, 0}};
+ clearCommandBuffer();
+ SendCommand(&c);
+ UsbCommand resp;
+
+ if (!WaitForResponseTimeout(CMD_ACK, &resp, TIMEOUT)) {
+ if (verbose) PrintAndLog("timeout while waiting for reply.");
+ return FALSE;
+ }
+
+ iso14b_card_select_t card;
+ memcpy(&card, (iso14b_card_select_t *)resp.d.asBytes, sizeof(iso14b_card_select_t));
+
+ uint64_t status = resp.arg[0];
+
+ switch( status ){
+ case 0:
+ PrintAndLog(" UID : %s", sprint_hex(card.uid, card.uidlen));
+ PrintAndLog(" ATQB : %s", sprint_hex(card.atqb, sizeof(card.atqb)));
+ PrintAndLog(" CHIPID : %02X", card.chipid);
+ print_atqb_resp(card.atqb, card.cid);
+ isSuccess = TRUE;
+ break;
+ case 2:
+ if (verbose) PrintAndLog("iso14443-3 ATTRIB fail");
+ break;
+ case 3:
+ if (verbose) PrintAndLog("iso14443-3 CRC fail");
+ break;
+ default:
+ if (verbose) PrintAndLog("iso14443b card select failed");
+ break;
+ }
+
+ switch_off_field_14b();
+ return isSuccess;
+}
+
+// test for other 14b type tags (mimic another reader - don't have tags to identify)
+bool HF14B_Other_Reader(){
+
+ // uint8_t data[] = {0x00, 0x0b, 0x3f, 0x80};
+ // uint8_t datalen = 4;
+
+ // // 14b get and print UID only (general info)
+ // uint32_t flags = ISO14B_CONNECT | ISO14B_SELECT_STD | ISO14B_RAW | ISO14B_APPEND_CRC;
+
+ // UsbCommand c = {CMD_ISO_14443B_COMMAND, {flags, datalen, 0}};
+ // memcpy(c.d.asBytes, data, datalen);
+
+ // clearCommandBuffer();
+ // SendCommand(&c);
+ // UsbCommand resp;
+ // WaitForResponse(CMD_ACK,&resp);
+
+ // if (datalen > 2 ) {
+ // printandlog ("\n14443-3b tag found:");
+ // printandlog ("unknown tag type answered to a 0x000b3f80 command ans:");
+ // //printandlog ("%s", sprint_hex(data, datalen));
+ // rawclose();
+ // return true;
+ // }
+
+ // c.arg1 = 1;
+ // c.d.asBytes[0] = ISO14443B_AUTHENTICATE;
+ // clearCommandBuffer();
+ // SendCommand(&c);
+ // UsbCommand resp;
+ // WaitForResponse(CMD_ACK, &resp);
+
+ // if (datalen > 0) {
+ // PrintAndLog ("\n14443-3b tag found:");
+ // PrintAndLog ("Unknown tag type answered to a 0x0A command ans:");
+ // // PrintAndLog ("%s", sprint_hex(data, datalen));
+ // rawClose();
+ // return TRUE;
+ // }
+
+ // c.arg1 = 1;
+ // c.d.asBytes[0] = ISO14443B_RESET;
+ // clearCommandBuffer();
+ // SendCommand(&c);
+ // UsbCommand resp;
+ // WaitForResponse(CMD_ACK, &resp);
+
+ // if (datalen > 0) {
+ // PrintAndLog ("\n14443-3b tag found:");
+ // PrintAndLog ("Unknown tag type answered to a 0x0C command ans:");
+ // PrintAndLog ("%s", sprint_hex(data, datalen));
+ // rawClose();
+ // return TRUE;
+ // }
+
+ // rawClose();
+ return FALSE;
+}
+
+// get and print general info about all known 14b chips
+bool HF14BReader(bool verbose){
+
+ // try std 14b (atqb)
+ if (HF14B_Std_Reader(verbose)) return TRUE;
+
+ // try ST Microelectronics 14b
+ if (HF14B_ST_Reader(verbose)) return TRUE;
+
+ // try unknown 14b read commands (to be identified later)
+ // could be read of calypso, CEPAS, moneo, or pico pass.
+ if (HF14B_Other_Reader()) return TRUE;
+
+ if (verbose) PrintAndLog("no 14443B tag found");
+ return FALSE;
+}
+
+// menu command to get and print general info about all known 14b chips