Hello. I try to emulate EMV card on my PN532. I use code:
#include <SPI.h>
#include <Adafruit_PN532.h>
#define PN532_SCK (10)
#define PN532_MISO (12)
#define PN532_MOSI (11)
#define PN532_SS (13)
Adafruit_PN532 nfc(PN532_SCK, PN532_MISO, PN532_MOSI, PN532_SS);
void setup()
{
Serial.begin(115200);
while (!Serial) delay(10);
Serial.println("Hello!");
nfc.begin();
delay(2000);
uint32_t versiondata = nfc.getFirmwareVersion();
if (! versiondata) {
Serial.print("Didn't find PN53x board");
while (1); // halt
}
Serial.print("Found chip PN5"); Serial.println((versiondata >> 24) & 0xFF, HEX);
Serial.print("Firmware ver. "); Serial.print((versiondata >> 16) & 0xFF, DEC);
Serial.print('.'); Serial.println((versiondata >> 8) & 0xFF, DEC);
nfc.setPassiveActivationRetries(0xFF);
Serial.println("As Target... Approach the NFC PN532 Board to a PoS or terminal!");
delay(200);
}
void loop()
{
uint8_t apdubuffer[255] = {}, apdulen = 0;
nfc.AsTarget();
(void)nfc.getDataTarget(apdubuffer, &apdulen);
if (apdulen > 0) {
Serial.println("____Step 1");
Serial.println("GET AID REQ");
for (uint8_t i = 0; i < apdulen; i++) {
Serial.print(" 0x"); Serial.print(apdubuffer[i], HEX);
}
Serial.println("");
uint8_t PDOL_send [] = {0x8E, 0x6F, 0x3B, 0x84, 0x07, 0xA0, 0x00, 0x00, 0x00, 0x04, 0x10, 0x10, 0xA5, 0x30, 0x50, 0x10, 0x44, 0x45, 0x42, 0x49, 0x54, 0x20, 0x4D, 0x41, 0x53, 0x54, 0x45, 0x52, 0x43, 0x41, 0x52, 0x44, 0x87, 0x01, 0x01, 0x5F, 0x2D, 0x06, 0x75, 0x61,
0x75, 0x6B, 0x65, 0x6E, 0xBF, 0x0C, 0x0F, 0x9F, 0x4D, 0x02, 0x0B, 0x0A, 0x9F, 0x6E, 0x07, 0x08, 0x04, 0x00, 0x00, 0x30, 0x30, 0x00, 0x90, 0x00
};
nfc.setDataTarget(PDOL_send, sizeof(PDOL_send));
}
}
I change PN532_PACKBUFFSIZ in Adafruit_PN532.cpp and set size in 255.
Then, when I tap PN532 on real POS-terminal I get incoming request and on terminal i saw received PDOL data. Then all is work.
But when i try tap PN532 on acr122u card reader - it's make "beep" but nothing to print in serial monitoring.
As I thing, the trouble is in getDataTarget function, in library it's look like:
uint8_t Adafruit_PN532::getDataTarget(uint8_t *cmd, uint8_t *cmdlen) {
uint8_t length;
pn532_packetbuffer[0] = 0x86;
if (!sendCommandCheckAck(pn532_packetbuffer, 1, 3000)) {
PN532DEBUGPRINT.println(F("Error en ack"));
return false;
}
// read data packet
readdata(pn532_packetbuffer, 64);
length = pn532_packetbuffer[3] - 3;
// if (length > *responseLength) {// Bug, should avoid it in the reading
// target data
// length = *responseLength; // silent truncation...
//}
for (int i = 0; i < length; ++i) {
cmd[i] = pn532_packetbuffer[8 + i];
}
*cmdlen = length;
return true;
}
maybe for acr122u need send something else besides 0x86 (or any other ask byte...) - I can't find any information...
If anyone known what can be trouble - please help, thanks!
P.S. PN532 connection to Arduino pro micro over SPI