@@ -48,7 +48,7 @@ uint8_t ISO14443ALastDataFrame[MAX_DATA_FRAME_XFER_SIZE] = { 0x00 };
48
48
uint16_t ISO14443ALastDataFrameBits = 0 ;
49
49
50
50
bool CheckStateRetryCount2 (bool resetByDefault , bool performLogging ) {
51
- if (resetByDefault || ++ StateRetryCount >= MAX_STATE_RETRY_COUNT ) {
51
+ if (resetByDefault || ++ StateRetryCount > MAX_STATE_RETRY_COUNT ) {
52
52
ISO144434SwitchState2 (Iso144433AIdleState , performLogging );
53
53
StateRetryCount = 0x00 ;
54
54
const char * debugStatusMsg = PSTR ("RETRY-RESET" );
@@ -311,16 +311,16 @@ uint16_t ISO144433APiccProcess(uint8_t *Buffer, uint16_t BitCount) {
311
311
312
312
/* Wakeup and Request may occure in all states */
313
313
bool checkStateRetryStatus = CheckStateRetryCount (false);
314
- bool decrementRetryCount = true;
314
+ bool incrementRetryCount = true;
315
315
if ((Cmd == ISO14443A_CMD_REQA ) && (LastReaderSentCmd == ISO14443A_CMD_REQA ) && !checkStateRetryStatus ) {
316
316
/* Catch timing issues where the reader sends multiple
317
- REQA bytes, in between which we would have already sent
318
- back a response, so that we should not reset. */
319
- decrementRetryCount = false;
317
+ REQA bytes, in between which we would have already sent
318
+ back a response, so that we should not reset. */
319
+ incrementRetryCount = false;
320
320
} else if (Cmd == ISO14443A_CMD_REQA || ISO14443ACmdIsWUPA (Cmd )) {
321
321
ISO144434Reset ();
322
322
ISO144433ASwitchState (ISO14443_3A_STATE_IDLE );
323
- decrementRetryCount = false;
323
+ incrementRetryCount = false;
324
324
} else if (ISO144433AIsHalt (Buffer , BitCount )) {
325
325
LogEntry (LOG_INFO_APP_CMD_HALT , NULL , 0 );
326
326
ISO144433ASwitchState (ISO14443_3A_STATE_HALT );
@@ -332,8 +332,8 @@ uint16_t ISO144433APiccProcess(uint8_t *Buffer, uint16_t BitCount) {
332
332
return ISO14443A_APP_NO_RESPONSE ;
333
333
}
334
334
LastReaderSentCmd = Cmd ;
335
- if (decrementRetryCount && StateRetryCount > 0 ) {
336
- StateRetryCount - = 1 ;
335
+ if (incrementRetryCount ) {
336
+ StateRetryCount + = 1 ;
337
337
}
338
338
339
339
/* This implements ISO 14443-3A state machine */
@@ -406,17 +406,20 @@ uint16_t ISO144433APiccProcess(uint8_t *Buffer, uint16_t BitCount) {
406
406
break ;
407
407
408
408
case ISO14443_3A_STATE_ACTIVE :
409
+ StateRetryCount = MAX_STATE_RETRY_COUNT ;
409
410
/* Recognise the HLTA command */
410
411
if (ISO144433AIsHalt (Buffer , BitCount )) {
411
412
LogEntry (LOG_INFO_APP_CMD_HALT , NULL , 0 );
412
413
ISO144434SwitchState (ISO14443_3A_STATE_HALT );
413
414
const char * logMsg = PSTR ("ISO14443-3: Got HALT" );
414
415
LogDebuggingMsg (logMsg );
415
416
return ISO14443A_APP_NO_RESPONSE ;
416
- } else if (Cmd == ISO14443A_CMD_RATS ) {
417
+ } else if (Cmd == ISO14443A_CMD_RATS ) {
417
418
ISO144433ASwitchState (ISO14443_4_STATE_EXPECT_RATS );
418
419
const char * logMsg = PSTR ("ISO14443-3/4: EXPECTING RATS" );
419
420
LogDebuggingMsg (logMsg );
421
+ } else if (Cmd == ISO14443A_CMD_SELECT_CL3 ) {
422
+ return ISO14443A_APP_NO_RESPONSE ;
420
423
}
421
424
/* Forward to ISO/IEC 14443-4 processing code */
422
425
uint16_t ByteCount = (BitCount + BITS_PER_BYTE - 1 ) / BITS_PER_BYTE ;
0 commit comments