Search code examples
androidnfcapdusmartcard-readerhce

How to handle S-block received by reader?


I use MFRC522 as the reader, while Sony C4 is executing Google HCE sample. The reader is sending frame 1:

02 00 A4 04 00 07 F0 01 02 03 04 05 06 crc1 crc2

Then the reader receives frame 2:

f2 08 50 dd

I think it may be an S-block or WTX.

However the log of the HCE app shows:

received apdu 00 A4 04 00 07 F0 01 02 03 04 05 06

sending account number number 123456

Even if the reader sends frame 1 again and again, I always receive the same frame 2, why?


Solution

  • f2 08 50 dd is an S-block indicating a waiting time extension (WTX):

    • PCB = f2:
      • Bit 8..7 = '11': S-block
      • Bit 6..5 = '11': S(WTX)
    • INF = 08:
      • WTXM = 8
    • EDC = 50 dd

    If the reader receives a S(WTX) request from the card, it needs to acknowledge this request by responding with a S(WTX) frame. Thus, you could, for instance, send the same S(WTX) frame back to the card.

    As HCE processing is usually rather slow, it's not uncommon to exchange multiple S(WTX) frames before you actually receive any response data for the APDU.