I try to create an Android app that sends a key to an Arduino NFC Shield. I am able to send the key from the mobile and turn on the LED on the Arduino. But I don't know how to make the NFC shield send back to the Android device a response: valid key or not.
I get the message on Arduino, I am able to turn on the LED when the key is correct. The problem is that I need the NFC Shield to send back a message to the mobile phone, so that the app knows everything worked as expected or not.
I use NFC Shield PN532 (with Adafruit_PN532) in SPI mode.
success = nfc.inListPassiveTarget();
if(success) {
Serial.println("Found something!");
uint8_t selectApdu[] = {
0x00, /* CLA */
0xA4, /* INS */
0x04, /* P1 */
0x00, /* P2 */
0x05, /* Length of AID */
0xF2, 0x22, 0x22, 0x22, 0x22};
uint8_t response[255];
uint8_t responseLength = sizeof(response);
success = nfc.inDataExchange(selectApdu,
sizeof(selectApdu), response, &responseLength);
if(success) {
if(validKey(response, responseLength)){
Serial.println("Acces GRANTED.");
accesGranted();
}else{
Serial.println("Acces DENIED!!!!!!!!!!!!!!!!\n");
}
}
else{
Serial.println("Failed sending SELECT AID");
}
}