#include "PN_532_HW_UART.h"
/*
++++Create a new object instance++++
--
PN_532_HW_UART NFC(&Serial1);
--
++++Connect the created object to the selected serial++++
--
NFC.StartSerial_PN532();
--
++++Configure and start the PN532 object, returns true if successfull++++
--
bool success = NFC.Start_PN532();
--
++++Read firmware version from the PN532 board++++
-If successfull returns the FirmWare version as a decimal value (typically close to 1543 dec)
-If not successful returns firmware version as 0 dec
--
int FirmWare = NFC.GetFirmWareVersion_PN532();
--
++++Read the 4-byte UID value++++
-If key is recognized: Returns true and the array contains the key's UID
-If key is not recognized: Returns false and the array contains garbage and must be ignored!
-The returned UID is padded with 4 additional 0-bytes so the total UID is 8 bytes.
--
byte UIDbuffer[8] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
bool success = NFC.Get_UID_PN532( UIDbuffer );
--
*/
PN_532_HW_UART NFC(&Serial1); //Any serial object; Serial, Serial1, Serial2, Serial3, SoftWareSerial...
void setup()
{
//**********************
NFC.StartSerial_PN532(); //ALWAYS !!
//**********************
//---------------------------------------------------------------------
if ( NFC.Start_PN532() == false) //Startforsøk var misslykket
{
Serial1.print( "Problem med start av PN532 kortet, mulig kommunikasjonsfeil...");
Serial1.println();
}
else
{
Serial1.print( "PN532 kortet har startet...");
Serial1.println();
}
Serial1.println();
Serial1.println();
Serial1.println();
//---------------------------------------------------------------------
//delay(500);
}
void loop()
{
//---------------------------------------------------------------------
int data = 0;
data = NFC.GetFirmWareVersion_PN532();
if ( data == 0)
{
Serial1.print( "Ikke kontakt med PN532 kortet...");
Serial1.println();
}
else
{
Serial1.print( data);
Serial1.println();
}
Serial1.println();
Serial1.println();
Serial1.println();
//---------------------------------------------------------------------
//---------------------------------------------------------------------
byte UIDbuffer[8] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
if (NFC.Get_UID_PN532( UIDbuffer ) == true)
{
for (int i = 0; i < 8; i++)
{
if (UIDbuffer[i] < 0x10) Serial1.print("0");//DEBUG
Serial1.print( UIDbuffer[i], HEX ); Serial1.print(" "); //DEBUG
}
Serial1.println();
}
else
{
Serial1.print( "Ser ingen nøkkel...");
Serial1.println();
}
Serial1.println();
Serial1.println();
Serial1.println();
//---------------------------------------------------------------------
delay(300);
}