+char *get_ST_Chip_Model(uint8_t data){
+ static char model[20];
+ char *retStr = model;
+ memset(model,0, sizeof(model));
+
+ switch (data) {
+ case 0x0: sprintf(retStr, "SRIX4K (Special)"); break;
+ case 0x2: sprintf(retStr, "SR176"); break;
+ case 0x3: sprintf(retStr, "SRIX4K"); break;
+ case 0x4: sprintf(retStr, "SRIX512"); break;
+ case 0x6: sprintf(retStr, "SRI512"); break;
+ case 0x7: sprintf(retStr, "SRI4K"); break;
+ case 0xC: sprintf(retStr, "SRT512"); break;
+ default: sprintf(retStr, "Unknown"); break;
+ }
+ return retStr;
+}
+
+static void print_st_info(uint8_t *data){
+ //uid = first 8 bytes in data
+ PrintAndLog(" UID: %s", sprint_hex(data,8));
+ PrintAndLog(" MFG: %02X, %s", data[1], getTagInfo(data[1]));
+ PrintAndLog("Chip: %02X, %s", data[2]>>2, get_ST_Chip_Model(data[2]>>2));
+ return;
+}
+
+int HF14BStdRead(uint8_t *data, uint8_t *datalen){
+ bool crc = true;
+ *datalen = 3;
+ //std read cmd
+ data[0] = 0x05;
+ data[1] = 0x00;
+ data[2] = 0x08;
+
+ if (HF14BCmdRaw(true, &crc, 0, data, datalen, false)==0) return 0;
+
+ if (data[0] != 0x50 || *datalen != 14 || !crc) return 0;
+
+ PrintAndLog ("\n14443-3b tag found:");
+ print_atqb_resp(data);
+
+ return 1;
+}
+
+int HF14B_ST_Read(uint8_t *data, uint8_t *datalen){
+ bool crc = true;
+ *datalen = 2;
+ //wake cmd
+ data[0] = 0x06;
+ data[1] = 0x00;
+
+ //leave power on
+ // verbose on for now for testing - turn off when functional
+ if (HF14BCmdRaw(true, &crc, 1, data, datalen, true)==0) return rawClose();
+
+ if (*datalen != 3 || !crc) return rawClose();
+
+ uint8_t chipID = data[0];
+ // select
+ data[0] = 0x0E;
+ data[1] = chipID;
+ *datalen = 2;
+
+ //leave power on
+ // verbose on for now for testing - turn off when functional
+ if (HF14BCmdRaw(true, &crc, 1, data, datalen, true)==0) return rawClose();
+
+ if (*datalen != 3 || !crc || data[0] != chipID) return rawClose();
+
+ // get uid
+ data[0] = 0x0B;
+ *datalen = 1;
+
+ //power off
+ // verbose on for now for testing - turn off when functional
+ if (HF14BCmdRaw(true, &crc, 1, data, datalen, true)==0) return 0;
+ rawClose();
+ if (*datalen != 10 || !crc) return 0;
+
+ PrintAndLog("\n14443-3b ST tag found:");
+ print_st_info(data);
+ return 1;
+}
+
+int HF14BReader(bool verbose){
+ uint8_t data[100];
+ uint8_t datalen = 5;
+
+ // try std 14b (atqb)
+ if (HF14BStdRead(data, &datalen)) return 1;
+
+ // try st 14b
+ if (HF14B_ST_Read(data, &datalen)) return 1;
+
+ if (verbose) PrintAndLog("no 14443B tag found");
+ return 0;
+}
+
+int CmdHF14BReader(const char *Cmd){
+ return HF14BReader(true);
+}
+
+int CmdHFRawSamples(const char *Cmd){
+ UsbCommand resp;
+ UsbCommand c = {CMD_ACQUIRE_RAW_ADC_SAMPLES_ISO_14443, {strtol(Cmd,NULL,0), 0, 0}};
+ SendCommand(&c);
+
+ if (!WaitForResponseTimeout(CMD_ACK,&resp,1000)) {
+ PrintAndLog("timeout while waiting for reply.");
+ return 0;
+ }
+ getSamples("39999", true);
+ return 1;
+}
+
+int CmdHF14BWrite( const char *Cmd){