initial commit
This commit is contained in:
30
examples/P2P_Receive/P2P_Receive.ino
Normal file
30
examples/P2P_Receive/P2P_Receive.ino
Normal file
@@ -0,0 +1,30 @@
|
||||
// Receive a NDEF message from a Peer
|
||||
// Requires SPI. Tested with Seeed Studio NFC Shield v2
|
||||
|
||||
#include "SPI.h"
|
||||
#include "PN532_SPI.h"
|
||||
#include "snep.h"
|
||||
#include "NdefMessage.h"
|
||||
|
||||
PN532_SPI pn532spi(SPI, 10);
|
||||
SNEP nfc(pn532spi);
|
||||
uint8_t ndefBuf[128];
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
Serial.println("NFC Peer to Peer Example - Receive Message");
|
||||
}
|
||||
|
||||
void loop() {
|
||||
Serial.println("Waiting for message from Peer");
|
||||
int msgSize = nfc.read(ndefBuf, sizeof(ndefBuf));
|
||||
if (msgSize > 0) {
|
||||
NdefMessage msg = NdefMessage(ndefBuf, msgSize);
|
||||
msg.print();
|
||||
Serial.println("\nSuccess");
|
||||
} else {
|
||||
Serial.println("Failed");
|
||||
}
|
||||
delay(3000);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user