Hi
thank you for reading my post, and for your help. I would need advice in the following:
I useing PN7150 as a tag. And use the lib of Electroniccats_PN7150 ,and the demo of “DetectingReaders”。Fortunately, when Reader approached, the log showed ""Reader detected!" ", but actually I want to send a custom "NDEF_MESSAGE" via PN7150。
void setup(){
Serial.begin(115200);
while(!Serial);
Serial.println("Detect P2P devices with PN7150");
Serial.println("Initializing...");
if(T4T_NDEF_EMU_SetMessage((unsigned char *) NDEF_MESSAGE, sizeof(NDEF_MESSAGE), (void*)*NdefPush_Cb))
{
Serial.printf("Set message ok\r\n");
}
else
{
Serial.printf("Set message error\r\n");
if (nfc.connectNCI()) { //Wake up the board
Serial.println("Error while setting up the mode, check connections!");
while (1);
}
if (nfc.ConfigureSettings()) {
Serial.println("The Configure Settings failed!");
while (1);
}
if(nfc.ConfigMode(mode)){ //Set up the configuration mode
Serial.println("The Configure Mode failed!!");
while (1);
}
nfc.StartDiscovery(mode); //NCI Discovery mode
Serial.println("Waiting for a P2P device...");
}
unsigned char STATUSOK[] = {0x90, 0x00}, Cmd[256], CmdSize;
void loop(){
if(nfc.CardModeReceive(Cmd, &CmdSize) == 0) { //Data in buffer?
if ((CmdSize >= 2) && (Cmd[0] == 0x00)) { //Expect at least two bytes
switch (Cmd[1]) {
case 0xA4: //Something tries to select a file, meaning that it is a reader
Serial.println("Reader detected!");
break;
case 0xB0: //SFI
Serial.println("0xB0 detected!");
break;
case 0xD0: //...
Serial.println("0xD0 detected!");
break;
default:
break;
}
nfc.CardModeSend(STATUSOK, sizeof(STATUSOK));
}
}
}
What should I do