1

I am working over emulating ndef tags with acr122U device(PN532 chip). My start point was the question at How to card emulate with ACR122U-A9. I can manage device (I can change led or buzzer states) with direct commands. But could not get a response from device when I pass tgInitAsTarget command. There is no an error, I am getting empty response when I pass tgInitAsTarget.

I am working over an windows 10 machine with Java, the acr122u firmware is ACR122U215 version.

Here is my commands and responses:

Read registers
<< FF 00 00 00 08 D4 06 63 05 63 0D 63 38 
>> D5 07 07 00 05 90 00 

Write registers
<< FF 00 00 00 11 D4 08 63 02 80 63 03 80 63 05 07 63 0D 00 63 38 05 
>> D5 09 90 00 

Set parameters
<< FF 00 00 00 03 D4 12 30 
>> D5 13 90 00 

tgInitAsTargetCommand
<< FF 00 00 00 27 D4 8C 05 04 00 12 34 56 20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
>>      

There should be a response, but I could not get response, and I wonder what is wrong?

tgInitAsTargetCommand
<< FF 00 00 00 27 D4 8C 05 04 00 12 34 56 20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
>>          //??Why could not I get response?         
zacoder
  • 91
  • 11
  • Got the same issue. Have you managed to solve it? – Kong Chun Ho Jun 01 '19 at 19:23
  • Maybe an insight for this issue. Referring to Michael's comment here: https://stackoverflow.com/questions/21051315/nfc-acr122-tginitastarget-initiator-releasing-target the `tgInitAsTargetCommand` is a blocking command and will return empty response until a reader apporach to the emulated tag. – Kong Chun Ho Jun 01 '19 at 19:27
  • 1
    Yes I have read about the `tgInitAsTargetCommand` is a blocking command, but I do not know how to get callback from pn532 when a reader connected. It necessary getting that callback before sending `tgGetData` and `tgSetData` commands. If I send `tgGetData` and `tgSetData` after `tgInitAsTargetCommand` ,I am getting D5 87 25 90 00 . Which 25 is not the expected response code. – zacoder Jun 02 '19 at 11:01
  • Sayer I have seemed to have solved this issue now. Whenever I am not getting response from tgInitAsTargetCommand, I will resend the same command. I will eventually get a response. Same thing with `TG_GET_DATA` too. If this works for you, I will write up the answer. – Kong Chun Ho Jun 03 '19 at 22:15
  • Kong Chun Ho, I tried your suggestion but unfortunately it did not worked on me. I am using javax.smartcardio.Card to connect to the reader, and transmitControlCommand always returns empty bytes. Even if I send it again and again . But using nfctools app I can see that the reader is starting emulating tag, but because of I could not communicate with device by sending 'tgGetData' and 'tgSetData' commands, i could not emulate content of a tag. So I could not understand what is the problem? – zacoder Jun 05 '19 at 23:08
  • I looped the (same) `tgInitAsTarget` command until I get a non-empty response. Then, I can supply tgGet/SetData APDU. – Kong Chun Ho Jun 06 '19 at 14:36
  • The `tgInitAsTarget` will return nothing until a reader is approached to the emulated tag, then the `tgInitAsTarget` APDU will return a valid, non-empty response. – Kong Chun Ho Jun 06 '19 at 20:53
  • I have put the reader(an android phone) on acr122u before I have sent 'tgInitAsTarget' command. And looped until getting a response from that command. but it did not gave response, all responses are empty. here is the code, it is looping forever even if I put reader on it : https://codeshare.io/5gE8e8 – zacoder Jun 07 '19 at 08:51
  • @zacoder I'm getting the same [ 87 25 ] response to TgGetData commands. According to the PN532 User Guide the 25 is an error code meaning "DEP Protocol: Invalid device state, the system is in a state which does not allow the operation". In my case I'm pretty sure that's because I (successfully) TgInitAsTarget'ed my emulator in passive mode only (mode byte = 0x01), no DEP. You are passing 0x05 for your mode, which if I read the doc correctly is both passive and PICC, but no DEP. Perhaps we both need to reconsider the mode we are using. – Opsimath Jul 16 '19 at 19:35

0 Answers0