Ok, as promised here goes.
Set Parameters
Either issue the following APDU commands directly or use the ACR122 tool's GUI.
to disable auto PICC polling
to disable auto ATS generation
ACR122U Tool->Reader Commands->PICC Operating Parameter->Set PICC .....
Disable "Auto PICC Polling"
Disable "Auto ATS Generation"
These parameters are reset everytime the reader is disconnected for me (so you may want to send the APDUs programmatically)
Then use the following command to 'poll' for a card:
Code:
FF 00 00 00 04 D4 4A 01 00
The response (if a card/phone is connected) should be in the following format:
Code:
D5 4B 01 01 00 02 38 04 UU UU UU UU 90 00
where UU is the UID of the connected tag. (the 04 prior to it denotes the length of UID, in my case, 4 bytes)
You now use this UID in your authentication command.
Code:
FF 00 00 00 0F D4 40 01 60 BB FF FF FF FF FF FF UU UU UU UU
where BB is the block to authenticate, UU is the discovered UID and you can replace FF FF... with a keyset relevant to you. (I think this is for Key A, change the 60 to 61 for Key B *i think*)
A response should be in the following format:
- if the third byte isn't 00 - then there was an error.
You have now authenticated a block with a keyset for a particular UID.
All that is left is to read the block:
Code:
FF 00 00 00 05 D4 40 01 30 BB
where BB is the block to be read.
You should get a response like the following:
Code:
D5 41 00 01 00 00 00 FE FF FF FF 01 00 00 00 00 FF 00 FF 90 00
where the first three bytes and the last two bytes are status codes, the remaining 16 is your data.
If the third byte is not 00, you had an error.
FYI, this is not very stable. I often receive an error back when authenticating or when reading, and there's no reason i can see. My only hope is to re-poll, re-authenticate and re-read upon receiving an error.
Let me know if this helps, i'm quite keen to know!
Cheers