}
-static void iso14a_set_timeout(uint32_t timeout) {
+void iso14a_set_timeout(uint32_t timeout) {
iso14a_timeout = timeout;
if(MF_DBGLEVEL >= 3) Dbprintf("ISO14443A Timeout set to %ld (%dms)", iso14a_timeout, iso14a_timeout / 106);
}
int cascade_level = 0;
int len;
+ // init card struct
+ if(p_hi14a_card) {
+ p_hi14a_card->uidlen = 0;
+ memset(p_hi14a_card->uid, 0, 10);
+ p_hi14a_card->ats_len = 0;
+ }
+
// Broadcast for a card, WUPA (0x52) will force response from all cards in the field
ReaderTransmitBitsPar(wupa, 7, NULL, NULL);
if(p_hi14a_card) {
memcpy(p_hi14a_card->atqa, resp, 2);
- p_hi14a_card->uidlen = 0;
- memset(p_hi14a_card->uid,0,10);
}
if (anticollision) {
if(p_hi14a_card) {
p_hi14a_card->sak = sak;
- p_hi14a_card->ats_len = 0;
}
- // non iso14443a compliant tag
- if( (sak & 0x20) == 0) return 2;
+ // PICC compilant with iso14443a-4 ---> (SAK & 0x20 != 0)
+ if( (sak & 0x20) == 0) return 2;
if (!no_rats) {
// Request for answer to select
size_t lenbits = c->arg[1] >> 16;
uint32_t timeout = c->arg[2];
uint32_t arg0 = 0;
- byte_t buf[USB_CMD_DATA_SIZE];
+ byte_t buf[USB_CMD_DATA_SIZE] = {0};
uint8_t par[MAX_PARITY_SIZE];
+ bool cantSELECT = false;
if(param & ISO14A_CONNECT) {
clear_trace();
}
if(param & ISO14A_CONNECT) {
+ LED_A_ON();
+ clear_trace();
iso14443a_setup(FPGA_HF_ISO14443A_READER_LISTEN);
if(!(param & ISO14A_NO_SELECT)) {
iso14a_card_select_t *card = (iso14a_card_select_t*)buf;
arg0 = iso14443a_select_card(NULL, card, NULL, true, 0, param & ISO14A_NO_RATS);
+
+ // if we cant select then we cant send data
+ if (arg0 != 1 && arg0 != 2) {
+ // 1 - all is OK with ATS, 2 - without ATS
+ cantSELECT = true;
+ }
+
+ LED_B_ON();
cmd_send(CMD_ACK,arg0,card->uidlen,0,buf,sizeof(iso14a_card_select_t));
+ LED_B_OFF();
}
}
iso14a_set_timeout(timeout);
}
- if(param & ISO14A_APDU) {
+ if(param & ISO14A_APDU && !cantSELECT) {
arg0 = iso14_apdu(cmd, len, buf);
+ LED_B_ON();
cmd_send(CMD_ACK,arg0,0,0,buf,sizeof(buf));
+ LED_B_OFF();
}
- if(param & ISO14A_RAW) {
+ if(param & ISO14A_RAW && !cantSELECT) {
if(param & ISO14A_APPEND_CRC) {
if(param & ISO14A_TOPAZMODE) {
AppendCrc14443b(cmd,len);
}
}
arg0 = ReaderReceive(buf, par);
+
+ LED_B_ON();
cmd_send(CMD_ACK,arg0,0,0,buf,sizeof(buf));
+ LED_B_OFF();
}
if(param & ISO14A_REQUEST_TRIGGER) {