* allow additional 2 ssp_frame cycles to detect SOF
* use only respective functions to get/set iso14a_timeout
* remove waiting time in MifareAcquireEncryptedNonces(). This is covered by GetATQA() now.
void iso14a_set_timeout(uint32_t timeout) {
void iso14a_set_timeout(uint32_t timeout) {
- iso14a_timeout = timeout - (DELAY_AIR2ARM_AS_READER + DELAY_ARM2AIR_AS_READER)/(16*8);
+ iso14a_timeout = timeout - (DELAY_AIR2ARM_AS_READER + DELAY_ARM2AIR_AS_READER)/(16*8) + 2;
if(MF_DBGLEVEL >= 3) Dbprintf("ISO14443A Timeout set to %ld (%dms)", timeout, timeout / 106);
}
uint32_t iso14a_get_timeout(void) {
if(MF_DBGLEVEL >= 3) Dbprintf("ISO14443A Timeout set to %ld (%dms)", timeout, timeout / 106);
}
uint32_t iso14a_get_timeout(void) {
- return iso14a_timeout + (DELAY_AIR2ARM_AS_READER + DELAY_ARM2AIR_AS_READER)/(16*8);
+ return iso14a_timeout + (DELAY_AIR2ARM_AS_READER + DELAY_ARM2AIR_AS_READER)/(16*8) - 2;
}
//-----------------------------------------------------------------------------
}
//-----------------------------------------------------------------------------
} else{
// S-Block WTX
while((data_bytes[0] & 0xF2) == 0xF2) {
} else{
// S-Block WTX
while((data_bytes[0] & 0xF2) == 0xF2) {
- uint32_t save_iso14a_timeout = iso14a_timeout;
+ uint32_t save_iso14a_timeout = iso14a_get_timeout();
// temporarily increase timeout
// temporarily increase timeout
- iso14a_timeout = MAX((data_bytes[1] & 0x3f) * iso14a_timeout, MAX_ISO14A_TIMEOUT);
+ iso14a_set_timeout(MAX((data_bytes[1] & 0x3f) * save_iso14a_timeout, MAX_ISO14A_TIMEOUT));
// Transmit WTX back
// byte1 - WTXM [1..59]. command FWT=FWT*WTXM
data_bytes[1] = data_bytes[1] & 0x3f; // 2 high bits mandatory set to 0b
// Transmit WTX back
// byte1 - WTXM [1..59]. command FWT=FWT*WTXM
data_bytes[1] = data_bytes[1] & 0x3f; // 2 high bits mandatory set to 0b
len = ReaderReceive(data, parity);
data_bytes = data;
// restore timeout
len = ReaderReceive(data, parity);
data_bytes = data;
// restore timeout
- iso14a_timeout = save_iso14a_timeout;
+ iso14a_set_timeout(save_iso14a_timeout);
}
// if we received an I- or R(ACK)-Block with a block number equal to the
}
// if we received an I- or R(ACK)-Block with a block number equal to the
- // send a dummy byte as reader response in order to trigger the cards authentication timeout\r
- uint8_t dummy_answer = 0;\r
- ReaderTransmit(&dummy_answer, 1, NULL);\r
- timeout = GetCountSspClk() + AUTHENTICATION_TIMEOUT;\r
+ // send a dummy response in order to trigger the cards authentication failure timeout\r
+ uint8_t dummy_answer[8] = {0};\r
+ ReaderTransmit(dummy_answer, 8, NULL);\r
\r
num_nonces++;\r
if (num_nonces % 2) {\r
\r
num_nonces++;\r
if (num_nonces % 2) {\r
- // wait for the card to become ready again\r
- while(GetCountSspClk() < timeout);\r
-\r