Hello there. I am trying to get APDU response from reader with PN512 chip but without success. Any one who have that problem already and can help ? I recieve wrong answer on that command. Here is my code:
#include <SPI.h>
#include <MFRC522.h>
#define SS_PIN 2
#define RST_PIN 3
MFRC522::StatusCode status;
MFRC522 rfid(SS_PIN, RST_PIN);
void setup() {
Serial.begin(115200);
Serial.setTimeout(1);
SPI.begin(); // init SPI bus
rfid.PCD_Init(); // init MFRC522
rfid.PCD_SetAntennaGain(rfid.RxGain_max);
//rfid.PCD_SetAntennaGain(112);
rfid.PCD_AntennaOn();
Serial.println("Tap RFID/NFC Tag on reader");
}
void loop() {
byte bufferATQA[10];
byte bufferSize = sizeof(bufferATQA);
// reply only when you receive data:
if (Serial.available() > 0) {
// read the incoming byte:
String incomingByte = Serial.readString();
incomingByte.trim();
Serial.println(incomingByte);
}
if (rfid.PICC_IsNewCardPresent()) {
rfid.PICC_WakeupA(bufferATQA, &bufferSize);
rfid.PICC_RequestA(bufferATQA, bufferSize);
MFRC522::StatusCode status;
byte sendData[] = {
0x00,
0xA4,
0x04,
0x00,
0x0e,
0x32,
0x50,
0x41,
0x59,
0x2e,
0x53,
0x59,
0x53,
0x2e,
0x44,
0x44,
0x46,
0x30,
0x31,
0x00
};
byte backData[255];
byte backLen;
status = rfid.PCD_TransceiveData(sendData, sizeof(sendData), backData, backLen);
if ( status != MFRC522::STATUS_OK) {
Serial.print(F("PCD_TransceiveData() failed: "));
Serial.println(rfid.GetStatusCodeName(status));
return;
}
else
{
Serial.println(F("PICC_TransceiveData() success "));
for(int i = 0; i < sizeof(backData); i++) {
Serial.print(backData[i], HEX);
}
Serial.println("---------------");
}
rfid.PICC_HaltA(); // halt PICC
rfid.PCD_StopCrypto1(); // stop encryption on PCD
}
}
thx