I am currently running android_hce code for arduino attached with PN532 NFC Hat to send Command APDUs to my android APP. APP is running in HCE mode. I want to read the NDEF File/data from the Android App using the arduino. Ndefdata I am trying to send is a String "github.com/AndroidCrypto?tab=repositories"
Sequence of Command APDUs I am sending
complete sequence:
commandApdu: 00a4040007d276000085010100
responseApdu: 9000
commandApdu: 00a4000c02e103
responseApdu: 9000
commandApdu: 00b000000f
responseApdu: 000f20003b00340406e10400ff00ff9000
commandApdu: 00a4000c02e104
responseApdu: 9000
commandApdu: 00b0000002
responseApdu: 00309000
commandApdu: 00b000022e
responseApdu: Error
The error is because of the following part. (debugged)
PN532::inDataExchange(uint8_t *send, uint8_t sendLength, uint8_t *response, uint8_t *responseLength)
.
.
.
int16_t status = HAL(readResponse)(response, *responseLength, 1000);
if (status < 0) {
return false;
}
Arduino code snippet for the last C-APDU
uint8_t fapdu[] = {0x00,
0xb0,
0x00,
0x02,
0x2e};
uint8_t fback[64];
uint8_t flength = 64;
success = nfc.inDataExchange(fapdu, sizeof(fapdu), fback, &flength);
if(success) {
Serial.print("responseLengthfinal Read: "); Serial.println(flength);
nfc.PrintHexChar(fback, flength);
}
else {
Serial.println("Broken connection?");
}
However, the Android Log shows the correct response
commandApdu: 00a4040007d276000085010100
responseApdu: 9000
commandApdu: 00a4000c02e103
responseApdu: 9000
commandApdu: 00b000000f
responseApdu: 000f20003b00340406e10400ff00ff9000
commandApdu: 00a4000c02e104
responseApdu: 9000
commandApdu: 00b0000002
file length: 50
responseApdu: 00309000
commandApdu: 00b000022e
file length: 50
responseApdu: d1012c5402656e6769746875622e636f6d2f416e64726f696443727970746f3f7461623d7265706f7369746f72699000
Android app is implemented using Link.
I am not sure why the arduino code cannot read the response APDU for the final command.
However when I use the following APDU in the final case
uint8_t fapdu[] = {0x00,
0xb0,
0x00,
0x02,
0x14};
responseLengthfinal Read: 22
22:22:47.857 -> D1 01 2C 54 02 65 6E 67 69 74 68 75 62 2E 63 6F 6D 2F 41 6E 90 00 ..,T.engithub.com/An..
But when I use (23 Read Length)
uint8_t fapdu[] = {0x00,
0xb0,
0x00,
0x02,
0x15};
Error in inDataExchange process of nfc.