Dear kavi,
thanks for your reply. It clarified the method but still no success. Below is the condensed version of my ardu code which flips pins when the networking happens. Still, any previous link is down or cannot be created inside. Guess I’m still doing it wrong.
Thanks a bunch,
o.
[code]#include <Ethernet2.h>
#include <SPI.h>
#include “PN532_SPI.h”
#include “PN532.h”
#include “NfcAdapter.h”
// ottona: default pin is 10, this one here is needed for the leonardo eth
PN532_SPI interface(SPI, 9); // create a PN532 SPI interface with the SPI CS terminal located at digital pin 9
NfcAdapter nfc = NfcAdapter(interface); // create an NFC adapter object
byte mac[] = { 0x90, 0xA2, 0xDA, 0x10, 0x1B, 0x97 };
byte server[] = { 192, 168, 5, 76 };
byte myip[] = { 192, 168, 5, 115 };
void setup(void) {
Serial.begin(115200); // begin serial communication
Serial.println(“NDEF Reader”);
delay(1000);
pinMode(4, OUTPUT);
pinMode(9, OUTPUT);
digitalWrite(4, HIGH);
pinMode(10, OUTPUT);
Ethernet.begin(mac, myip);
Serial.println(Ethernet.localIP());
digitalWrite(10, HIGH);
digitalWrite(9, LOW);
nfc.begin(); // begin NFC communication
}
void loop(void) {
if (nfc.tagPresent()) // Do an NFC scan to see if an NFC tag is present
{
NfcTag tag = nfc.read(); // read the NFC tag into an object, nfc.read() returns an NfcTag object.
tag.print(); // prints the NFC tags type, UID, and NDEF message (if available)
digitalWrite(9, HIGH); // disable nfc shield
digitalWrite(10, LOW); // enable networking
EthernetUDP udp;
udp.beginPacket(server, 44789);
udp.write("TESTMSG"/*tag.getUidString()*/);
udp.endPacket();
digitalWrite(10, HIGH); // disable networking
digitalWrite(9, LOW); // enable nfc shield
}
delay(500); // wait half a second (500ms) before scanning again (you may increment or decrement the wait time)
}[/code]