summaryrefslogtreecommitdiff
path: root/.pio/libdeps/esp32-s3-n16r8/Adafruit PN532
diff options
context:
space:
mode:
authorkrolyxon <me@krolyxon.com>2026-06-08 23:10:46 +0530
committerkrolyxon <me@krolyxon.com>2026-06-08 23:10:46 +0530
commit3120783000d0025b183b0397acaa8b769499eb38 (patch)
tree1c4f93be213f1b1d48f59e554562d847b4e7c25e /.pio/libdeps/esp32-s3-n16r8/Adafruit PN532
Initial gh-pages firmware hosting
Diffstat (limited to '.pio/libdeps/esp32-s3-n16r8/Adafruit PN532')
-rw-r--r--.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/.github/ISSUE_TEMPLATE.md46
-rw-r--r--.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/.github/PULL_REQUEST_TEMPLATE.md26
-rw-r--r--.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/.github/workflows/githubci.yml32
-rw-r--r--.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/.gitignore4
-rw-r--r--.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/.piopm1
-rw-r--r--.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/Adafruit_PN532.cpp1832
-rw-r--r--.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/Adafruit_PN532.h223
-rw-r--r--.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/README.md53
-rw-r--r--.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/examples/apduToBlackBerry/.esp32.test.skip0
-rw-r--r--.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/examples/apduToBlackBerry/BlackBerry7/.classpath7
-rw-r--r--.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/examples/apduToBlackBerry/BlackBerry7/.project29
-rw-r--r--.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/examples/apduToBlackBerry/BlackBerry7/.settings/org.eclipse.jdt.core.prefs12
-rw-r--r--.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/examples/apduToBlackBerry/BlackBerry7/BlackBerry_App_Descriptor.xml40
-rw-r--r--.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/examples/apduToBlackBerry/BlackBerry7/build.xml35
-rw-r--r--.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/examples/apduToBlackBerry/BlackBerry7/src/mypackage/ColorMixer.java152
-rw-r--r--.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/examples/apduToBlackBerry/BlackBerry7/src/mypackage/MyApp.java47
-rw-r--r--.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/examples/apduToBlackBerry/BlackBerry7/src/mypackage/MyScreen.java163
-rw-r--r--.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/examples/apduToBlackBerry/apduToBlackBerry.ino148
-rw-r--r--.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/examples/iso14443a_uid/iso14443a_uid.ino110
-rw-r--r--.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/examples/iso14443as_target/iso14443as_target.ino106
-rw-r--r--.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/examples/mifareclassic_formatndef/mifareclassic_formatndef.ino201
-rw-r--r--.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/examples/mifareclassic_memdump/mifareclassic_memdump.ino190
-rw-r--r--.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/examples/mifareclassic_ndeftoclassic/mifareclassic_ndeftoclassic.ino207
-rw-r--r--.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/examples/mifareclassic_updatendef/mifareclassic_updatendef.ino177
-rw-r--r--.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/examples/ntag2xx_erase/ntag2xx_erase.ino158
-rw-r--r--.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/examples/ntag2xx_read/ntag2xx_read.ino155
-rw-r--r--.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/examples/ntag2xx_updatendef/ntag2xx_updatendef.ino212
-rw-r--r--.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/examples/readMifare/readMifare.ino184
-rw-r--r--.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/examples/readMifareClassic/readMifareClassic.ino119
-rw-r--r--.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/examples/readMifareClassicIrq/readMifareClassicIrq.ino156
-rw-r--r--.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/library.properties10
-rw-r--r--.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/license.txt26
32 files changed, 4861 insertions, 0 deletions
diff --git a/.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/.github/ISSUE_TEMPLATE.md b/.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/.github/ISSUE_TEMPLATE.md
new file mode 100644
index 0000000..f0e2614
--- /dev/null
+++ b/.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/.github/ISSUE_TEMPLATE.md
@@ -0,0 +1,46 @@
+Thank you for opening an issue on an Adafruit Arduino library repository. To
+improve the speed of resolution please review the following guidelines and
+common troubleshooting steps below before creating the issue:
+
+- **Do not use GitHub issues for troubleshooting projects and issues.** Instead use
+ the forums at http://forums.adafruit.com to ask questions and troubleshoot why
+ something isn't working as expected. In many cases the problem is a common issue
+ that you will more quickly receive help from the forum community. GitHub issues
+ are meant for known defects in the code. If you don't know if there is a defect
+ in the code then start with troubleshooting on the forum first.
+
+- **If following a tutorial or guide be sure you didn't miss a step.** Carefully
+ check all of the steps and commands to run have been followed. Consult the
+ forum if you're unsure or have questions about steps in a guide/tutorial.
+
+- **For Arduino projects check these very common issues to ensure they don't apply**:
+
+ - For uploading sketches or communicating with the board make sure you're using
+ a **USB data cable** and **not** a **USB charge-only cable**. It is sometimes
+ very hard to tell the difference between a data and charge cable! Try using the
+ cable with other devices or swapping to another cable to confirm it is not
+ the problem.
+
+ - **Be sure you are supplying adequate power to the board.** Check the specs of
+ your board and plug in an external power supply. In many cases just
+ plugging a board into your computer is not enough to power it and other
+ peripherals.
+
+ - **Double check all soldering joints and connections.** Flakey connections
+ cause many mysterious problems. See the [guide to excellent soldering](https://learn.adafruit.com/adafruit-guide-excellent-soldering/tools) for examples of good solder joints.
+
+ - **Ensure you are using an official Arduino or Adafruit board.** We can't
+ guarantee a clone board will have the same functionality and work as expected
+ with this code and don't support them.
+
+If you're sure this issue is a defect in the code and checked the steps above
+please fill in the following fields to provide enough troubleshooting information.
+You may delete the guideline and text above to just leave the following details:
+
+- Arduino board: **INSERT ARDUINO BOARD NAME/TYPE HERE**
+
+- Arduino IDE version (found in Arduino -> About Arduino menu): **INSERT ARDUINO
+ VERSION HERE**
+
+- List the steps to reproduce the problem below (if possible attach a sketch or
+ copy the sketch code in too): **LIST REPRO STEPS BELOW**
diff --git a/.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/.github/PULL_REQUEST_TEMPLATE.md b/.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/.github/PULL_REQUEST_TEMPLATE.md
new file mode 100644
index 0000000..7b641eb
--- /dev/null
+++ b/.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/.github/PULL_REQUEST_TEMPLATE.md
@@ -0,0 +1,26 @@
+Thank you for creating a pull request to contribute to Adafruit's GitHub code!
+Before you open the request please review the following guidelines and tips to
+help it be more easily integrated:
+
+- **Describe the scope of your change--i.e. what the change does and what parts
+ of the code were modified.** This will help us understand any risks of integrating
+ the code.
+
+- **Describe any known limitations with your change.** For example if the change
+ doesn't apply to a supported platform of the library please mention it.
+
+- **Please run any tests or examples that can exercise your modified code.** We
+ strive to not break users of the code and running tests/examples helps with this
+ process.
+
+Thank you again for contributing! We will try to test and integrate the change
+as soon as we can, but be aware we have many GitHub repositories to manage and
+can't immediately respond to every request. There is no need to bump or check in
+on a pull request (it will clutter the discussion of the request).
+
+Also don't be worried if the request is closed or not integrated--sometimes the
+priorities of Adafruit's GitHub code (education, ease of use) might not match the
+priorities of the pull request. Don't fret, the open source community thrives on
+forks and GitHub makes it easy to keep your changes in a forked repo.
+
+After reviewing the guidelines above you can delete this text from the pull request.
diff --git a/.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/.github/workflows/githubci.yml b/.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/.github/workflows/githubci.yml
new file mode 100644
index 0000000..e00452d
--- /dev/null
+++ b/.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/.github/workflows/githubci.yml
@@ -0,0 +1,32 @@
+name: Arduino Library CI
+
+on: [pull_request, push, repository_dispatch]
+
+jobs:
+ build:
+ runs-on: ubuntu-latest
+
+ steps:
+ - uses: actions/setup-python@v4
+ with:
+ python-version: '3.x'
+ - uses: actions/checkout@v3
+ - uses: actions/checkout@v3
+ with:
+ repository: adafruit/ci-arduino
+ path: ci
+
+ - name: pre-install
+ run: bash ci/actions_install.sh
+
+ - name: test platforms
+ run: python3 ci/build_platform.py main_platforms
+
+ - name: clang
+ run: python3 ci/run-clang-format.py -e "ci/*" -e "bin/*" -r .
+
+ - name: doxygen
+ env:
+ GH_REPO_TOKEN: ${{ secrets.GH_REPO_TOKEN }}
+ PRETTYNAME : "Adafruit PN532 Library"
+ run: bash ci/doxy_gen_and_deploy.sh
diff --git a/.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/.gitignore b/.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/.gitignore
new file mode 100644
index 0000000..c2a26c0
--- /dev/null
+++ b/.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/.gitignore
@@ -0,0 +1,4 @@
+# Our handy .gitignore for automation ease
+Doxyfile*
+doxygen_sqlite3.db
+html
diff --git a/.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/.piopm b/.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/.piopm
new file mode 100644
index 0000000..7dab1dd
--- /dev/null
+++ b/.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/.piopm
@@ -0,0 +1 @@
+{"type": "library", "name": "Adafruit PN532", "version": "1.3.4", "spec": {"owner": "adafruit", "id": 29, "name": "Adafruit PN532", "requirements": null, "uri": null}} \ No newline at end of file
diff --git a/.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/Adafruit_PN532.cpp b/.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/Adafruit_PN532.cpp
new file mode 100644
index 0000000..0a547b7
--- /dev/null
+++ b/.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/Adafruit_PN532.cpp
@@ -0,0 +1,1832 @@
+/**************************************************************************/
+/*!
+ @file Adafruit_PN532.cpp
+
+ @section intro_sec Introduction
+
+ Driver for NXP's PN532 NFC/13.56MHz RFID Transceiver
+
+ This is a library for the Adafruit PN532 NFC/RFID breakout boards
+ This library works with the Adafruit NFC breakout
+ ----> https://www.adafruit.com/products/364
+
+ Check out the links above for our tutorials and wiring diagrams
+ These chips use SPI or I2C to communicate.
+
+ Adafruit invests time and resources providing this open source code,
+ please support Adafruit and open-source hardware by purchasing
+ products from Adafruit!
+
+ @section author Author
+
+ Adafruit Industries
+
+ @section license License
+
+ BSD (see license.txt)
+
+ @section HISTORY
+
+ v2.2 - Added startPassiveTargetIDDetection() to start card detection and
+ readDetectedPassiveTargetID() to read it, useful when using the
+ IRQ pin.
+
+ v2.1 - Added NTAG2xx helper functions
+
+ v2.0 - Refactored to add I2C support from Adafruit_NFCShield_I2C library.
+
+ v1.4 - Added setPassiveActivationRetries()
+
+ v1.2 - Added writeGPIO()
+ - Added readGPIO()
+
+ v1.1 - Changed readPassiveTargetID() to handle multiple UID sizes
+ - Added the following helper functions for text display
+ static void PrintHex(const byte * data, const uint32_t numBytes)
+ static void PrintHexChar(const byte * pbtData, const uint32_t
+ numBytes)
+ - Added the following Mifare Classic functions:
+ bool mifareclassic_IsFirstBlock (uint32_t uiBlock)
+ bool mifareclassic_IsTrailerBlock (uint32_t uiBlock)
+ uint8_t mifareclassic_AuthenticateBlock (uint8_t * uid, uint8_t
+ uidLen, uint32_t blockNumber, uint8_t keyNumber, uint8_t * keyData) uint8_t
+ mifareclassic_ReadDataBlock (uint8_t blockNumber, uint8_t * data) uint8_t
+ mifareclassic_WriteDataBlock (uint8_t blockNumber, uint8_t * data)
+ - Added the following Mifare Ultalight functions:
+ uint8_t mifareultralight_ReadPage (uint8_t page, uint8_t * buffer)
+*/
+/**************************************************************************/
+
+#include "Adafruit_PN532.h"
+
+byte pn532ack[] = {0x00, 0x00, 0xFF,
+ 0x00, 0xFF, 0x00}; ///< ACK message from PN532
+byte pn532response_firmwarevers[] = {
+ 0x00, 0x00, 0xFF,
+ 0x06, 0xFA, 0xD5}; ///< Expected firmware version message from PN532
+
+// Uncomment these lines to enable debug output for PN532(SPI) and/or MIFARE
+// related code
+
+// #define PN532DEBUG
+// #define MIFAREDEBUG
+
+// If using Native Port on Arduino Zero or Due define as SerialUSB
+#define PN532DEBUGPRINT Serial ///< Fixed name for debug Serial instance
+// #define PN532DEBUGPRINT SerialUSB ///< Fixed name for debug Serial instance
+
+#define PN532_PACKBUFFSIZ 64 ///< Packet buffer size in bytes
+byte pn532_packetbuffer[PN532_PACKBUFFSIZ]; ///< Packet buffer used in various
+ ///< transactions
+
+/**************************************************************************/
+/*!
+ @brief Instantiates a new PN532 class using software SPI.
+
+ @param clk SPI clock pin (SCK)
+ @param miso SPI MISO pin
+ @param mosi SPI MOSI pin
+ @param ss SPI chip select pin (CS/SSEL)
+*/
+/**************************************************************************/
+Adafruit_PN532::Adafruit_PN532(uint8_t clk, uint8_t miso, uint8_t mosi,
+ uint8_t ss) {
+ _cs = ss;
+ spi_dev = new Adafruit_SPIDevice(ss, clk, miso, mosi, 1000000,
+ SPI_BITORDER_LSBFIRST, SPI_MODE0);
+}
+
+/**************************************************************************/
+/*!
+ @brief Instantiates a new PN532 class using I2C.
+
+ @param irq Location of the IRQ pin
+ @param reset Location of the RSTPD_N pin
+ @param theWire pointer to I2C bus to use
+*/
+/**************************************************************************/
+Adafruit_PN532::Adafruit_PN532(uint8_t irq, uint8_t reset, TwoWire *theWire)
+ : _irq(irq), _reset(reset) {
+ pinMode(_irq, INPUT);
+ pinMode(_reset, OUTPUT);
+ i2c_dev = new Adafruit_I2CDevice(PN532_I2C_ADDRESS, theWire);
+}
+
+/**************************************************************************/
+/*!
+ @brief Instantiates a new PN532 class using hardware SPI.
+
+ @param ss SPI chip select pin (CS/SSEL)
+ @param theSPI pointer to the SPI bus to use
+*/
+/**************************************************************************/
+Adafruit_PN532::Adafruit_PN532(uint8_t ss, SPIClass *theSPI) {
+ _cs = ss;
+ spi_dev = new Adafruit_SPIDevice(ss, 1000000, SPI_BITORDER_LSBFIRST,
+ SPI_MODE0, theSPI);
+}
+
+/**************************************************************************/
+/*!
+ @brief Instantiates a new PN532 class using hardware UART (HSU).
+
+ @param reset Location of the RSTPD_N pin
+ @param theSer pointer to HardWare Serial bus to use
+*/
+/**************************************************************************/
+Adafruit_PN532::Adafruit_PN532(uint8_t reset, HardwareSerial *theSer)
+ : _reset(reset) {
+ pinMode(_reset, OUTPUT);
+ ser_dev = theSer;
+}
+
+/**************************************************************************/
+/*!
+ @brief Setups the HW
+
+ @returns true if successful, otherwise false
+*/
+/**************************************************************************/
+bool Adafruit_PN532::begin() {
+ if (spi_dev) {
+ // SPI initialization
+ if (!spi_dev->begin()) {
+ return false;
+ }
+ } else if (i2c_dev) {
+ // I2C initialization
+ // PN532 will fail address check since its asleep, so suppress
+ if (!i2c_dev->begin(false)) {
+ return false;
+ }
+ } else if (ser_dev) {
+ ser_dev->begin(115200);
+ // clear out anything in read buffer
+ while (ser_dev->available())
+ ser_dev->read();
+ } else {
+ // no interface specified
+ return false;
+ }
+ reset(); // HW reset - put in known state
+ delay(10);
+ wakeup(); // hey! wakeup!
+ return true;
+}
+
+/**************************************************************************/
+/*!
+ @brief Perform a hardware reset. Requires reset pin to have been provided.
+*/
+/**************************************************************************/
+void Adafruit_PN532::reset(void) {
+ // see Datasheet p.209, Fig.48 for timings
+ if (_reset != -1) {
+ digitalWrite(_reset, LOW);
+ delay(1); // min 20ns
+ digitalWrite(_reset, HIGH);
+ delay(2); // max 2ms
+ }
+}
+
+/**************************************************************************/
+/*!
+ @brief Wakeup from LowVbat mode into Normal Mode.
+*/
+/**************************************************************************/
+void Adafruit_PN532::wakeup(void) {
+ // interface specific wakeups - each one is unique!
+ if (spi_dev) {
+ // hold CS low for 2ms
+ digitalWrite(_cs, LOW);
+ delay(2);
+ } else if (ser_dev) {
+ uint8_t w[3] = {0x55, 0x00, 0x00};
+ ser_dev->write(w, 3);
+ delay(2);
+ }
+
+ // PN532 will clock stretch I2C during SAMConfig as a "wakeup"
+
+ // need to config SAM to stay in Normal Mode
+ SAMConfig();
+}
+
+/**************************************************************************/
+/*!
+ @brief Prints a hexadecimal value in plain characters
+
+ @param data Pointer to the byte data
+ @param numBytes Data length in bytes
+*/
+/**************************************************************************/
+void Adafruit_PN532::PrintHex(const byte *data, const uint32_t numBytes) {
+ uint32_t szPos;
+ for (szPos = 0; szPos < numBytes; szPos++) {
+ PN532DEBUGPRINT.print(F("0x"));
+ // Append leading 0 for small values
+ if (data[szPos] <= 0xF)
+ PN532DEBUGPRINT.print(F("0"));
+ PN532DEBUGPRINT.print(data[szPos] & 0xff, HEX);
+ if ((numBytes > 1) && (szPos != numBytes - 1)) {
+ PN532DEBUGPRINT.print(F(" "));
+ }
+ }
+ PN532DEBUGPRINT.println();
+}
+
+/**************************************************************************/
+/*!
+ @brief Prints a hexadecimal value in plain characters, along with
+ the char equivalents in the following format
+
+ 00 00 00 00 00 00 ......
+
+ @param data Pointer to the byte data
+ @param numBytes Data length in bytes
+*/
+/**************************************************************************/
+void Adafruit_PN532::PrintHexChar(const byte *data, const uint32_t numBytes) {
+ uint32_t szPos;
+ for (szPos = 0; szPos < numBytes; szPos++) {
+ // Append leading 0 for small values
+ if (data[szPos] <= 0xF)
+ PN532DEBUGPRINT.print(F("0"));
+ PN532DEBUGPRINT.print(data[szPos], HEX);
+ if ((numBytes > 1) && (szPos != numBytes - 1)) {
+ PN532DEBUGPRINT.print(F(" "));
+ }
+ }
+ PN532DEBUGPRINT.print(F(" "));
+ for (szPos = 0; szPos < numBytes; szPos++) {
+ if (data[szPos] <= 0x1F)
+ PN532DEBUGPRINT.print(F("."));
+ else
+ PN532DEBUGPRINT.print((char)data[szPos]);
+ }
+ PN532DEBUGPRINT.println();
+}
+
+/**************************************************************************/
+/*!
+ @brief Checks the firmware version of the PN5xx chip
+
+ @returns The chip's firmware version and ID
+*/
+/**************************************************************************/
+uint32_t Adafruit_PN532::getFirmwareVersion(void) {
+ uint32_t response;
+
+ pn532_packetbuffer[0] = PN532_COMMAND_GETFIRMWAREVERSION;
+
+ if (!sendCommandCheckAck(pn532_packetbuffer, 1)) {
+ return 0;
+ }
+
+ // read data packet
+ readdata(pn532_packetbuffer, 13);
+
+ // check some basic stuff
+ if (0 != memcmp((char *)pn532_packetbuffer,
+ (char *)pn532response_firmwarevers, 6)) {
+#ifdef PN532DEBUG
+ PN532DEBUGPRINT.println(F("Firmware doesn't match!"));
+#endif
+ return 0;
+ }
+
+ int offset = 7;
+ response = pn532_packetbuffer[offset++];
+ response <<= 8;
+ response |= pn532_packetbuffer[offset++];
+ response <<= 8;
+ response |= pn532_packetbuffer[offset++];
+ response <<= 8;
+ response |= pn532_packetbuffer[offset++];
+
+ return response;
+}
+
+/**************************************************************************/
+/*!
+ @brief Sends a command and waits a specified period for the ACK
+
+ @param cmd Pointer to the command buffer
+ @param cmdlen The size of the command in bytes
+ @param timeout timeout before giving up
+
+ @returns 1 if everything is OK, 0 if timeout occured before an
+ ACK was recieved
+*/
+/**************************************************************************/
+// default timeout of one second
+bool Adafruit_PN532::sendCommandCheckAck(uint8_t *cmd, uint8_t cmdlen,
+ uint16_t timeout) {
+
+ // I2C works without using IRQ pin by polling for RDY byte
+ // seems to work best with some delays between transactions
+ uint8_t SLOWDOWN = 0;
+ if (i2c_dev || spi_dev) // SPI and I2C need 1ms slow for page reads
+ SLOWDOWN = 1;
+
+ // write the command
+ writecommand(cmd, cmdlen);
+
+ // I2C TUNING
+ delay(SLOWDOWN);
+
+ // Wait for chip to say its ready!
+ if (!waitready(timeout)) {
+ return false;
+ }
+
+#ifdef PN532DEBUG
+ if (spi_dev == NULL) {
+ PN532DEBUGPRINT.println(F("IRQ received"));
+ }
+#endif
+
+ // read acknowledgement
+ if (!readack()) {
+#ifdef PN532DEBUG
+ PN532DEBUGPRINT.println(F("No ACK frame received!"));
+#endif
+ return false;
+ }
+
+ // I2C TUNING
+ delay(SLOWDOWN);
+
+ // Wait for chip to say its ready!
+ if (!waitready(timeout)) {
+ return false;
+ }
+
+ return true; // ack'd command
+}
+
+/**************************************************************************/
+/*!
+ @brief Writes an 8-bit value that sets the state of the PN532's GPIO
+ pins.
+ @param pinstate P3 pins state.
+
+ @warning This function is provided exclusively for board testing and
+ is dangerous since it will throw an error if any pin other
+ than the ones marked "Can be used as GPIO" are modified! All
+ pins that can not be used as GPIO should ALWAYS be left high
+ (value = 1) or the system will become unstable and a HW reset
+ will be required to recover the PN532.
+
+ pinState[0] = P30 Can be used as GPIO
+ pinState[1] = P31 Can be used as GPIO
+ pinState[2] = P32 *** RESERVED (Must be 1!) ***
+ pinState[3] = P33 Can be used as GPIO
+ pinState[4] = P34 *** RESERVED (Must be 1!) ***
+ pinState[5] = P35 Can be used as GPIO
+
+ @return 1 if everything executed properly, 0 for an error
+*/
+/**************************************************************************/
+bool Adafruit_PN532::writeGPIO(uint8_t pinstate) {
+ // uint8_t errorbit;
+
+ // Make sure pinstate does not try to toggle P32 or P34
+ pinstate |= (1 << PN532_GPIO_P32) | (1 << PN532_GPIO_P34);
+
+ // Fill command buffer
+ pn532_packetbuffer[0] = PN532_COMMAND_WRITEGPIO;
+ pn532_packetbuffer[1] = PN532_GPIO_VALIDATIONBIT | pinstate; // P3 Pins
+ pn532_packetbuffer[2] = 0x00; // P7 GPIO Pins (not used ... taken by SPI)
+
+#ifdef PN532DEBUG
+ PN532DEBUGPRINT.print(F("Writing P3 GPIO: "));
+ PN532DEBUGPRINT.println(pn532_packetbuffer[1], HEX);
+#endif
+
+ // Send the WRITEGPIO command (0x0E)
+ if (!sendCommandCheckAck(pn532_packetbuffer, 3))
+ return 0x0;
+
+ // Read response packet (00 FF PLEN PLENCHECKSUM D5 CMD+1(0x0F) DATACHECKSUM
+ // 00)
+ readdata(pn532_packetbuffer, 8);
+
+#ifdef PN532DEBUG
+ PN532DEBUGPRINT.print(F("Received: "));
+ PrintHex(pn532_packetbuffer, 8);
+ PN532DEBUGPRINT.println();
+#endif
+
+ int offset = 6;
+ return (pn532_packetbuffer[offset] == 0x0F);
+}
+
+/**************************************************************************/
+/*!
+ Reads the state of the PN532's GPIO pins
+
+ @returns An 8-bit value containing the pin state where:
+
+ pinState[0] = P30
+ pinState[1] = P31
+ pinState[2] = P32
+ pinState[3] = P33
+ pinState[4] = P34
+ pinState[5] = P35
+*/
+/**************************************************************************/
+uint8_t Adafruit_PN532::readGPIO(void) {
+ pn532_packetbuffer[0] = PN532_COMMAND_READGPIO;
+
+ // Send the READGPIO command (0x0C)
+ if (!sendCommandCheckAck(pn532_packetbuffer, 1))
+ return 0x0;
+
+ // Read response packet (00 FF PLEN PLENCHECKSUM D5 CMD+1(0x0D) P3 P7 IO1
+ // DATACHECKSUM 00)
+ readdata(pn532_packetbuffer, 11);
+
+ /* READGPIO response should be in the following format:
+
+ byte Description
+ ------------- ------------------------------------------
+ b0..5 Frame header and preamble (with I2C there is an extra
+ 0x00) b6 P3 GPIO Pins b7 P7 GPIO Pins (not used
+ ... taken by SPI) b8 Interface Mode Pins (not used ... bus
+ select pins) b9..10 checksum */
+
+ int p3offset = 7;
+
+#ifdef PN532DEBUG
+ PN532DEBUGPRINT.print(F("Received: "));
+ PrintHex(pn532_packetbuffer, 11);
+ PN532DEBUGPRINT.println();
+ PN532DEBUGPRINT.print(F("P3 GPIO: 0x"));
+ PN532DEBUGPRINT.println(pn532_packetbuffer[p3offset], HEX);
+ PN532DEBUGPRINT.print(F("P7 GPIO: 0x"));
+ PN532DEBUGPRINT.println(pn532_packetbuffer[p3offset + 1], HEX);
+ PN532DEBUGPRINT.print(F("IO GPIO: 0x"));
+ PN532DEBUGPRINT.println(pn532_packetbuffer[p3offset + 2], HEX);
+ // Note: You can use the IO GPIO value to detect the serial bus being used
+ switch (pn532_packetbuffer[p3offset + 2]) {
+ case 0x00: // Using UART
+ PN532DEBUGPRINT.println(F("Using UART (IO = 0x00)"));
+ break;
+ case 0x01: // Using I2C
+ PN532DEBUGPRINT.println(F("Using I2C (IO = 0x01)"));
+ break;
+ case 0x02: // Using SPI
+ PN532DEBUGPRINT.println(F("Using SPI (IO = 0x02)"));
+ break;
+ }
+#endif
+
+ return pn532_packetbuffer[p3offset];
+}
+
+/**************************************************************************/
+/*!
+ @brief Configures the SAM (Secure Access Module)
+ @return true on success, false otherwise.
+*/
+/**************************************************************************/
+bool Adafruit_PN532::SAMConfig(void) {
+ pn532_packetbuffer[0] = PN532_COMMAND_SAMCONFIGURATION;
+ pn532_packetbuffer[1] = 0x01; // normal mode;
+ pn532_packetbuffer[2] = 0x14; // timeout 50ms * 20 = 1 second
+ pn532_packetbuffer[3] = 0x01; // use IRQ pin!
+
+ if (!sendCommandCheckAck(pn532_packetbuffer, 4))
+ return false;
+
+ // read data packet
+ readdata(pn532_packetbuffer, 9);
+
+ int offset = 6;
+ return (pn532_packetbuffer[offset] == 0x15);
+}
+
+/**************************************************************************/
+/*!
+ Sets the MxRtyPassiveActivation byte of the RFConfiguration register
+
+ @param maxRetries 0xFF to wait forever, 0x00..0xFE to timeout
+ after mxRetries
+
+ @returns 1 if everything executed properly, 0 for an error
+*/
+/**************************************************************************/
+bool Adafruit_PN532::setPassiveActivationRetries(uint8_t maxRetries) {
+ pn532_packetbuffer[0] = PN532_COMMAND_RFCONFIGURATION;
+ pn532_packetbuffer[1] = 5; // Config item 5 (MaxRetries)
+ pn532_packetbuffer[2] = 0xFF; // MxRtyATR (default = 0xFF)
+ pn532_packetbuffer[3] = 0x01; // MxRtyPSL (default = 0x01)
+ pn532_packetbuffer[4] = maxRetries;
+
+#ifdef MIFAREDEBUG
+ PN532DEBUGPRINT.print(F("Setting MxRtyPassiveActivation to "));
+ PN532DEBUGPRINT.print(maxRetries, DEC);
+ PN532DEBUGPRINT.println(F(" "));
+#endif
+
+ if (!sendCommandCheckAck(pn532_packetbuffer, 5))
+ return 0x0; // no ACK
+
+ return 1;
+}
+
+/***** ISO14443A Commands ******/
+
+/**************************************************************************/
+/*!
+ @brief Waits for an ISO14443A target to enter the field and reads
+ its ID.
+
+ @param cardbaudrate Baud rate of the card
+ @param uid Pointer to the array that will be populated
+ with the card's UID (up to 7 bytes)
+ @param uidLength Pointer to the variable that will hold the
+ length of the card's UID.
+ @param timeout Timeout in milliseconds.
+
+ @return 1 if everything executed properly, 0 for an error
+*/
+/**************************************************************************/
+bool Adafruit_PN532::readPassiveTargetID(uint8_t cardbaudrate, uint8_t *uid,
+ uint8_t *uidLength, uint16_t timeout) {
+ pn532_packetbuffer[0] = PN532_COMMAND_INLISTPASSIVETARGET;
+ pn532_packetbuffer[1] =
+ 1; // max 1 cards at once (we can set this to 2 later)
+ pn532_packetbuffer[2] = cardbaudrate;
+
+ if (!sendCommandCheckAck(pn532_packetbuffer, 3, timeout)) {
+#ifdef PN532DEBUG
+ PN532DEBUGPRINT.println(F("No card(s) read"));
+#endif
+ return 0x0; // no cards read
+ }
+
+ return readDetectedPassiveTargetID(uid, uidLength);
+}
+
+/**************************************************************************/
+/*!
+ @brief Put the reader in detection mode, non blocking so interrupts
+ must be enabled.
+ @param cardbaudrate Baud rate of the card
+ @return 1 if everything executed properly, 0 for an error
+*/
+/**************************************************************************/
+bool Adafruit_PN532::startPassiveTargetIDDetection(uint8_t cardbaudrate) {
+ pn532_packetbuffer[0] = PN532_COMMAND_INLISTPASSIVETARGET;
+ pn532_packetbuffer[1] =
+ 1; // max 1 cards at once (we can set this to 2 later)
+ pn532_packetbuffer[2] = cardbaudrate;
+
+ return sendCommandCheckAck(pn532_packetbuffer, 3);
+}
+
+/**************************************************************************/
+/*!
+ Reads the ID of the passive target the reader has deteceted.
+
+ @param uid Pointer to the array that will be populated
+ with the card's UID (up to 7 bytes)
+ @param uidLength Pointer to the variable that will hold the
+ length of the card's UID.
+
+ @returns 1 if everything executed properly, 0 for an error
+*/
+/**************************************************************************/
+bool Adafruit_PN532::readDetectedPassiveTargetID(uint8_t *uid,
+ uint8_t *uidLength) {
+ // read data packet
+ readdata(pn532_packetbuffer, 20);
+ // check some basic stuff
+
+ /* ISO14443A card response should be in the following format:
+
+ byte Description
+ ------------- ------------------------------------------
+ b0..6 Frame header and preamble
+ b7 Tags Found
+ b8 Tag Number (only one used in this example)
+ b9..10 SENS_RES
+ b11 SEL_RES
+ b12 NFCID Length
+ b13..NFCIDLen NFCID */
+
+#ifdef MIFAREDEBUG
+ PN532DEBUGPRINT.print(F("Found "));
+ PN532DEBUGPRINT.print(pn532_packetbuffer[7], DEC);
+ PN532DEBUGPRINT.println(F(" tags"));
+#endif
+ if (pn532_packetbuffer[7] != 1)
+ return 0;
+
+ uint16_t sens_res = pn532_packetbuffer[9];
+ sens_res <<= 8;
+ sens_res |= pn532_packetbuffer[10];
+#ifdef MIFAREDEBUG
+ PN532DEBUGPRINT.print(F("ATQA: 0x"));
+ PN532DEBUGPRINT.println(sens_res, HEX);
+ PN532DEBUGPRINT.print(F("SAK: 0x"));
+ PN532DEBUGPRINT.println(pn532_packetbuffer[11], HEX);
+#endif
+
+ /* Card appears to be Mifare Classic */
+ *uidLength = pn532_packetbuffer[12];
+#ifdef MIFAREDEBUG
+ PN532DEBUGPRINT.print(F("UID:"));
+#endif
+ for (uint8_t i = 0; i < pn532_packetbuffer[12]; i++) {
+ uid[i] = pn532_packetbuffer[13 + i];
+#ifdef MIFAREDEBUG
+ PN532DEBUGPRINT.print(F(" 0x"));
+ PN532DEBUGPRINT.print(uid[i], HEX);
+#endif
+ }
+#ifdef MIFAREDEBUG
+ PN532DEBUGPRINT.println();
+#endif
+
+ return 1;
+}
+
+/**************************************************************************/
+/*!
+ @brief Exchanges an APDU with the currently inlisted peer
+
+ @param send Pointer to data to send
+ @param sendLength Length of the data to send
+ @param response Pointer to response data
+ @param responseLength Pointer to the response data length
+ @return true on success, false otherwise.
+*/
+/**************************************************************************/
+bool Adafruit_PN532::inDataExchange(uint8_t *send, uint8_t sendLength,
+ uint8_t *response,
+ uint8_t *responseLength) {
+ if (sendLength > PN532_PACKBUFFSIZ - 2) {
+#ifdef PN532DEBUG
+ PN532DEBUGPRINT.println(F("APDU length too long for packet buffer"));
+#endif
+ return false;
+ }
+ uint8_t i;
+
+ pn532_packetbuffer[0] = 0x40; // PN532_COMMAND_INDATAEXCHANGE;
+ pn532_packetbuffer[1] = _inListedTag;
+ for (i = 0; i < sendLength; ++i) {
+ pn532_packetbuffer[i + 2] = send[i];
+ }
+
+ if (!sendCommandCheckAck(pn532_packetbuffer, sendLength + 2, 1000)) {
+#ifdef PN532DEBUG
+ PN532DEBUGPRINT.println(F("Could not send APDU"));
+#endif
+ return false;
+ }
+
+ if (!waitready(1000)) {
+#ifdef PN532DEBUG
+ PN532DEBUGPRINT.println(F("Response never received for APDU..."));
+#endif
+ return false;
+ }
+
+ readdata(pn532_packetbuffer, sizeof(pn532_packetbuffer));
+
+ if (pn532_packetbuffer[0] == 0 && pn532_packetbuffer[1] == 0 &&
+ pn532_packetbuffer[2] == 0xff) {
+ uint8_t length = pn532_packetbuffer[3];
+ if (pn532_packetbuffer[4] != (uint8_t)(~length + 1)) {
+#ifdef PN532DEBUG
+ PN532DEBUGPRINT.println(F("Length check invalid"));
+ PN532DEBUGPRINT.println(length, HEX);
+ PN532DEBUGPRINT.println((~length) + 1, HEX);
+#endif
+ return false;
+ }
+ if (pn532_packetbuffer[5] == PN532_PN532TOHOST &&
+ pn532_packetbuffer[6] == PN532_RESPONSE_INDATAEXCHANGE) {
+ if ((pn532_packetbuffer[7] & 0x3f) != 0) {
+#ifdef PN532DEBUG
+ PN532DEBUGPRINT.println(F("Status code indicates an error"));
+#endif
+ return false;
+ }
+
+ length -= 3;
+
+ if (length > *responseLength) {
+ length = *responseLength; // silent truncation...
+ }
+
+ for (i = 0; i < length; ++i) {
+ response[i] = pn532_packetbuffer[8 + i];
+ }
+ *responseLength = length;
+
+ return true;
+ } else {
+ PN532DEBUGPRINT.print(F("Don't know how to handle this command: "));
+ PN532DEBUGPRINT.println(pn532_packetbuffer[6], HEX);
+ return false;
+ }
+ } else {
+ PN532DEBUGPRINT.println(F("Preamble missing"));
+ return false;
+ }
+}
+
+/**************************************************************************/
+/*!
+ @brief 'InLists' a passive target. PN532 acting as reader/initiator,
+ peer acting as card/responder.
+ @return true on success, false otherwise.
+*/
+/**************************************************************************/
+bool Adafruit_PN532::inListPassiveTarget() {
+ pn532_packetbuffer[0] = PN532_COMMAND_INLISTPASSIVETARGET;
+ pn532_packetbuffer[1] = 1;
+ pn532_packetbuffer[2] = 0;
+
+#ifdef PN532DEBUG
+ PN532DEBUGPRINT.print(F("About to inList passive target"));
+#endif
+
+ if (!sendCommandCheckAck(pn532_packetbuffer, 3, 1000)) {
+#ifdef PN532DEBUG
+ PN532DEBUGPRINT.println(F("Could not send inlist message"));
+#endif
+ return false;
+ }
+
+ if (!waitready(30000)) {
+ return false;
+ }
+
+ readdata(pn532_packetbuffer, sizeof(pn532_packetbuffer));
+
+ if (pn532_packetbuffer[0] == 0 && pn532_packetbuffer[1] == 0 &&
+ pn532_packetbuffer[2] == 0xff) {
+ uint8_t length = pn532_packetbuffer[3];
+ if (pn532_packetbuffer[4] != (uint8_t)(~length + 1)) {
+#ifdef PN532DEBUG
+ PN532DEBUGPRINT.println(F("Length check invalid"));
+ PN532DEBUGPRINT.println(length, HEX);
+ PN532DEBUGPRINT.println((~length) + 1, HEX);
+#endif
+ return false;
+ }
+ if (pn532_packetbuffer[5] == PN532_PN532TOHOST &&
+ pn532_packetbuffer[6] == PN532_RESPONSE_INLISTPASSIVETARGET) {
+ if (pn532_packetbuffer[7] != 1) {
+#ifdef PN532DEBUG
+ PN532DEBUGPRINT.println(
+ F("Unhandled number of targets inlisted"));
+#endif
+ PN532DEBUGPRINT.println(F("Number of tags inlisted:"));
+ PN532DEBUGPRINT.println(pn532_packetbuffer[7]);
+ return false;
+ }
+
+ _inListedTag = pn532_packetbuffer[8];
+ PN532DEBUGPRINT.print(F("Tag number: "));
+ PN532DEBUGPRINT.println(_inListedTag);
+
+ return true;
+ } else {
+#ifdef PN532DEBUG
+ PN532DEBUGPRINT.print(
+ F("Unexpected response to inlist passive host"));
+#endif
+ return false;
+ }
+ } else {
+#ifdef PN532DEBUG
+ PN532DEBUGPRINT.println(F("Preamble missing"));
+#endif
+ return false;
+ }
+
+ return true;
+}
+
+/***** Mifare Classic Functions ******/
+
+/**************************************************************************/
+/*!
+ @brief Indicates whether the specified block number is the first block
+ in the sector (block 0 relative to the current sector)
+ @param uiBlock Block number to test.
+ @return true if first block, false otherwise.
+*/
+/**************************************************************************/
+bool Adafruit_PN532::mifareclassic_IsFirstBlock(uint32_t uiBlock) {
+ // Test if we are in the small or big sectors
+ if (uiBlock < 128)
+ return ((uiBlock) % 4 == 0);
+ else
+ return ((uiBlock) % 16 == 0);
+}
+
+/**************************************************************************/
+/*!
+ @brief Indicates whether the specified block number is the sector
+ trailer.
+ @param uiBlock Block number to test.
+ @return true if sector trailer, false otherwise.
+*/
+/**************************************************************************/
+bool Adafruit_PN532::mifareclassic_IsTrailerBlock(uint32_t uiBlock) {
+ // Test if we are in the small or big sectors
+ if (uiBlock < 128)
+ return ((uiBlock + 1) % 4 == 0);
+ else
+ return ((uiBlock + 1) % 16 == 0);
+}
+
+/**************************************************************************/
+/*!
+ Tries to authenticate a block of memory on a MIFARE card using the
+ INDATAEXCHANGE command. See section 7.3.8 of the PN532 User Manual
+ for more information on sending MIFARE and other commands.
+
+ @param uid Pointer to a byte array containing the card UID
+ @param uidLen The length (in bytes) of the card's UID (Should
+ be 4 for MIFARE Classic)
+ @param blockNumber The block number to authenticate. (0..63 for
+ 1KB cards, and 0..255 for 4KB cards).
+ @param keyNumber Which key type to use during authentication
+ (0 = MIFARE_CMD_AUTH_A, 1 = MIFARE_CMD_AUTH_B)
+ @param keyData Pointer to a byte array containing the 6 byte
+ key value
+
+ @returns 1 if everything executed properly, 0 for an error
+*/
+/**************************************************************************/
+uint8_t Adafruit_PN532::mifareclassic_AuthenticateBlock(uint8_t *uid,
+ uint8_t uidLen,
+ uint32_t blockNumber,
+ uint8_t keyNumber,
+ uint8_t *keyData) {
+ // uint8_t len;
+ uint8_t i;
+
+ // Hang on to the key and uid data
+ memcpy(_key, keyData, 6);
+ memcpy(_uid, uid, uidLen);
+ _uidLen = uidLen;
+
+#ifdef MIFAREDEBUG
+ PN532DEBUGPRINT.print(F("Trying to authenticate card "));
+ Adafruit_PN532::PrintHex(_uid, _uidLen);
+ PN532DEBUGPRINT.print(F("Using authentication KEY "));
+ PN532DEBUGPRINT.print(keyNumber ? 'B' : 'A');
+ PN532DEBUGPRINT.print(F(": "));
+ Adafruit_PN532::PrintHex(_key, 6);
+#endif
+
+ // Prepare the authentication command //
+ pn532_packetbuffer[0] =
+ PN532_COMMAND_INDATAEXCHANGE; /* Data Exchange Header */
+ pn532_packetbuffer[1] = 1; /* Max card numbers */
+ pn532_packetbuffer[2] = (keyNumber) ? MIFARE_CMD_AUTH_B : MIFARE_CMD_AUTH_A;
+ pn532_packetbuffer[3] =
+ blockNumber; /* Block Number (1K = 0..63, 4K = 0..255 */
+ memcpy(pn532_packetbuffer + 4, _key, 6);
+ for (i = 0; i < _uidLen; i++) {
+ pn532_packetbuffer[10 + i] = _uid[i]; /* 4 byte card ID */
+ }
+
+ if (!sendCommandCheckAck(pn532_packetbuffer, 10 + _uidLen))
+ return 0;
+
+ // Read the response packet
+ readdata(pn532_packetbuffer, 12);
+
+ // check if the response is valid and we are authenticated???
+ // for an auth success it should be bytes 5-7: 0xD5 0x41 0x00
+ // Mifare auth error is technically byte 7: 0x14 but anything other and 0x00
+ // is not good
+ if (pn532_packetbuffer[7] != 0x00) {
+#ifdef PN532DEBUG
+ PN532DEBUGPRINT.print(F("Authentification failed: "));
+ Adafruit_PN532::PrintHexChar(pn532_packetbuffer, 12);
+#endif
+ return 0;
+ }
+
+ return 1;
+}
+
+/**************************************************************************/
+/*!
+ Tries to read an entire 16-byte data block at the specified block
+ address.
+
+ @param blockNumber The block number to authenticate. (0..63 for
+ 1KB cards, and 0..255 for 4KB cards).
+ @param data Pointer to the byte array that will hold the
+ retrieved data (if any)
+
+ @returns 1 if everything executed properly, 0 for an error
+*/
+/**************************************************************************/
+uint8_t Adafruit_PN532::mifareclassic_ReadDataBlock(uint8_t blockNumber,
+ uint8_t *data) {
+#ifdef MIFAREDEBUG
+ PN532DEBUGPRINT.print(F("Trying to read 16 bytes from block "));
+ PN532DEBUGPRINT.println(blockNumber);
+#endif
+
+ /* Prepare the command */
+ pn532_packetbuffer[0] = PN532_COMMAND_INDATAEXCHANGE;
+ pn532_packetbuffer[1] = 1; /* Card number */
+ pn532_packetbuffer[2] = MIFARE_CMD_READ; /* Mifare Read command = 0x30 */
+ pn532_packetbuffer[3] =
+ blockNumber; /* Block Number (0..63 for 1K, 0..255 for 4K) */
+
+ /* Send the command */
+ if (!sendCommandCheckAck(pn532_packetbuffer, 4)) {
+#ifdef MIFAREDEBUG
+ PN532DEBUGPRINT.println(F("Failed to receive ACK for read command"));
+#endif
+ return 0;
+ }
+
+ /* Read the response packet */
+ readdata(pn532_packetbuffer, 26);
+
+ /* If byte 8 isn't 0x00 we probably have an error */
+ if (pn532_packetbuffer[7] != 0x00) {
+#ifdef MIFAREDEBUG
+ PN532DEBUGPRINT.println(F("Unexpected response"));
+ Adafruit_PN532::PrintHexChar(pn532_packetbuffer, 26);
+#endif
+ return 0;
+ }
+
+ /* Copy the 16 data bytes to the output buffer */
+ /* Block content starts at byte 9 of a valid response */
+ memcpy(data, pn532_packetbuffer + 8, 16);
+
+/* Display data for debug if requested */
+#ifdef MIFAREDEBUG
+ PN532DEBUGPRINT.print(F("Block "));
+ PN532DEBUGPRINT.println(blockNumber);
+ Adafruit_PN532::PrintHexChar(data, 16);
+#endif
+
+ return 1;
+}
+
+/**************************************************************************/
+/*!
+ Tries to write an entire 16-byte data block at the specified block
+ address.
+
+ @param blockNumber The block number to authenticate. (0..63 for
+ 1KB cards, and 0..255 for 4KB cards).
+ @param data The byte array that contains the data to write.
+
+ @returns 1 if everything executed properly, 0 for an error
+*/
+/**************************************************************************/
+uint8_t Adafruit_PN532::mifareclassic_WriteDataBlock(uint8_t blockNumber,
+ uint8_t *data) {
+#ifdef MIFAREDEBUG
+ PN532DEBUGPRINT.print(F("Trying to write 16 bytes to block "));
+ PN532DEBUGPRINT.println(blockNumber);
+#endif
+
+ /* Prepare the first command */
+ pn532_packetbuffer[0] = PN532_COMMAND_INDATAEXCHANGE;
+ pn532_packetbuffer[1] = 1; /* Card number */
+ pn532_packetbuffer[2] = MIFARE_CMD_WRITE; /* Mifare Write command = 0xA0 */
+ pn532_packetbuffer[3] =
+ blockNumber; /* Block Number (0..63 for 1K, 0..255 for 4K) */
+ memcpy(pn532_packetbuffer + 4, data, 16); /* Data Payload */
+
+ /* Send the command */
+ if (!sendCommandCheckAck(pn532_packetbuffer, 20)) {
+#ifdef MIFAREDEBUG
+ PN532DEBUGPRINT.println(F("Failed to receive ACK for write command"));
+#endif
+ return 0;
+ }
+ delay(10);
+
+ /* Read the response packet */
+ readdata(pn532_packetbuffer, 26);
+
+ return 1;
+}
+
+/**************************************************************************/
+/*!
+ Formats a Mifare Classic card to store NDEF Records
+
+ @returns 1 if everything executed properly, 0 for an error
+*/
+/**************************************************************************/
+uint8_t Adafruit_PN532::mifareclassic_FormatNDEF(void) {
+ uint8_t sectorbuffer1[16] = {0x14, 0x01, 0x03, 0xE1, 0x03, 0xE1,
+ 0x03, 0xE1, 0x03, 0xE1, 0x03, 0xE1,
+ 0x03, 0xE1, 0x03, 0xE1};
+ uint8_t sectorbuffer2[16] = {0x03, 0xE1, 0x03, 0xE1, 0x03, 0xE1,
+ 0x03, 0xE1, 0x03, 0xE1, 0x03, 0xE1,
+ 0x03, 0xE1, 0x03, 0xE1};
+ uint8_t sectorbuffer3[16] = {0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5,
+ 0x78, 0x77, 0x88, 0xC1, 0xFF, 0xFF,
+ 0xFF, 0xFF, 0xFF, 0xFF};
+
+ // Note 0xA0 0xA1 0xA2 0xA3 0xA4 0xA5 must be used for key A
+ // for the MAD sector in NDEF records (sector 0)
+
+ // Write block 1 and 2 to the card
+ if (!(mifareclassic_WriteDataBlock(1, sectorbuffer1)))
+ return 0;
+ if (!(mifareclassic_WriteDataBlock(2, sectorbuffer2)))
+ return 0;
+ // Write key A and access rights card
+ if (!(mifareclassic_WriteDataBlock(3, sectorbuffer3)))
+ return 0;
+
+ // Seems that everything was OK (?!)
+ return 1;
+}
+
+/**************************************************************************/
+/*!
+ Writes an NDEF URI Record to the specified sector (1..15)
+
+ Note that this function assumes that the Mifare Classic card is
+ already formatted to work as an "NFC Forum Tag" and uses a MAD1
+ file system. You can use the NXP TagWriter app on Android to
+ properly format cards for this.
+
+ @param sectorNumber The sector that the URI record should be written
+ to (can be 1..15 for a 1K card)
+ @param uriIdentifier The uri identifier code (0 = none, 0x01 =
+ "http://www.", etc.)
+ @param url The uri text to write (max 38 characters).
+
+ @returns 1 if everything executed properly, 0 for an error
+*/
+/**************************************************************************/
+uint8_t Adafruit_PN532::mifareclassic_WriteNDEFURI(uint8_t sectorNumber,
+ uint8_t uriIdentifier,
+ const char *url) {
+ // Figure out how long the string is
+ uint8_t len = strlen(url);
+
+ // Make sure we're within a 1K limit for the sector number
+ if ((sectorNumber < 1) || (sectorNumber > 15))
+ return 0;
+
+ // Make sure the URI payload is between 1 and 38 chars
+ if ((len < 1) || (len > 38))
+ return 0;
+
+ // Note 0xD3 0xF7 0xD3 0xF7 0xD3 0xF7 must be used for key A
+ // in NDEF records
+
+ // Setup the sector buffer (w/pre-formatted TLV wrapper and NDEF message)
+ uint8_t sectorbuffer1[16] = {0x00,
+ 0x00,
+ 0x03,
+ (uint8_t)(len + 5),
+ 0xD1,
+ 0x01,
+ (uint8_t)(len + 1),
+ 0x55,
+ uriIdentifier,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00};
+ uint8_t sectorbuffer2[16] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00};
+ uint8_t sectorbuffer3[16] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00};
+ uint8_t sectorbuffer4[16] = {0xD3, 0xF7, 0xD3, 0xF7, 0xD3, 0xF7,
+ 0x7F, 0x07, 0x88, 0x40, 0xFF, 0xFF,
+ 0xFF, 0xFF, 0xFF, 0xFF};
+ if (len <= 6) {
+ // Unlikely we'll get a url this short, but why not ...
+ memcpy(sectorbuffer1 + 9, url, len);
+ sectorbuffer1[len + 9] = 0xFE;
+ } else if (len == 7) {
+ // 0xFE needs to be wrapped around to next block
+ memcpy(sectorbuffer1 + 9, url, len);
+ sectorbuffer2[0] = 0xFE;
+ } else if ((len > 7) && (len <= 22)) {
+ // Url fits in two blocks
+ memcpy(sectorbuffer1 + 9, url, 7);
+ memcpy(sectorbuffer2, url + 7, len - 7);
+ sectorbuffer2[len - 7] = 0xFE;
+ } else if (len == 23) {
+ // 0xFE needs to be wrapped around to final block
+ memcpy(sectorbuffer1 + 9, url, 7);
+ memcpy(sectorbuffer2, url + 7, len - 7);
+ sectorbuffer3[0] = 0xFE;
+ } else {
+ // Url fits in three blocks
+ memcpy(sectorbuffer1 + 9, url, 7);
+ memcpy(sectorbuffer2, url + 7, 16);
+ memcpy(sectorbuffer3, url + 23, len - 24);
+ sectorbuffer3[len - 22] = 0xFE;
+ }
+
+ // Now write all three blocks back to the card
+ if (!(mifareclassic_WriteDataBlock(sectorNumber * 4, sectorbuffer1)))
+ return 0;
+ if (!(mifareclassic_WriteDataBlock((sectorNumber * 4) + 1, sectorbuffer2)))
+ return 0;
+ if (!(mifareclassic_WriteDataBlock((sectorNumber * 4) + 2, sectorbuffer3)))
+ return 0;
+ if (!(mifareclassic_WriteDataBlock((sectorNumber * 4) + 3, sectorbuffer4)))
+ return 0;
+
+ // Seems that everything was OK (?!)
+ return 1;
+}
+
+/***** Mifare Ultralight Functions ******/
+
+/**************************************************************************/
+/*!
+ @brief Tries to read an entire 4-byte page at the specified address.
+
+ @param page The page number (0..63 in most cases)
+ @param buffer Pointer to the byte array that will hold the
+ retrieved data (if any)
+ @return 1 on success, 0 on error.
+*/
+/**************************************************************************/
+uint8_t Adafruit_PN532::mifareultralight_ReadPage(uint8_t page,
+ uint8_t *buffer) {
+ if (page >= 64) {
+#ifdef MIFAREDEBUG
+ PN532DEBUGPRINT.println(F("Page value out of range"));
+#endif
+ return 0;
+ }
+
+#ifdef MIFAREDEBUG
+ PN532DEBUGPRINT.print(F("Reading page "));
+ PN532DEBUGPRINT.println(page);
+#endif
+
+ /* Prepare the command */
+ pn532_packetbuffer[0] = PN532_COMMAND_INDATAEXCHANGE;
+ pn532_packetbuffer[1] = 1; /* Card number */
+ pn532_packetbuffer[2] = MIFARE_CMD_READ; /* Mifare Read command = 0x30 */
+ pn532_packetbuffer[3] = page; /* Page Number (0..63 in most cases) */
+
+ /* Send the command */
+ if (!sendCommandCheckAck(pn532_packetbuffer, 4)) {
+#ifdef MIFAREDEBUG
+ PN532DEBUGPRINT.println(F("Failed to receive ACK for write command"));
+#endif
+ return 0;
+ }
+
+ /* Read the response packet */
+ readdata(pn532_packetbuffer, 26);
+#ifdef MIFAREDEBUG
+ PN532DEBUGPRINT.println(F("Received: "));
+ Adafruit_PN532::PrintHexChar(pn532_packetbuffer, 26);
+#endif
+
+ /* If byte 8 isn't 0x00 we probably have an error */
+ if (pn532_packetbuffer[7] == 0x00) {
+ /* Copy the 4 data bytes to the output buffer */
+ /* Block content starts at byte 9 of a valid response */
+ /* Note that the command actually reads 16 byte or 4 */
+ /* pages at a time ... we simply discard the last 12 */
+ /* bytes */
+ memcpy(buffer, pn532_packetbuffer + 8, 4);
+ } else {
+#ifdef MIFAREDEBUG
+ PN532DEBUGPRINT.println(F("Unexpected response reading block: "));
+ Adafruit_PN532::PrintHexChar(pn532_packetbuffer, 26);
+#endif
+ return 0;
+ }
+
+/* Display data for debug if requested */
+#ifdef MIFAREDEBUG
+ PN532DEBUGPRINT.print(F("Page "));
+ PN532DEBUGPRINT.print(page);
+ PN532DEBUGPRINT.println(F(":"));
+ Adafruit_PN532::PrintHexChar(buffer, 4);
+#endif
+
+ // Return OK signal
+ return 1;
+}
+
+/**************************************************************************/
+/*!
+ Tries to write an entire 4-byte page at the specified block
+ address.
+
+ @param page The page number to write. (0..63 for most cases)
+ @param data The byte array that contains the data to write.
+ Should be exactly 4 bytes long.
+
+ @returns 1 if everything executed properly, 0 for an error
+*/
+/**************************************************************************/
+uint8_t Adafruit_PN532::mifareultralight_WritePage(uint8_t page,
+ uint8_t *data) {
+
+ if (page >= 64) {
+#ifdef MIFAREDEBUG
+ PN532DEBUGPRINT.println(F("Page value out of range"));
+#endif
+ // Return Failed Signal
+ return 0;
+ }
+
+#ifdef MIFAREDEBUG
+ PN532DEBUGPRINT.print(F("Trying to write 4 byte page"));
+ PN532DEBUGPRINT.println(page);
+#endif
+
+ /* Prepare the first command */
+ pn532_packetbuffer[0] = PN532_COMMAND_INDATAEXCHANGE;
+ pn532_packetbuffer[1] = 1; /* Card number */
+ pn532_packetbuffer[2] =
+ MIFARE_ULTRALIGHT_CMD_WRITE; /* Mifare Ultralight Write command = 0xA2
+ */
+ pn532_packetbuffer[3] = page; /* Page Number (0..63 for most cases) */
+ memcpy(pn532_packetbuffer + 4, data, 4); /* Data Payload */
+
+ /* Send the command */
+ if (!sendCommandCheckAck(pn532_packetbuffer, 8)) {
+#ifdef MIFAREDEBUG
+ PN532DEBUGPRINT.println(F("Failed to receive ACK for write command"));
+#endif
+
+ // Return Failed Signal
+ return 0;
+ }
+ delay(10);
+
+ /* Read the response packet */
+ readdata(pn532_packetbuffer, 26);
+
+ // Return OK Signal
+ return 1;
+}
+
+/***** NTAG2xx Functions ******/
+
+/**************************************************************************/
+/*!
+ @brief Tries to read an entire 4-byte page at the specified address.
+
+ @param page The page number (0..63 in most cases)
+ @param buffer Pointer to the byte array that will hold the
+ retrieved data (if any)
+ @return 1 on success, 0 on error.
+*/
+/**************************************************************************/
+uint8_t Adafruit_PN532::ntag2xx_ReadPage(uint8_t page, uint8_t *buffer) {
+ // TAG Type PAGES USER START USER STOP
+ // -------- ----- ---------- ---------
+ // NTAG 203 42 4 39
+ // NTAG 213 45 4 39
+ // NTAG 215 135 4 129
+ // NTAG 216 231 4 225
+
+ if (page >= 231) {
+#ifdef MIFAREDEBUG
+ PN532DEBUGPRINT.println(F("Page value out of range"));
+#endif
+ return 0;
+ }
+
+#ifdef MIFAREDEBUG
+ PN532DEBUGPRINT.print(F("Reading page "));
+ PN532DEBUGPRINT.println(page);
+#endif
+
+ /* Prepare the command */
+ pn532_packetbuffer[0] = PN532_COMMAND_INDATAEXCHANGE;
+ pn532_packetbuffer[1] = 1; /* Card number */
+ pn532_packetbuffer[2] = MIFARE_CMD_READ; /* Mifare Read command = 0x30 */
+ pn532_packetbuffer[3] = page; /* Page Number (0..63 in most cases) */
+
+ /* Send the command */
+ if (!sendCommandCheckAck(pn532_packetbuffer, 4)) {
+#ifdef MIFAREDEBUG
+ PN532DEBUGPRINT.println(F("Failed to receive ACK for write command"));
+#endif
+ return 0;
+ }
+
+ /* Read the response packet */
+ readdata(pn532_packetbuffer, 26);
+#ifdef MIFAREDEBUG
+ PN532DEBUGPRINT.println(F("Received: "));
+ Adafruit_PN532::PrintHexChar(pn532_packetbuffer, 26);
+#endif
+
+ /* If byte 8 isn't 0x00 we probably have an error */
+ if (pn532_packetbuffer[7] == 0x00) {
+ /* Copy the 4 data bytes to the output buffer */
+ /* Block content starts at byte 9 of a valid response */
+ /* Note that the command actually reads 16 byte or 4 */
+ /* pages at a time ... we simply discard the last 12 */
+ /* bytes */
+ memcpy(buffer, pn532_packetbuffer + 8, 4);
+ } else {
+#ifdef MIFAREDEBUG
+ PN532DEBUGPRINT.println(F("Unexpected response reading block: "));
+ Adafruit_PN532::PrintHexChar(pn532_packetbuffer, 26);
+#endif
+ return 0;
+ }
+
+/* Display data for debug if requested */
+#ifdef MIFAREDEBUG
+ PN532DEBUGPRINT.print(F("Page "));
+ PN532DEBUGPRINT.print(page);
+ PN532DEBUGPRINT.println(F(":"));
+ Adafruit_PN532::PrintHexChar(buffer, 4);
+#endif
+
+ // Return OK signal
+ return 1;
+}
+
+/**************************************************************************/
+/*!
+ Tries to write an entire 4-byte page at the specified block
+ address.
+
+ @param page The page number to write. (0..63 for most cases)
+ @param data The byte array that contains the data to write.
+ Should be exactly 4 bytes long.
+
+ @returns 1 if everything executed properly, 0 for an error
+*/
+/**************************************************************************/
+uint8_t Adafruit_PN532::ntag2xx_WritePage(uint8_t page, uint8_t *data) {
+ // TAG Type PAGES USER START USER STOP
+ // -------- ----- ---------- ---------
+ // NTAG 203 42 4 39
+ // NTAG 213 45 4 39
+ // NTAG 215 135 4 129
+ // NTAG 216 231 4 225
+
+ if ((page < 4) || (page > 225)) {
+#ifdef MIFAREDEBUG
+ PN532DEBUGPRINT.println(F("Page value out of range"));
+#endif
+ // Return Failed Signal
+ return 0;
+ }
+
+#ifdef MIFAREDEBUG
+ PN532DEBUGPRINT.print(F("Trying to write 4 byte page"));
+ PN532DEBUGPRINT.println(page);
+#endif
+
+ /* Prepare the first command */
+ pn532_packetbuffer[0] = PN532_COMMAND_INDATAEXCHANGE;
+ pn532_packetbuffer[1] = 1; /* Card number */
+ pn532_packetbuffer[2] =
+ MIFARE_ULTRALIGHT_CMD_WRITE; /* Mifare Ultralight Write command = 0xA2
+ */
+ pn532_packetbuffer[3] = page; /* Page Number (0..63 for most cases) */
+ memcpy(pn532_packetbuffer + 4, data, 4); /* Data Payload */
+
+ /* Send the command */
+ if (!sendCommandCheckAck(pn532_packetbuffer, 8)) {
+#ifdef MIFAREDEBUG
+ PN532DEBUGPRINT.println(F("Failed to receive ACK for write command"));
+#endif
+
+ // Return Failed Signal
+ return 0;
+ }
+ delay(10);
+
+ /* Read the response packet */
+ readdata(pn532_packetbuffer, 26);
+
+ // Return OK Signal
+ return 1;
+}
+
+/**************************************************************************/
+/*!
+ Writes an NDEF URI Record starting at the specified page (4..nn)
+
+ Note that this function assumes that the NTAG2xx card is
+ already formatted to work as an "NFC Forum Tag".
+
+ @param uriIdentifier The uri identifier code (0 = none, 0x01 =
+ "http://www.", etc.)
+ @param url The uri text to write (null-terminated string).
+ @param dataLen The size of the data area for overflow checks.
+
+ @returns 1 if everything executed properly, 0 for an error
+*/
+/**************************************************************************/
+uint8_t Adafruit_PN532::ntag2xx_WriteNDEFURI(uint8_t uriIdentifier, char *url,
+ uint8_t dataLen) {
+ uint8_t pageBuffer[4] = {0, 0, 0, 0};
+
+ // Remove NDEF record overhead from the URI data (pageHeader below)
+ uint8_t wrapperSize = 12;
+
+ // Figure out how long the string is
+ uint8_t len = strlen(url);
+
+ // Make sure the URI payload will fit in dataLen (include 0xFE trailer)
+ if ((len < 1) || (len + 1 > (dataLen - wrapperSize)))
+ return 0;
+
+ // Setup the record header
+ // See NFCForum-TS-Type-2-Tag_1.1.pdf for details
+ uint8_t pageHeader[12] = {
+ /* NDEF Lock Control TLV (must be first and always present) */
+ 0x01, /* Tag Field (0x01 = Lock Control TLV) */
+ 0x03, /* Payload Length (always 3) */
+ 0xA0, /* The position inside the tag of the lock bytes (upper 4 = page
+ address, lower 4 = byte offset) */
+ 0x10, /* Size in bits of the lock area */
+ 0x44, /* Size in bytes of a page and the number of bytes each lock bit
+ can lock (4 bit + 4 bits) */
+ /* NDEF Message TLV - URI Record */
+ 0x03, /* Tag Field (0x03 = NDEF Message) */
+ (uint8_t)(len + 5), /* Payload Length (not including 0xFE trailer) */
+ 0xD1, /* NDEF Record Header (TNF=0x1:Well known record + SR + ME + MB)
+ */
+ 0x01, /* Type Length for the record type indicator */
+ (uint8_t)(len + 1), /* Payload len */
+ 0x55, /* Record Type Indicator (0x55 or 'U' = URI Record) */
+ uriIdentifier /* URI Prefix (ex. 0x01 = "http://www.") */
+ };
+
+ // Write 12 byte header (three pages of data starting at page 4)
+ memcpy(pageBuffer, pageHeader, 4);
+ if (!(ntag2xx_WritePage(4, pageBuffer)))
+ return 0;
+ memcpy(pageBuffer, pageHeader + 4, 4);
+ if (!(ntag2xx_WritePage(5, pageBuffer)))
+ return 0;
+ memcpy(pageBuffer, pageHeader + 8, 4);
+ if (!(ntag2xx_WritePage(6, pageBuffer)))
+ return 0;
+
+ // Write URI (starting at page 7)
+ uint8_t currentPage = 7;
+ char *urlcopy = url;
+ while (len) {
+ if (len < 4) {
+ memset(pageBuffer, 0, 4);
+ memcpy(pageBuffer, urlcopy, len);
+ pageBuffer[len] = 0xFE; // NDEF record footer
+ if (!(ntag2xx_WritePage(currentPage, pageBuffer)))
+ return 0;
+ // DONE!
+ return 1;
+ } else if (len == 4) {
+ memcpy(pageBuffer, urlcopy, len);
+ if (!(ntag2xx_WritePage(currentPage, pageBuffer)))
+ return 0;
+ memset(pageBuffer, 0, 4);
+ pageBuffer[0] = 0xFE; // NDEF record footer
+ currentPage++;
+ if (!(ntag2xx_WritePage(currentPage, pageBuffer)))
+ return 0;
+ // DONE!
+ return 1;
+ } else {
+ // More than one page of data left
+ memcpy(pageBuffer, urlcopy, 4);
+ if (!(ntag2xx_WritePage(currentPage, pageBuffer)))
+ return 0;
+ currentPage++;
+ urlcopy += 4;
+ len -= 4;
+ }
+ }
+
+ // Seems that everything was OK (?!)
+ return 1;
+}
+
+/************** high level communication functions (handles both I2C and SPI) */
+
+/**************************************************************************/
+/*!
+ @brief Tries to read the SPI or I2C ACK signal
+*/
+/**************************************************************************/
+bool Adafruit_PN532::readack() {
+ uint8_t ackbuff[6];
+
+ if (spi_dev) {
+ uint8_t cmd = PN532_SPI_DATAREAD;
+ spi_dev->write_then_read(&cmd, 1, ackbuff, 6);
+ } else if (i2c_dev || ser_dev) {
+ readdata(ackbuff, 6);
+ }
+
+ return (0 == memcmp((char *)ackbuff, (char *)pn532ack, 6));
+}
+
+/**************************************************************************/
+/*!
+ @brief Return true if the PN532 is ready with a response.
+*/
+/**************************************************************************/
+bool Adafruit_PN532::isready() {
+ if (spi_dev) {
+ // SPI ready check via Status Request
+ uint8_t cmd = PN532_SPI_STATREAD;
+ uint8_t reply;
+ spi_dev->write_then_read(&cmd, 1, &reply, 1);
+ return reply == PN532_SPI_READY;
+ } else if (i2c_dev) {
+ // I2C ready check via reading RDY byte
+ uint8_t rdy[1];
+ i2c_dev->read(rdy, 1);
+ return rdy[0] == PN532_I2C_READY;
+ } else if (ser_dev) {
+ // Serial ready check based on non-zero read buffer
+ return (ser_dev->available() != 0);
+ } else if (_irq != -1) {
+ uint8_t x = digitalRead(_irq);
+ return x == 0;
+ }
+ return false;
+}
+
+/**************************************************************************/
+/*!
+ @brief Waits until the PN532 is ready.
+
+ @param timeout Timeout before giving up
+*/
+/**************************************************************************/
+bool Adafruit_PN532::waitready(uint16_t timeout) {
+ uint16_t timer = 0;
+ while (!isready()) {
+ if (timeout != 0) {
+ timer += 10;
+ if (timer > timeout) {
+#ifdef PN532DEBUG
+ PN532DEBUGPRINT.println("TIMEOUT!");
+#endif
+ return false;
+ }
+ }
+ delay(10);
+ }
+ return true;
+}
+
+/**************************************************************************/
+/*!
+ @brief Reads n bytes of data from the PN532 via SPI or I2C.
+
+ @param buff Pointer to the buffer where data will be written
+ @param n Number of bytes to be read
+*/
+/**************************************************************************/
+void Adafruit_PN532::readdata(uint8_t *buff, uint8_t n) {
+ if (spi_dev) {
+ // SPI read
+ uint8_t cmd = PN532_SPI_DATAREAD;
+ spi_dev->write_then_read(&cmd, 1, buff, n);
+ } else if (i2c_dev) {
+ // I2C read
+ uint8_t rbuff[n + 1]; // +1 for leading RDY byte
+ i2c_dev->read(rbuff, n + 1);
+ for (uint8_t i = 0; i < n; i++) {
+ buff[i] = rbuff[i + 1];
+ }
+ } else if (ser_dev) {
+ // Serial read
+ ser_dev->readBytes(buff, n);
+ }
+#ifdef PN532DEBUG
+ PN532DEBUGPRINT.print(F("Reading: "));
+ for (uint8_t i = 0; i < n; i++) {
+ PN532DEBUGPRINT.print(F(" 0x"));
+ PN532DEBUGPRINT.print(buff[i], HEX);
+ }
+ PN532DEBUGPRINT.println();
+#endif
+}
+
+/**************************************************************************/
+/*!
+ @brief set the PN532 as iso14443a Target behaving as a SmartCard
+ @return true on success, false otherwise.
+ @note Author: Salvador Mendoza (salmg.net) new functions:
+ -AsTarget
+ -getDataTarget
+ -setDataTarget
+*/
+/**************************************************************************/
+uint8_t Adafruit_PN532::AsTarget() {
+ pn532_packetbuffer[0] = 0x8C;
+ uint8_t target[] = {
+ 0x8C, // INIT AS TARGET
+ 0x00, // MODE -> BITFIELD
+ 0x08, 0x00, // SENS_RES - MIFARE PARAMS
+ 0xdc, 0x44, 0x20, // NFCID1T
+ 0x60, // SEL_RES
+ 0x01, 0xfe, // NFCID2T MUST START WITH 01fe - FELICA PARAMS - POL_RES
+ 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xc0,
+ 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, // PAD
+ 0xff, 0xff, // SYSTEM CODE
+ 0xaa, 0x99, 0x88, 0x77, 0x66, 0x55, 0x44,
+ 0x33, 0x22, 0x11, 0x01, 0x00, // NFCID3t MAX 47 BYTES ATR_RES
+ 0x0d, 0x52, 0x46, 0x49, 0x44, 0x49, 0x4f,
+ 0x74, 0x20, 0x50, 0x4e, 0x35, 0x33, 0x32 // HISTORICAL BYTES
+ };
+ if (!sendCommandCheckAck(target, sizeof(target)))
+ return false;
+
+ // read data packet
+ readdata(pn532_packetbuffer, 8);
+
+ int offset = 6;
+ return (pn532_packetbuffer[offset] == 0x15);
+}
+/**************************************************************************/
+/*!
+ @brief Retrieve response from the emulation mode
+
+ @param cmd = data
+ @param cmdlen = data length
+ @return true on success, false otherwise.
+*/
+/**************************************************************************/
+uint8_t Adafruit_PN532::getDataTarget(uint8_t *cmd, uint8_t *cmdlen) {
+ uint8_t length;
+ pn532_packetbuffer[0] = 0x86;
+ if (!sendCommandCheckAck(pn532_packetbuffer, 1, 1000)) {
+ 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;
+}
+
+/**************************************************************************/
+/*!
+ @brief Set data in PN532 in the emulation mode
+
+ @param cmd = data
+ @param cmdlen = data length
+ @return true on success, false otherwise.
+*/
+/**************************************************************************/
+uint8_t Adafruit_PN532::setDataTarget(uint8_t *cmd, uint8_t cmdlen) {
+ uint8_t length;
+ // cmd1[0] = 0x8E; Must!
+
+ if (!sendCommandCheckAck(cmd, cmdlen))
+ return false;
+
+ // read data packet
+ readdata(pn532_packetbuffer, 8);
+ length = pn532_packetbuffer[3] - 3;
+ for (int i = 0; i < length; ++i) {
+ cmd[i] = pn532_packetbuffer[8 + i];
+ }
+ // cmdl = 0
+ cmdlen = length;
+
+ int offset = 6;
+ return (pn532_packetbuffer[offset] == 0x15);
+}
+
+/**************************************************************************/
+/*!
+ @brief Writes a command to the PN532, automatically inserting the
+ preamble and required frame details (checksum, len, etc.)
+
+ @param cmd Pointer to the command buffer
+ @param cmdlen Command length in bytes
+*/
+/**************************************************************************/
+void Adafruit_PN532::writecommand(uint8_t *cmd, uint8_t cmdlen) {
+ if (spi_dev) {
+ // SPI command write.
+ uint8_t checksum;
+ uint8_t packet[9 + cmdlen];
+ uint8_t *p = packet;
+ cmdlen++;
+
+ p[0] = PN532_SPI_DATAWRITE;
+ p++;
+
+ p[0] = PN532_PREAMBLE;
+ p++;
+ p[0] = PN532_STARTCODE1;
+ p++;
+ p[0] = PN532_STARTCODE2;
+ p++;
+ checksum = PN532_PREAMBLE + PN532_STARTCODE1 + PN532_STARTCODE2;
+
+ p[0] = cmdlen;
+ p++;
+ p[0] = ~cmdlen + 1;
+ p++;
+
+ p[0] = PN532_HOSTTOPN532;
+ p++;
+ checksum += PN532_HOSTTOPN532;
+
+ for (uint8_t i = 0; i < cmdlen - 1; i++) {
+ p[0] = cmd[i];
+ p++;
+ checksum += cmd[i];
+ }
+
+ p[0] = ~checksum;
+ p++;
+ p[0] = PN532_POSTAMBLE;
+ p++;
+
+#ifdef PN532DEBUG
+ Serial.print("Sending : ");
+ for (int i = 1; i < 8 + cmdlen; i++) {
+ Serial.print("0x");
+ Serial.print(packet[i], HEX);
+ Serial.print(", ");
+ }
+ Serial.println();
+#endif
+
+ spi_dev->write(packet, 8 + cmdlen);
+ } else if (i2c_dev || ser_dev) {
+ // I2C or Serial command write.
+ uint8_t packet[8 + cmdlen];
+ uint8_t LEN = cmdlen + 1;
+
+ packet[0] = PN532_PREAMBLE;
+ packet[1] = PN532_STARTCODE1;
+ packet[2] = PN532_STARTCODE2;
+ packet[3] = LEN;
+ packet[4] = ~LEN + 1;
+ packet[5] = PN532_HOSTTOPN532;
+ uint8_t sum = 0;
+ for (uint8_t i = 0; i < cmdlen; i++) {
+ packet[6 + i] = cmd[i];
+ sum += cmd[i];
+ }
+ packet[6 + cmdlen] = ~(PN532_HOSTTOPN532 + sum) + 1;
+ packet[7 + cmdlen] = PN532_POSTAMBLE;
+
+#ifdef PN532DEBUG
+ Serial.print("Sending : ");
+ for (int i = 1; i < 8 + cmdlen; i++) {
+ Serial.print("0x");
+ Serial.print(packet[i], HEX);
+ Serial.print(", ");
+ }
+ Serial.println();
+#endif
+
+ if (i2c_dev) {
+ i2c_dev->write(packet, 8 + cmdlen);
+ } else {
+ ser_dev->write(packet, 8 + cmdlen);
+ }
+ }
+}
diff --git a/.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/Adafruit_PN532.h b/.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/Adafruit_PN532.h
new file mode 100644
index 0000000..d211f58
--- /dev/null
+++ b/.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/Adafruit_PN532.h
@@ -0,0 +1,223 @@
+/**************************************************************************/
+/*!
+ @file Adafruit_PN532.h
+
+ v2.0 - Refactored to add I2C support from Adafruit_NFCShield_I2C library.
+
+ v1.1 - Added full command list
+ - Added 'verbose' mode flag to constructor to toggle debug output
+ - Changed readPassiveTargetID() to return variable length values
+*/
+/**************************************************************************/
+
+#ifndef ADAFRUIT_PN532_H
+#define ADAFRUIT_PN532_H
+
+#include "Arduino.h"
+
+#include <Adafruit_I2CDevice.h>
+#include <Adafruit_SPIDevice.h>
+
+#define PN532_PREAMBLE (0x00) ///< Command sequence start, byte 1/3
+#define PN532_STARTCODE1 (0x00) ///< Command sequence start, byte 2/3
+#define PN532_STARTCODE2 (0xFF) ///< Command sequence start, byte 3/3
+#define PN532_POSTAMBLE (0x00) ///< EOD
+
+#define PN532_HOSTTOPN532 (0xD4) ///< Host-to-PN532
+#define PN532_PN532TOHOST (0xD5) ///< PN532-to-host
+
+// PN532 Commands
+#define PN532_COMMAND_DIAGNOSE (0x00) ///< Diagnose
+#define PN532_COMMAND_GETFIRMWAREVERSION (0x02) ///< Get firmware version
+#define PN532_COMMAND_GETGENERALSTATUS (0x04) ///< Get general status
+#define PN532_COMMAND_READREGISTER (0x06) ///< Read register
+#define PN532_COMMAND_WRITEREGISTER (0x08) ///< Write register
+#define PN532_COMMAND_READGPIO (0x0C) ///< Read GPIO
+#define PN532_COMMAND_WRITEGPIO (0x0E) ///< Write GPIO
+#define PN532_COMMAND_SETSERIALBAUDRATE (0x10) ///< Set serial baud rate
+#define PN532_COMMAND_SETPARAMETERS (0x12) ///< Set parameters
+#define PN532_COMMAND_SAMCONFIGURATION (0x14) ///< SAM configuration
+#define PN532_COMMAND_POWERDOWN (0x16) ///< Power down
+#define PN532_COMMAND_RFCONFIGURATION (0x32) ///< RF config
+#define PN532_COMMAND_RFREGULATIONTEST (0x58) ///< RF regulation test
+#define PN532_COMMAND_INJUMPFORDEP (0x56) ///< Jump for DEP
+#define PN532_COMMAND_INJUMPFORPSL (0x46) ///< Jump for PSL
+#define PN532_COMMAND_INLISTPASSIVETARGET (0x4A) ///< List passive target
+#define PN532_COMMAND_INATR (0x50) ///< ATR
+#define PN532_COMMAND_INPSL (0x4E) ///< PSL
+#define PN532_COMMAND_INDATAEXCHANGE (0x40) ///< Data exchange
+#define PN532_COMMAND_INCOMMUNICATETHRU (0x42) ///< Communicate through
+#define PN532_COMMAND_INDESELECT (0x44) ///< Deselect
+#define PN532_COMMAND_INRELEASE (0x52) ///< Release
+#define PN532_COMMAND_INSELECT (0x54) ///< Select
+#define PN532_COMMAND_INAUTOPOLL (0x60) ///< Auto poll
+#define PN532_COMMAND_TGINITASTARGET (0x8C) ///< Init as target
+#define PN532_COMMAND_TGSETGENERALBYTES (0x92) ///< Set general bytes
+#define PN532_COMMAND_TGGETDATA (0x86) ///< Get data
+#define PN532_COMMAND_TGSETDATA (0x8E) ///< Set data
+#define PN532_COMMAND_TGSETMETADATA (0x94) ///< Set metadata
+#define PN532_COMMAND_TGGETINITIATORCOMMAND (0x88) ///< Get initiator command
+#define PN532_COMMAND_TGRESPONSETOINITIATOR (0x90) ///< Response to initiator
+#define PN532_COMMAND_TGGETTARGETSTATUS (0x8A) ///< Get target status
+
+#define PN532_RESPONSE_INDATAEXCHANGE (0x41) ///< Data exchange
+#define PN532_RESPONSE_INLISTPASSIVETARGET (0x4B) ///< List passive target
+
+#define PN532_WAKEUP (0x55) ///< Wake
+
+#define PN532_SPI_STATREAD (0x02) ///< Stat read
+#define PN532_SPI_DATAWRITE (0x01) ///< Data write
+#define PN532_SPI_DATAREAD (0x03) ///< Data read
+#define PN532_SPI_READY (0x01) ///< Ready
+
+#define PN532_I2C_ADDRESS (0x48 >> 1) ///< Default I2C address
+#define PN532_I2C_READBIT (0x01) ///< Read bit
+#define PN532_I2C_BUSY (0x00) ///< Busy
+#define PN532_I2C_READY (0x01) ///< Ready
+#define PN532_I2C_READYTIMEOUT (20) ///< Ready timeout
+
+#define PN532_MIFARE_ISO14443A (0x00) ///< MiFare
+
+// Mifare Commands
+#define MIFARE_CMD_AUTH_A (0x60) ///< Auth A
+#define MIFARE_CMD_AUTH_B (0x61) ///< Auth B
+#define MIFARE_CMD_READ (0x30) ///< Read
+#define MIFARE_CMD_WRITE (0xA0) ///< Write
+#define MIFARE_CMD_TRANSFER (0xB0) ///< Transfer
+#define MIFARE_CMD_DECREMENT (0xC0) ///< Decrement
+#define MIFARE_CMD_INCREMENT (0xC1) ///< Increment
+#define MIFARE_CMD_STORE (0xC2) ///< Store
+#define MIFARE_ULTRALIGHT_CMD_WRITE (0xA2) ///< Write (MiFare Ultralight)
+
+// Prefixes for NDEF Records (to identify record type)
+#define NDEF_URIPREFIX_NONE (0x00) ///< No prefix
+#define NDEF_URIPREFIX_HTTP_WWWDOT (0x01) ///< HTTP www. prefix
+#define NDEF_URIPREFIX_HTTPS_WWWDOT (0x02) ///< HTTPS www. prefix
+#define NDEF_URIPREFIX_HTTP (0x03) ///< HTTP prefix
+#define NDEF_URIPREFIX_HTTPS (0x04) ///< HTTPS prefix
+#define NDEF_URIPREFIX_TEL (0x05) ///< Tel prefix
+#define NDEF_URIPREFIX_MAILTO (0x06) ///< Mailto prefix
+#define NDEF_URIPREFIX_FTP_ANONAT (0x07) ///< FTP
+#define NDEF_URIPREFIX_FTP_FTPDOT (0x08) ///< FTP dot
+#define NDEF_URIPREFIX_FTPS (0x09) ///< FTPS
+#define NDEF_URIPREFIX_SFTP (0x0A) ///< SFTP
+#define NDEF_URIPREFIX_SMB (0x0B) ///< SMB
+#define NDEF_URIPREFIX_NFS (0x0C) ///< NFS
+#define NDEF_URIPREFIX_FTP (0x0D) ///< FTP
+#define NDEF_URIPREFIX_DAV (0x0E) ///< DAV
+#define NDEF_URIPREFIX_NEWS (0x0F) ///< NEWS
+#define NDEF_URIPREFIX_TELNET (0x10) ///< Telnet prefix
+#define NDEF_URIPREFIX_IMAP (0x11) ///< IMAP prefix
+#define NDEF_URIPREFIX_RTSP (0x12) ///< RTSP
+#define NDEF_URIPREFIX_URN (0x13) ///< URN
+#define NDEF_URIPREFIX_POP (0x14) ///< POP
+#define NDEF_URIPREFIX_SIP (0x15) ///< SIP
+#define NDEF_URIPREFIX_SIPS (0x16) ///< SIPS
+#define NDEF_URIPREFIX_TFTP (0x17) ///< TFPT
+#define NDEF_URIPREFIX_BTSPP (0x18) ///< BTSPP
+#define NDEF_URIPREFIX_BTL2CAP (0x19) ///< BTL2CAP
+#define NDEF_URIPREFIX_BTGOEP (0x1A) ///< BTGOEP
+#define NDEF_URIPREFIX_TCPOBEX (0x1B) ///< TCPOBEX
+#define NDEF_URIPREFIX_IRDAOBEX (0x1C) ///< IRDAOBEX
+#define NDEF_URIPREFIX_FILE (0x1D) ///< File
+#define NDEF_URIPREFIX_URN_EPC_ID (0x1E) ///< URN EPC ID
+#define NDEF_URIPREFIX_URN_EPC_TAG (0x1F) ///< URN EPC tag
+#define NDEF_URIPREFIX_URN_EPC_PAT (0x20) ///< URN EPC pat
+#define NDEF_URIPREFIX_URN_EPC_RAW (0x21) ///< URN EPC raw
+#define NDEF_URIPREFIX_URN_EPC (0x22) ///< URN EPC
+#define NDEF_URIPREFIX_URN_NFC (0x23) ///< URN NFC
+
+#define PN532_GPIO_VALIDATIONBIT (0x80) ///< GPIO validation bit
+#define PN532_GPIO_P30 (0) ///< GPIO 30
+#define PN532_GPIO_P31 (1) ///< GPIO 31
+#define PN532_GPIO_P32 (2) ///< GPIO 32
+#define PN532_GPIO_P33 (3) ///< GPIO 33
+#define PN532_GPIO_P34 (4) ///< GPIO 34
+#define PN532_GPIO_P35 (5) ///< GPIO 35
+
+/**
+ * @brief Class for working with Adafruit PN532 NFC/RFID breakout boards.
+ */
+class Adafruit_PN532 {
+ public:
+ Adafruit_PN532(uint8_t clk, uint8_t miso, uint8_t mosi,
+ uint8_t ss); // Software SPI
+ Adafruit_PN532(uint8_t ss, SPIClass *theSPI = &SPI); // Hardware SPI
+ Adafruit_PN532(uint8_t irq, uint8_t reset,
+ TwoWire *theWire = &Wire); // Hardware I2C
+ Adafruit_PN532(uint8_t reset, HardwareSerial *theSer); // Hardware UART
+ bool begin(void);
+
+ void reset(void);
+ void wakeup(void);
+
+ // Generic PN532 functions
+ bool SAMConfig(void);
+ uint32_t getFirmwareVersion(void);
+ bool sendCommandCheckAck(uint8_t *cmd, uint8_t cmdlen,
+ uint16_t timeout = 100);
+ bool writeGPIO(uint8_t pinstate);
+ uint8_t readGPIO(void);
+ bool setPassiveActivationRetries(uint8_t maxRetries);
+
+ // ISO14443A functions
+ bool readPassiveTargetID(
+ uint8_t cardbaudrate, uint8_t *uid, uint8_t *uidLength,
+ uint16_t timeout =
+ 0); // timeout 0 means no timeout - will block forever.
+ bool startPassiveTargetIDDetection(uint8_t cardbaudrate);
+ bool readDetectedPassiveTargetID(uint8_t *uid, uint8_t *uidLength);
+ bool inDataExchange(uint8_t *send, uint8_t sendLength, uint8_t *response,
+ uint8_t *responseLength);
+ bool inListPassiveTarget();
+ uint8_t AsTarget();
+ uint8_t getDataTarget(uint8_t *cmd, uint8_t *cmdlen);
+ uint8_t setDataTarget(uint8_t *cmd, uint8_t cmdlen);
+
+ // Mifare Classic functions
+ bool mifareclassic_IsFirstBlock(uint32_t uiBlock);
+ bool mifareclassic_IsTrailerBlock(uint32_t uiBlock);
+ uint8_t mifareclassic_AuthenticateBlock(uint8_t *uid, uint8_t uidLen,
+ uint32_t blockNumber,
+ uint8_t keyNumber,
+ uint8_t *keyData);
+ uint8_t mifareclassic_ReadDataBlock(uint8_t blockNumber, uint8_t *data);
+ uint8_t mifareclassic_WriteDataBlock(uint8_t blockNumber, uint8_t *data);
+ uint8_t mifareclassic_FormatNDEF(void);
+ uint8_t mifareclassic_WriteNDEFURI(uint8_t sectorNumber,
+ uint8_t uriIdentifier, const char *url);
+
+ // Mifare Ultralight functions
+ uint8_t mifareultralight_ReadPage(uint8_t page, uint8_t *buffer);
+ uint8_t mifareultralight_WritePage(uint8_t page, uint8_t *data);
+
+ // NTAG2xx functions
+ uint8_t ntag2xx_ReadPage(uint8_t page, uint8_t *buffer);
+ uint8_t ntag2xx_WritePage(uint8_t page, uint8_t *data);
+ uint8_t ntag2xx_WriteNDEFURI(uint8_t uriIdentifier, char *url,
+ uint8_t dataLen);
+
+ // Help functions to display formatted text
+ static void PrintHex(const byte *data, const uint32_t numBytes);
+ static void PrintHexChar(const byte *pbtData, const uint32_t numBytes);
+
+ private:
+ int8_t _irq = -1, _reset = -1, _cs = -1;
+ int8_t _uid[7]; // ISO14443A uid
+ int8_t _uidLen; // uid len
+ int8_t _key[6]; // Mifare Classic key
+ int8_t _inListedTag; // Tg number of inlisted tag.
+
+ // Low level communication functions that handle both SPI and I2C.
+ void readdata(uint8_t *buff, uint8_t n);
+ void writecommand(uint8_t *cmd, uint8_t cmdlen);
+ bool isready();
+ bool waitready(uint16_t timeout);
+ bool readack();
+
+ Adafruit_SPIDevice *spi_dev = NULL;
+ Adafruit_I2CDevice *i2c_dev = NULL;
+ HardwareSerial *ser_dev = NULL;
+};
+
+#endif
diff --git a/.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/README.md b/.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/README.md
new file mode 100644
index 0000000..012cd93
--- /dev/null
+++ b/.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/README.md
@@ -0,0 +1,53 @@
+# Adafruit-PN532 [![Build Status](https://github.com/adafruit/Adafruit-PN532/workflows/Arduino%20Library%20CI/badge.svg)](https://github.com/adafruit/Adafruit-PN532/actions)
+
+
+This is a library for the Adafruit PN532 NFC/RFID breakout boards
+This library works with the Adafruit NFC breakout
+
+ * https://www.adafruit.com/products/364
+
+Check out the links above for our tutorials and wiring diagrams
+These chips use I2C or SPI to communicate.
+
+# Dependencies
+* [Adafruit_BusIO](https://github.com/adafruit/Adafruit_BusIO)
+
+
+# Contributing
+
+Contributions are welcome! Please read our [Code of Conduct](https://github.com/adafruit/Adafruit-PN532/blob/master/CODE_OF_CONDUCT.md>)
+before contributing to help this project stay welcoming.
+
+## Documentation and doxygen
+Documentation is produced by doxygen. Contributions should include documentation for any new code added.
+
+Some examples of how to use doxygen can be found in these guide pages:
+
+https://learn.adafruit.com/the-well-automated-arduino-library/doxygen
+
+https://learn.adafruit.com/the-well-automated-arduino-library/doxygen-tips
+
+## Formatting and clang-format
+This library uses [`clang-format`](https://releases.llvm.org/download.html) to standardize the formatting of `.cpp` and `.h` files.
+Contributions should be formatted using `clang-format`:
+
+The `-i` flag will make the changes to the file.
+```bash
+clang-format -i *.cpp *.h
+```
+If you prefer to make the changes yourself, running `clang-format` without the `-i` flag will print out a formatted version of the file. You can save this to a file and diff it against the original to see the changes.
+
+Note that the formatting output by `clang-format` is what the automated formatting checker will expect. Any diffs from this formatting will result in a failed build until they are addressed. Using the `-i` flag is highly recommended.
+
+### clang-format resources
+ * [Binary builds and source available on the LLVM downloads page](https://releases.llvm.org/download.html)
+ * [Documentation and IDE integration](https://clang.llvm.org/docs/ClangFormat.html)
+Adafruit invests time and resources providing this open source code,
+please support Adafruit and open-source hardware by purchasing
+products from Adafruit!
+
+Written by Limor Fried/Ladyada & Kevin Townsend for Adafruit Industries.
+BSD license, check license.txt for more information
+All text above must be included in any redistribution
+
+To install, use the Arduino Library Manager and search for "Adafruit PN532" and install the library. Adafruit BusIO library is also required
diff --git a/.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/examples/apduToBlackBerry/.esp32.test.skip b/.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/examples/apduToBlackBerry/.esp32.test.skip
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/examples/apduToBlackBerry/.esp32.test.skip
diff --git a/.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/examples/apduToBlackBerry/BlackBerry7/.classpath b/.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/examples/apduToBlackBerry/BlackBerry7/.classpath
new file mode 100644
index 0000000..4426948
--- /dev/null
+++ b/.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/examples/apduToBlackBerry/BlackBerry7/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="src" path="res"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/net.rim.ejde.BlackBerryVMInstallType/BlackBerry JRE 7.0.0"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/examples/apduToBlackBerry/BlackBerry7/.project b/.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/examples/apduToBlackBerry/BlackBerry7/.project
new file mode 100644
index 0000000..1a8239a
--- /dev/null
+++ b/.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/examples/apduToBlackBerry/BlackBerry7/.project
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>TargetEmulation</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>net.rim.ejde.internal.builder.BlackBerryPreprocessBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>net.rim.ejde.internal.builder.BlackBerryResourcesBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>net.rim.ejde.BlackBerryPreProcessNature</nature>
+ <nature>net.rim.ejde.BlackBerryProjectCoreNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/examples/apduToBlackBerry/BlackBerry7/.settings/org.eclipse.jdt.core.prefs b/.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/examples/apduToBlackBerry/BlackBerry7/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..3f59a3e
--- /dev/null
+++ b/.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/examples/apduToBlackBerry/BlackBerry7/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,12 @@
+#Fri Jun 22 00:02:13 EDT 2012
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.4
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=ignore
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=ignore
+org.eclipse.jdt.core.compiler.source=1.3
diff --git a/.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/examples/apduToBlackBerry/BlackBerry7/BlackBerry_App_Descriptor.xml b/.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/examples/apduToBlackBerry/BlackBerry7/BlackBerry_App_Descriptor.xml
new file mode 100644
index 0000000..aa610d2
--- /dev/null
+++ b/.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/examples/apduToBlackBerry/BlackBerry7/BlackBerry_App_Descriptor.xml
@@ -0,0 +1,40 @@
+<!--
+
+ Copyright (c) 2013 Research In Motion Limited.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<!-- This file has been generated by the BlackBerry Plugin for Eclipse v3.6.0. -->
+
+<Properties ModelVersion="1.1.2">
+ <General Title="" Version="1.0.0" Vendor="BlackBerry Developer" Description=""/>
+ <Application Type="BlackBerry Application" MainMIDletName="" MainArgs="" HomeScreenPosition="0" StartupTier="7" IsSystemModule="false" IsAutostartup="false"/>
+ <Resources hasTitleResource="false" TitleResourceBundleName="" TitleResourceBundleRelativePath="" TitleResourceBundleClassName="" TitleResourceBundleKey="" DescriptionId="">
+ <Icons>
+ <Icon CanonicalFileName="res\img\icon.png" IsFocus="false"/>
+ </Icons>
+ </Resources>
+ <KeywordResources KeywordResourceBundleName="" KeywordResourceBundleRelativePath="" KeywordResourceBundleClassName="" KeywordResourceBundleKey=""/>
+ <Compile OutputCompilerMessages="false" ConvertImages="true" CreateWarningForNoExportedRoutine="true" CompressResources="false" AliasList="">
+ <PreprocessorDefines/>
+ </Compile>
+ <Packaging PreBuildStep="" PostBuildStep="" CleanStep="" OutputFileName="TargetEmulation" OutputFolder="deliverables" GenerateALXFile="true">
+ <AlxFiles/>
+ </Packaging>
+ <HiddenProperties>
+ <ClassProtection/>
+ <PackageProtection/>
+ </HiddenProperties>
+ <AlternateEntryPoints/>
+</Properties>
diff --git a/.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/examples/apduToBlackBerry/BlackBerry7/build.xml b/.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/examples/apduToBlackBerry/BlackBerry7/build.xml
new file mode 100644
index 0000000..72bf0c3
--- /dev/null
+++ b/.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/examples/apduToBlackBerry/BlackBerry7/build.xml
@@ -0,0 +1,35 @@
+<!--
+
+ Copyright (c) 2013 Research In Motion Limited.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<project default="all">
+ <property name="jde.path" value="c:/Program Files/Research In Motion/BlackBerry JDE 7.1.0" />
+ <target name="all" depends="sign,deploy">
+ </target>
+
+ <target name="sign">
+ <java failonerror="true" fork="true"
+ jar="c:/Program Files/Research In Motion/BlackBerry JDE 7.1.0/bin/SignatureTool.jar" args="-p s0ftc0ck -a -c deliverables/Standard/7.0.0/TargetEmulation.cod">
+ </java>
+ </target>
+ <target name="deploy">
+ <exec executable="${jde.path}/bin/JavaLoader.exe">
+ <arg value="-wpasscc" />
+ <arg value="load" />
+ <arg value="deliverables/Standard/7.0.0/TargetEmulation.cod" />
+ </exec>
+ </target>
+</project>
diff --git a/.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/examples/apduToBlackBerry/BlackBerry7/src/mypackage/ColorMixer.java b/.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/examples/apduToBlackBerry/BlackBerry7/src/mypackage/ColorMixer.java
new file mode 100644
index 0000000..d81f802
--- /dev/null
+++ b/.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/examples/apduToBlackBerry/BlackBerry7/src/mypackage/ColorMixer.java
@@ -0,0 +1,152 @@
+/**
+ Copyright (c) 2011, 2012, 2013 Research In Motion Limited.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+**/
+package mypackage;
+
+import net.rim.device.api.ui.Field;
+import net.rim.device.api.ui.Graphics;
+import net.rim.device.api.ui.TouchEvent;
+
+public class ColorMixer extends Field {
+ private static final int[] colors = new int[] { 0xff0000, 0xff00, 0xff };
+ private int barGap = 5;
+
+ private int barHeight = 64;
+ private int color;
+ private MyScreen owner;
+
+ private double r, g, b;
+
+ public ColorMixer(MyScreen owner) {
+ this.owner = owner;
+ }
+
+ protected void layout(int width, int height) {
+ setExtent(640, barHeight * 3 + barGap * 2);
+ }
+
+ protected void paint(Graphics graphics) {
+ int barWidth = getWidth() - barHeight * 3 - barGap * 3;
+ double[] values = new double[] { r, g, b };
+
+ // Draw color sliders
+ for (int i = 0; i < 3; ++i) {
+ int top = i * (barHeight + barGap);
+ int toDraw = (int) (values[i] * barWidth + 0.5);
+ graphics.setColor(0);
+ graphics.fillRect(toDraw, top, barWidth - toDraw, barHeight);
+
+ graphics.setColor(colors[i]);
+ graphics.fillRect(0, top, toDraw, barHeight);
+
+ graphics.setColor(0x7f7f7f);
+ graphics.drawRect(0, top, barWidth, barHeight);
+ }
+
+ // Draw mixed down color
+ int boxWidth = barHeight * 3 + barGap * 2;
+ graphics.setColor(color);
+ graphics.fillRect(getWidth() - 1 - boxWidth, 0, boxWidth, boxWidth);
+
+ graphics.setColor(0x7f7f7f);
+ graphics.drawRect(getWidth() - 1 - boxWidth, 0, boxWidth, boxWidth);
+ }
+
+ public void setColor(int color) {
+ if (color != this.color) {
+ this.color = color;
+ r = ((color >> 16) & 0xff) / 255.0;
+ g = ((color >> 8) & 0xff) / 255.0;
+ b = (color & 0xff) / 255.0;
+ invalidate();
+ }
+ }
+
+ private void setPart(int which, double value) {
+ double source = which == 0 ? r : which == 1 ? g : b;
+ if (value == source) {
+ return;
+ }
+ int bv = (int) (value * 255 + 0.5);
+ bv &= 0xff;
+ if (which == 0) {
+ r = value;
+ color &= 0xffff;
+ color |= bv << 16;
+ } else if (which == 1) {
+ g = value;
+ color &= 0xff00ff;
+ color |= bv << 8;
+ } else {
+ b = value;
+ color &= 0xffff00;
+ color |= bv;
+ }
+ owner.setColor(color);
+ invalidate();
+ }
+
+ private int touchTarget = -1;
+
+ protected boolean touchEvent(TouchEvent message) {
+ int event = message.getEvent();
+
+ int x = message.getX(1);
+ int y = message.getY(1);
+
+ int barWidth = getWidth() - barHeight * 3 - barGap * 3;
+
+ if (event == TouchEvent.UP) {
+ touchTarget = -1;
+ return false;
+ } else if (event == TouchEvent.DOWN) {
+ if (y < -5 || y > getWidth() + 5) {
+ return false;
+ }
+
+ if (x <= barWidth) {
+ for (int i = 0; i < 3; ++i) {
+ if (y < 0) {
+ break;
+ }
+ if (y < barHeight) {
+ touchTarget = i;
+ break;
+ }
+ y -= barHeight;
+ y -= barGap;
+ }
+ } else {
+ return false;
+ }
+ }
+
+ if (touchTarget == -1) {
+ return false;
+ }
+
+ double newValue = 1.0 * x / barWidth;
+ if (newValue < 0) {
+ newValue = 0;
+ }
+ if (newValue > 1) {
+ newValue = 1;
+ }
+
+ setPart(touchTarget, newValue);
+
+ return true;
+ }
+}
diff --git a/.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/examples/apduToBlackBerry/BlackBerry7/src/mypackage/MyApp.java b/.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/examples/apduToBlackBerry/BlackBerry7/src/mypackage/MyApp.java
new file mode 100644
index 0000000..4da1da5
--- /dev/null
+++ b/.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/examples/apduToBlackBerry/BlackBerry7/src/mypackage/MyApp.java
@@ -0,0 +1,47 @@
+/**
+ Copyright (c) 2011, 2012, 2013 Research In Motion Limited.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+**/
+package mypackage;
+
+import net.rim.device.api.ui.UiApplication;
+
+/**
+ * This class extends the UiApplication class, providing a
+ * graphical user interface.
+ */
+public class MyApp extends UiApplication
+{
+ /**
+ * Entry point for application
+ * @param args Command line arguments (not used)
+ */
+ public static void main(String[] args)
+ {
+ // Create a new instance of the application and make the currently
+ // running thread the application's event dispatch thread.
+ MyApp theApp = new MyApp();
+ theApp.enterEventDispatcher();
+ }
+
+
+ /**
+ * Creates a new MyApp object
+ */
+ public MyApp()
+ {
+ // Push a screen onto the UI stack for rendering.
+ pushScreen(new MyScreen());
+ }
+}
diff --git a/.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/examples/apduToBlackBerry/BlackBerry7/src/mypackage/MyScreen.java b/.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/examples/apduToBlackBerry/BlackBerry7/src/mypackage/MyScreen.java
new file mode 100644
index 0000000..0f80667
--- /dev/null
+++ b/.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/examples/apduToBlackBerry/BlackBerry7/src/mypackage/MyScreen.java
@@ -0,0 +1,163 @@
+/**
+ Copyright (c) 2011, 2012, 2013 Research In Motion Limited.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+**/
+package mypackage;
+
+import net.rim.device.api.io.nfc.NFCException;
+import net.rim.device.api.io.nfc.emulation.VirtualISO14443Part4TargetCallback;
+import net.rim.device.api.io.nfc.emulation.VirtualISO14443Part4TypeATarget;
+import net.rim.device.api.ui.Field;
+import net.rim.device.api.ui.FieldChangeListener;
+import net.rim.device.api.ui.component.CheckboxField;
+import net.rim.device.api.ui.component.LabelField;
+import net.rim.device.api.ui.container.MainScreen;
+import net.rim.device.api.ui.decor.BackgroundFactory;
+
+/**
+ * A class extending the MainScreen class, which provides default standard
+ * behavior for BlackBerry GUI applications.
+ */
+public final class MyScreen extends MainScreen implements
+ VirtualISO14443Part4TargetCallback, FieldChangeListener {
+
+ private int color = 0x7f7f7f;
+
+ private boolean colorQueued = false;
+ private CheckboxField colorQueueLocked;
+ private VirtualISO14443Part4TypeATarget emulated;
+ private ColorMixer mixer;
+
+ private LabelField status;
+
+ /**
+ * Creates a new MyScreen object
+ */
+ public MyScreen() {
+ // Set the displayed title of the screen
+ setTitle("Colour Control Setter");
+ setBackground(BackgroundFactory.createSolidBackground(0x3f3f3f));
+
+ add(new LabelField(""));
+ add(colorQueueLocked = new CheckboxField("Lock Color", false));
+ colorQueueLocked.setChangeListener(this);
+
+ add(mixer = new ColorMixer(this));
+ mixer.setColor(0x7f7f7f);
+
+ add(status = new LabelField(""));
+
+ try {
+ emulated = new VirtualISO14443Part4TypeATarget(this, "10451045",
+ null);
+ log("created");
+ emulated.startEmulation();
+ log("emulating");
+ } catch (NFCException e) {
+ log("Failed to listen");
+ status.setText(e.getClass().getName() + " " + e.getMessage());
+ e.printStackTrace();
+ }
+ }
+
+ // private TextField textField;
+
+ public void fieldChanged(Field field, int context) {
+ if (colorQueueLocked.getChecked()) {
+ setColor(color);
+ } else {
+ colorQueued = false;
+ status.setText("");
+ }
+ }
+
+ private boolean isColorQueueLocked() {
+ return colorQueueLocked.getChecked();
+ }
+
+ protected void log(String message) {
+ System.out.println("SUPERDUPER: " + message);
+ // textField.setText(textField.getText() + "\n" + message);
+ }
+
+ public void onVirtualTargetEvent(int targetEvent) {
+ log("Target event: " + targetEvent);
+ }
+
+ public byte[] processCommand(byte[] command) {
+ byte[] toReturn = processCommandInternal(command);
+ String message = "[" + toString(command) + "," + toString(toReturn)
+ + "]";
+ // status.setText(message);
+ // log(message);
+ return toReturn;
+ }
+
+ private byte[] processCommandInternal(byte[] command) {
+ if (command == null) {
+ return new byte[0];
+ }
+ int messageType = command[0] & 0xff;
+ switch (messageType) {
+ case 1:
+ if (command.length == 4) {
+ int colorIn = (command[1] & 0xff) << 16;
+ colorIn |= (command[2] & 0xff) << 8;
+ colorIn |= (command[3] & 0xff);
+
+ if (colorIn != color) {
+ if (colorQueued) {
+
+ byte[] toReturn = new byte[4];
+ toReturn[0] = 1;
+ toReturn[1] = (byte) (color >> 16);
+ toReturn[2] = (byte) (color >> 8);
+ toReturn[3] = (byte) color;
+
+ if (!isColorQueueLocked()) {
+ colorQueued = false;
+ status.setText("");
+ }
+
+ return toReturn;
+ } else {
+ this.color = colorIn;
+ mixer.setColor(colorIn);
+ }
+ }
+ }
+ break;
+ }
+ return new byte[] { 0 };
+ }
+
+ public void setColor(int color) {
+ colorQueued = true;
+ this.color = color;
+ status.setText("#" + toHex(color));
+ }
+
+ private String toHex(int i) {
+ String toReturn = "000000" + Integer.toString(i, 16);
+ return toReturn.substring(toReturn.length() - 6);
+ }
+
+ private String toString(byte[] command) {
+ String toReturn = "";
+ for (int i = 0; i < command.length; ++i) {
+ toReturn += Integer.toString(command[i] & 0xff, 16) + " ";
+ }
+ return toReturn;
+ }
+}
diff --git a/.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/examples/apduToBlackBerry/apduToBlackBerry.ino b/.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/examples/apduToBlackBerry/apduToBlackBerry.ino
new file mode 100644
index 0000000..0b5269a
--- /dev/null
+++ b/.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/examples/apduToBlackBerry/apduToBlackBerry.ino
@@ -0,0 +1,148 @@
+/**
+ Copyright (c) 2011, 2012, 2013 Research In Motion Limited.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+**/
+#include <Wire.h>
+#include <SPI.h>
+#include <Adafruit_PN532.h>
+
+// If using the breakout with SPI, define the pins for SPI communication.
+#define PN532_SCK (2)
+#define PN532_MOSI (3)
+#define PN532_SS (4)
+#define PN532_MISO (5)
+
+// If using the breakout or shield with I2C, define just the pins connected
+// to the IRQ and reset lines. Use the values below (2, 3) for the shield!
+#define PN532_IRQ (2)
+#define PN532_RESET (3) // Not connected by default on the NFC Shield
+
+// Uncomment just _one_ line below depending on how your breakout or shield
+// is connected to the Arduino:
+
+// Use this line for a breakout with a SPI connection:
+Adafruit_PN532 nfc(PN532_SCK, PN532_MISO, PN532_MOSI, PN532_SS);
+
+// Use this line for a breakout with a hardware SPI connection. Note that
+// the PN532 SCK, MOSI, and MISO pins need to be connected to the Arduino's
+// hardware SPI SCK, MOSI, and MISO pins. On an Arduino Uno these are
+// SCK = 13, MOSI = 11, MISO = 12. The SS line can be any digital IO pin.
+//Adafruit_PN532 nfc(PN532_SS);
+
+// Or use this line for a breakout or shield with an I2C connection:
+//Adafruit_PN532 nfc(PN532_IRQ, PN532_RESET);
+
+// PWM LED will be on the following PINs.
+#define R_PIN (9)
+#define G_PIN (10)
+#define B_PIN (11)
+
+// Initial values of RGB.
+uint8_t r = 0x00;
+uint8_t g = 0x00;
+uint8_t b = 0x7f;
+
+/**
+ * Write the current color to the output pins.
+ */
+void showColor() {
+ analogWrite(R_PIN,r);
+ analogWrite(G_PIN,g);
+ analogWrite(B_PIN,b);
+}
+
+
+void setup() {
+ Serial.begin(115200);
+ while (!Serial) delay(10); // for Leonardo/Micro/Zero
+
+ pinMode(R_PIN,OUTPUT);
+ pinMode(G_PIN,OUTPUT);
+ pinMode(B_PIN,OUTPUT);
+ showColor();
+
+ nfc.begin();
+
+ uint32_t versiondata = nfc.getFirmwareVersion();
+ if (! versiondata) {
+ Serial.println("Did not find the shield - locking up");
+ while (true) {
+ }
+ }
+
+ 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.begin();
+}
+
+uint8_t message[4];
+
+void loop(void) {
+ uint8_t i;
+
+ // Serial.println("Listening...");
+ if (nfc.inListPassiveTarget()) {
+ // Serial.println("Something's there...");
+ while(true) {
+ message[0] = 1;
+ message[1] = r;
+ message[2] = g;
+ message[3] = b;
+ uint8_t responseLength = sizeof(message);
+ if (nfc.inDataExchange(message,sizeof(message),message,&responseLength)) {
+ uint8_t command = message[0];
+ switch(command) {
+ case 0:
+ // NOP
+ break;
+ case 1:
+ if (responseLength==4) {
+ r = message[1];
+ g = message[2];
+ b = message[3];
+ showColor();
+ //Serial.print("Read a color: ");
+ //for (i=0; i<3; ++i) {
+ // Serial.print(message[i+1],HEX);
+ // Serial.print(' ');
+ //}
+ //Serial.println();
+ }
+ else {
+ //Serial.println("Doesn't seem to be a color...");
+ }
+ break;
+ default:
+ //Serial.print("Unknown command ");
+ //Serial.println(message[0]);
+ ;
+ }
+ delay(10);
+ }
+ else {
+ //Serial.println("It's gone...");
+ break;
+ }
+ }
+ }
+ else {
+ //Serial.print("Trying again...");
+ }
+}
+
diff --git a/.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/examples/iso14443a_uid/iso14443a_uid.ino b/.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/examples/iso14443a_uid/iso14443a_uid.ino
new file mode 100644
index 0000000..069e73e
--- /dev/null
+++ b/.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/examples/iso14443a_uid/iso14443a_uid.ino
@@ -0,0 +1,110 @@
+/**************************************************************************/
+/*!
+ @file iso14443a_uid.pde
+ @author Adafruit Industries
+ @license BSD (see license.txt)
+
+ This example will attempt to connect to an ISO14443A
+ card or tag and retrieve some basic information about it
+ that can be used to determine what type of card it is.
+
+ Note that you need the baud rate to be 115200 because we need to print
+ out the data and read from the card at the same time!
+
+This is an example sketch for the Adafruit PN532 NFC/RFID breakout boards
+This library works with the Adafruit NFC breakout
+ ----> https://www.adafruit.com/products/364
+
+Check out the links above for our tutorials and wiring diagrams
+These chips use SPI or I2C to communicate.
+
+Adafruit invests time and resources providing this open source code,
+please support Adafruit and open-source hardware by purchasing
+products from Adafruit!
+
+*/
+/**************************************************************************/
+#include <Wire.h>
+#include <SPI.h>
+#include <Adafruit_PN532.h>
+
+// If using the breakout with SPI, define the pins for SPI communication.
+#define PN532_SCK (2)
+#define PN532_MOSI (3)
+#define PN532_SS (4)
+#define PN532_MISO (5)
+
+// If using the breakout or shield with I2C, define just the pins connected
+// to the IRQ and reset lines. Use the values below (2, 3) for the shield!
+#define PN532_IRQ (2)
+#define PN532_RESET (3) // Not connected by default on the NFC Shield
+
+// Uncomment just _one_ line below depending on how your breakout or shield
+// is connected to the Arduino:
+
+// Use this line for a breakout with a SPI connection:
+Adafruit_PN532 nfc(PN532_SCK, PN532_MISO, PN532_MOSI, PN532_SS);
+
+// Use this line for a breakout with a hardware SPI connection. Note that
+// the PN532 SCK, MOSI, and MISO pins need to be connected to the Arduino's
+// hardware SPI SCK, MOSI, and MISO pins. On an Arduino Uno these are
+// SCK = 13, MOSI = 11, MISO = 12. The SS line can be any digital IO pin.
+//Adafruit_PN532 nfc(PN532_SS);
+
+// Or use this line for a breakout or shield with an I2C connection:
+//Adafruit_PN532 nfc(PN532_IRQ, PN532_RESET);
+
+void setup(void) {
+ Serial.begin(115200);
+ while (!Serial) delay(10); // for Leonardo/Micro/Zero
+ Serial.println("Hello!");
+
+ nfc.begin();
+
+ uint32_t versiondata = nfc.getFirmwareVersion();
+ if (! versiondata) {
+ Serial.print("Didn't find PN53x board");
+ while (1); // halt
+ }
+
+ // Got ok data, print it out!
+ 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);
+
+ // Set the max number of retry attempts to read from a card
+ // This prevents us from waiting forever for a card, which is
+ // the default behaviour of the PN532.
+ nfc.setPassiveActivationRetries(0xFF);
+
+ Serial.println("Waiting for an ISO14443A card");
+}
+
+void loop(void) {
+ boolean success;
+ uint8_t uid[] = { 0, 0, 0, 0, 0, 0, 0 }; // Buffer to store the returned UID
+ uint8_t uidLength; // Length of the UID (4 or 7 bytes depending on ISO14443A card type)
+
+ // Wait for an ISO14443A type cards (Mifare, etc.). When one is found
+ // 'uid' will be populated with the UID, and uidLength will indicate
+ // if the uid is 4 bytes (Mifare Classic) or 7 bytes (Mifare Ultralight)
+ success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, &uid[0], &uidLength);
+
+ if (success) {
+ Serial.println("Found a card!");
+ Serial.print("UID Length: ");Serial.print(uidLength, DEC);Serial.println(" bytes");
+ Serial.print("UID Value: ");
+ for (uint8_t i=0; i < uidLength; i++)
+ {
+ Serial.print(" 0x");Serial.print(uid[i], HEX);
+ }
+ Serial.println("");
+ // Wait 1 second before continuing
+ delay(1000);
+ }
+ else
+ {
+ // PN532 probably timed out waiting for a card
+ Serial.println("Timed out waiting for a card");
+ }
+}
diff --git a/.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/examples/iso14443as_target/iso14443as_target.ino b/.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/examples/iso14443as_target/iso14443as_target.ino
new file mode 100644
index 0000000..a3a7a2a
--- /dev/null
+++ b/.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/examples/iso14443as_target/iso14443as_target.ino
@@ -0,0 +1,106 @@
+/**************************************************************************/
+/*!
+ @file iso14443as_target.pde
+ @original Adafruit Industries
+ @modified Salvador Mendoza(@Netxing)
+ @license BSD (see license.txt)
+
+ This example will attempt to mimic an ISO14443A smart card
+ and retrieve some basic information from a PoS or terminal,
+ this can be used to establish a communication process.
+
+ Note that you need the baud rate to be 115200 because we need to print
+ out the data and read from the card at the same time!
+
+This is an example sketch for the Adafruit PN532 NFC/RFID breakout boards
+This library works with the Adafruit NFC breakout
+ ----> https://www.adafruit.com/products/364
+
+Check out the links above for our tutorials and wiring diagrams
+These chips use SPI or I2C to communicate.
+
+Adafruit invests time and resources providing this open source code,
+please support Adafruit and open-source hardware by purchasing
+products from Adafruit!
+
+*/
+/**************************************************************************/
+#include <Wire.h>
+#include <SPI.h>
+#include <Adafruit_PN532.h>
+
+// If using the breakout with SPI, define the pins for SPI communication.
+#define PN532_SCK (2)
+#define PN532_MOSI (3)
+#define PN532_SS (4)
+#define PN532_MISO (5)
+
+// If using the breakout or shield with I2C, define just the pins connected
+// to the IRQ and reset lines. Use the values below (2, 3) for the shield!
+#define PN532_IRQ (2)
+#define PN532_RESET (3) // Not connected by default on the NFC Shield
+
+// Uncomment just _one_ line below depending on how your breakout or shield
+// is connected to the Arduino:
+
+// Use this line for a breakout with a SPI connection:
+Adafruit_PN532 nfc(PN532_SCK, PN532_MISO, PN532_MOSI, PN532_SS);
+
+// Use this line for a breakout with a hardware SPI connection. Note that
+// the PN532 SCK, MOSI, and MISO pins need to be connected to the Arduino's
+// hardware SPI SCK, MOSI, and MISO pins. On an Arduino Uno these are
+// SCK = 13, MOSI = 11, MISO = 12. The SS line can be any digital IO pin.
+//Adafruit_PN532 nfc(PN532_SS);
+
+// Or use this line for a breakout or shield with an I2C connection:
+//Adafruit_PN532 nfc(PN532_IRQ, PN532_RESET);
+
+void setup(void) {
+ Serial.begin(115200);
+ while (!Serial) delay(10); // for Leonardo/Micro/Zero
+
+ Serial.println("Hello!");
+
+ nfc.begin();
+
+ uint32_t versiondata = nfc.getFirmwareVersion();
+ if (! versiondata) {
+ Serial.print("Didn't find PN53x board");
+ while (1); // halt
+ }
+
+ // Got ok data, print it out!
+ 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);
+
+ // Set the max number of retry attempts to read from a card
+ // This prevents us from waiting forever for a card, which is
+ // the default behaviour of the PN532.
+ nfc.setPassiveActivationRetries(0xFF);
+
+ Serial.println("As Target... Approach the NFC PN532 Board to a PoS or terminal!");
+ delay(200);
+}
+
+void loop(void) {
+ uint8_t apdubuffer[255] = {}, apdulen = 0;
+ uint8_t ppse[] = {0x8E, 0x6F, 0x23, 0x84, 0x0E, 0x32, 0x50, 0x41, 0x59, 0x2E, 0x53, 0x59, 0x53, 0x2E, 0x44, 0x44, 0x46, 0x30, 0x31, 0xA5, 0x11, 0xBF, 0x0C, 0x0E, 0x61, 0x0C, 0x4F, 0x07, 0xA0, 0x00, 0x00, 0x00, 0x03, 0x10, 0x10, 0x87, 0x01, 0x01, 0x90, 0x00};
+ nfc.AsTarget();
+ (void)nfc.getDataTarget(apdubuffer, &apdulen); //Read initial APDU
+ if (apdulen>0){
+ for (uint8_t i = 0; i < apdulen; i++){
+ Serial.print(" 0x"); Serial.print(apdubuffer[i], HEX);
+ }
+ Serial.println("");
+ }
+ nfc.setDataTarget(ppse, sizeof(ppse)); //Mimic a smart card response with a PPSE APDU
+ nfc.getDataTarget(apdubuffer, &apdulen); //Read respond from the PoS or Terminal
+ if (apdulen>0){
+ for (uint8_t i = 0; i < apdulen; i++){
+ Serial.print(" 0x"); Serial.print(apdubuffer[i], HEX);
+ }
+ Serial.println("");
+ }
+ delay(1000);
+}
diff --git a/.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/examples/mifareclassic_formatndef/mifareclassic_formatndef.ino b/.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/examples/mifareclassic_formatndef/mifareclassic_formatndef.ino
new file mode 100644
index 0000000..feeb083
--- /dev/null
+++ b/.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/examples/mifareclassic_formatndef/mifareclassic_formatndef.ino
@@ -0,0 +1,201 @@
+/**************************************************************************/
+/*!
+ @file mifareclassic_formatndef.pde
+ @author Adafruit Industries
+ @license BSD (see license.txt)
+
+ This example attempts to format a clean Mifare Classic 1K card as
+ an NFC Forum tag (to store NDEF messages that can be read by any
+ NFC enabled Android phone, etc.)
+
+ Note that you need the baud rate to be 115200 because we need to print
+ out the data and read from the card at the same time!
+
+ This is an example sketch for the Adafruit PN532 NFC/RFID breakout boards
+ This library works with the Adafruit NFC Shield
+ ----> https://www.adafruit.com/products/789
+
+ Check out the links above for our tutorials and wiring diagrams
+ These chips use SPI or I2C to communicate
+
+ Adafruit invests time and resources providing this open source code,
+ please support Adafruit and open-source hardware by purchasing
+ products from Adafruit!
+
+*/
+/**************************************************************************/
+
+#include <Wire.h>
+#include <SPI.h>
+#include <Adafruit_PN532.h>
+
+// If using the breakout with SPI, define the pins for SPI communication.
+#define PN532_SCK (2)
+#define PN532_MOSI (3)
+#define PN532_SS (4)
+#define PN532_MISO (5)
+
+// If using the breakout or shield with I2C, define just the pins connected
+// to the IRQ and reset lines. Use the values below (2, 3) for the shield!
+#define PN532_IRQ (2)
+#define PN532_RESET (3) // Not connected by default on the NFC Shield
+
+// Uncomment just _one_ line below depending on how your breakout or shield
+// is connected to the Arduino:
+
+// Use this line for a breakout with a SPI connection:
+Adafruit_PN532 nfc(PN532_SCK, PN532_MISO, PN532_MOSI, PN532_SS);
+
+// Use this line for a breakout with a hardware SPI connection. Note that
+// the PN532 SCK, MOSI, and MISO pins need to be connected to the Arduino's
+// hardware SPI SCK, MOSI, and MISO pins. On an Arduino Uno these are
+// SCK = 13, MOSI = 11, MISO = 12. The SS line can be any digital IO pin.
+//Adafruit_PN532 nfc(PN532_SS);
+
+// Or use this line for a breakout or shield with an I2C connection:
+//Adafruit_PN532 nfc(PN532_IRQ, PN532_RESET);
+
+/*
+ We can encode many different kinds of pointers to the card,
+ from a URL, to an Email address, to a phone number, and many more
+ check the library header .h file to see the large # of supported
+ prefixes!
+*/
+// For a http://www. url:
+const char * url = "adafruit.com";
+uint8_t ndefprefix = NDEF_URIPREFIX_HTTP_WWWDOT;
+
+// for an email address
+//const char * url = "mail@example.com";
+//uint8_t ndefprefix = NDEF_URIPREFIX_MAILTO;
+
+// for a phone number
+//const char * url = "+1 212 555 1212";
+//uint8_t ndefprefix = NDEF_URIPREFIX_TEL;
+
+
+void setup(void) {
+ Serial.begin(115200);
+ while (!Serial) delay(10); // for Leonardo/Micro/Zero
+
+ Serial.println("Looking for PN532...");
+
+ nfc.begin();
+
+ uint32_t versiondata = nfc.getFirmwareVersion();
+ if (! versiondata) {
+ Serial.print("Didn't find PN53x board");
+ while (1); // halt
+ }
+
+ // Got ok data, print it out!
+ 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);
+}
+
+void loop(void) {
+ uint8_t success; // Flag to check if there was an error with the PN532
+ uint8_t uid[] = { 0, 0, 0, 0, 0, 0, 0 }; // Buffer to store the returned UID
+ uint8_t uidLength; // Length of the UID (4 or 7 bytes depending on ISO14443A card type)
+
+ // Use the default key
+ uint8_t keya[6] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
+
+ Serial.println("");
+ Serial.println("PLEASE NOTE: Formatting your card for NDEF records will change the");
+ Serial.println("authentication keys. To reformat your NDEF tag as a clean Mifare");
+ Serial.println("Classic tag, use the mifareclassic_ndeftoclassic example!");
+ Serial.println("");
+ Serial.println("Place your Mifare Classic card on the reader to format with NDEF");
+ Serial.println("and press any key to continue ...");
+ // Wait for user input before proceeding
+ while (!Serial.available());
+ // a key was pressed1
+ while (Serial.available()) Serial.read();
+
+ // Wait for an ISO14443A type card (Mifare, etc.). When one is found
+ // 'uid' will be populated with the UID, and uidLength will indicate
+ // if the uid is 4 bytes (Mifare Classic) or 7 bytes (Mifare Ultralight)
+ success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, uid, &uidLength);
+
+ if (success)
+ {
+ // Display some basic information about the card
+ Serial.println("Found an ISO14443A card");
+ Serial.print(" UID Length: ");Serial.print(uidLength, DEC);Serial.println(" bytes");
+ Serial.print(" UID Value: ");
+ nfc.PrintHex(uid, uidLength);
+ Serial.println("");
+
+ // Make sure this is a Mifare Classic card
+ if (uidLength != 4)
+ {
+ Serial.println("Ooops ... this doesn't seem to be a Mifare Classic card!");
+ return;
+ }
+
+ // We probably have a Mifare Classic card ...
+ Serial.println("Seems to be a Mifare Classic card (4 byte UID)");
+
+ // Try to format the card for NDEF data
+ success = nfc.mifareclassic_AuthenticateBlock (uid, uidLength, 0, 0, keya);
+ if (!success)
+ {
+ Serial.println("Unable to authenticate block 0 to enable card formatting!");
+ return;
+ }
+ success = nfc.mifareclassic_FormatNDEF();
+ if (!success)
+ {
+ Serial.println("Unable to format the card for NDEF");
+ return;
+ }
+
+ Serial.println("Card has been formatted for NDEF data using MAD1");
+
+ // Try to authenticate block 4 (first block of sector 1) using our key
+ success = nfc.mifareclassic_AuthenticateBlock (uid, uidLength, 4, 0, keya);
+
+ // Make sure the authentification process didn't fail
+ if (!success)
+ {
+ Serial.println("Authentication failed.");
+ return;
+ }
+
+ // Try to write a URL
+ Serial.println("Writing URI to sector 1 as an NDEF Message");
+
+ // Authenticated seems to have worked
+ // Try to write an NDEF record to sector 1
+ // Use 0x01 for the URI Identifier Code to prepend "http://www."
+ // to the url (and save some space). For information on URI ID Codes
+ // see http://www.ladyada.net/wiki/private/articlestaging/nfc/ndef
+ if (strlen(url) > 38)
+ {
+ // The length is also checked in the WriteNDEFURI function, but lets
+ // warn users here just in case they change the value and it's bigger
+ // than it should be
+ Serial.println("URI is too long ... must be less than 38 characters long");
+ return;
+ }
+
+ // URI is within size limits ... write it to the card and report success/failure
+ success = nfc.mifareclassic_WriteNDEFURI(1, ndefprefix, url);
+ if (success)
+ {
+ Serial.println("NDEF URI Record written to sector 1");
+ }
+ else
+ {
+ Serial.println("NDEF Record creation failed! :(");
+ }
+ }
+
+ // Wait a bit before trying again
+ Serial.println("\n\nDone!");
+ delay(1000);
+ Serial.flush();
+ while(Serial.available()) Serial.read();
+}
diff --git a/.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/examples/mifareclassic_memdump/mifareclassic_memdump.ino b/.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/examples/mifareclassic_memdump/mifareclassic_memdump.ino
new file mode 100644
index 0000000..5a50222
--- /dev/null
+++ b/.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/examples/mifareclassic_memdump/mifareclassic_memdump.ino
@@ -0,0 +1,190 @@
+/**************************************************************************/
+/*!
+ @file mifareclassic_memdump.pde
+ @author Adafruit Industries
+ @license BSD (see license.txt)
+
+ This example attempts to dump the contents of a Mifare Classic 1K card
+
+ Note that you need the baud rate to be 115200 because we need to print
+ out the data and read from the card at the same time!
+
+ This is an example sketch for the Adafruit PN532 NFC/RFID breakout boards
+ This library works with the Adafruit NFC breakout
+ ----> https://www.adafruit.com/products/364
+
+ Check out the links above for our tutorials and wiring diagrams
+ These chips use SPI or I2C to communicate
+
+ Adafruit invests time and resources providing this open source code,
+ please support Adafruit and open-source hardware by purchasing
+ products from Adafruit!
+
+*/
+/**************************************************************************/
+
+#include <Wire.h>
+#include <SPI.h>
+#include <Adafruit_PN532.h>
+
+// If using the breakout with SPI, define the pins for SPI communication.
+#define PN532_SCK (2)
+#define PN532_MOSI (3)
+#define PN532_SS (4)
+#define PN532_MISO (5)
+
+// If using the breakout or shield with I2C, define just the pins connected
+// to the IRQ and reset lines. Use the values below (2, 3) for the shield!
+#define PN532_IRQ (2)
+#define PN532_RESET (3) // Not connected by default on the NFC Shield
+
+// Uncomment just _one_ line below depending on how your breakout or shield
+// is connected to the Arduino:
+
+// Use this line for a breakout with a SPI connection:
+Adafruit_PN532 nfc(PN532_SCK, PN532_MISO, PN532_MOSI, PN532_SS);
+
+// Use this line for a breakout with a hardware SPI connection. Note that
+// the PN532 SCK, MOSI, and MISO pins need to be connected to the Arduino's
+// hardware SPI SCK, MOSI, and MISO pins. On an Arduino Uno these are
+// SCK = 13, MOSI = 11, MISO = 12. The SS line can be any digital IO pin.
+//Adafruit_PN532 nfc(PN532_SS);
+
+// Or use this line for a breakout or shield with an I2C connection:
+//Adafruit_PN532 nfc(PN532_IRQ, PN532_RESET);
+
+void setup(void) {
+ // has to be fast to dump the entire memory contents!
+ Serial.begin(115200);
+ while (!Serial) delay(10); // for Leonardo/Micro/Zero
+
+ Serial.println("Looking for PN532...");
+
+ nfc.begin();
+
+ uint32_t versiondata = nfc.getFirmwareVersion();
+ if (! versiondata) {
+ Serial.print("Didn't find PN53x board");
+ while (1); // halt
+ }
+ // Got ok data, print it out!
+ 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);
+
+ Serial.println("Waiting for an ISO14443A Card ...");
+}
+
+
+void loop(void) {
+ uint8_t success; // Flag to check if there was an error with the PN532
+ uint8_t uid[] = { 0, 0, 0, 0, 0, 0, 0 }; // Buffer to store the returned UID
+ uint8_t uidLength; // Length of the UID (4 or 7 bytes depending on ISO14443A card type)
+ uint8_t currentblock; // Counter to keep track of which block we're on
+ bool authenticated = false; // Flag to indicate if the sector is authenticated
+ uint8_t data[16]; // Array to store block data during reads
+
+ // Keyb on NDEF and Mifare Classic should be the same
+ uint8_t keyuniversal[6] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
+
+ // Wait for an ISO14443A type cards (Mifare, etc.). When one is found
+ // 'uid' will be populated with the UID, and uidLength will indicate
+ // if the uid is 4 bytes (Mifare Classic) or 7 bytes (Mifare Ultralight)
+ success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, uid, &uidLength);
+
+ if (success) {
+ // Display some basic information about the card
+ Serial.println("Found an ISO14443A card");
+ Serial.print(" UID Length: ");Serial.print(uidLength, DEC);Serial.println(" bytes");
+ Serial.print(" UID Value: ");
+ nfc.PrintHex(uid, uidLength);
+ Serial.println("");
+
+ if (uidLength == 4)
+ {
+ // We probably have a Mifare Classic card ...
+ Serial.println("Seems to be a Mifare Classic card (4 byte UID)");
+
+ // Now we try to go through all 16 sectors (each having 4 blocks)
+ // authenticating each sector, and then dumping the blocks
+ for (currentblock = 0; currentblock < 64; currentblock++)
+ {
+ // Check if this is a new block so that we can reauthenticate
+ if (nfc.mifareclassic_IsFirstBlock(currentblock)) authenticated = false;
+
+ // If the sector hasn't been authenticated, do so first
+ if (!authenticated)
+ {
+ // Starting of a new sector ... try to to authenticate
+ Serial.print("------------------------Sector ");Serial.print(currentblock/4, DEC);Serial.println("-------------------------");
+ if (currentblock == 0)
+ {
+ // This will be 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF for Mifare Classic (non-NDEF!)
+ // or 0xA0 0xA1 0xA2 0xA3 0xA4 0xA5 for NDEF formatted cards using key a,
+ // but keyb should be the same for both (0xFF 0xFF 0xFF 0xFF 0xFF 0xFF)
+ success = nfc.mifareclassic_AuthenticateBlock (uid, uidLength, currentblock, 1, keyuniversal);
+ }
+ else
+ {
+ // This will be 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF for Mifare Classic (non-NDEF!)
+ // or 0xD3 0xF7 0xD3 0xF7 0xD3 0xF7 for NDEF formatted cards using key a,
+ // but keyb should be the same for both (0xFF 0xFF 0xFF 0xFF 0xFF 0xFF)
+ success = nfc.mifareclassic_AuthenticateBlock (uid, uidLength, currentblock, 1, keyuniversal);
+ }
+ if (success)
+ {
+ authenticated = true;
+ }
+ else
+ {
+ Serial.println("Authentication error");
+ }
+ }
+ // If we're still not authenticated just skip the block
+ if (!authenticated)
+ {
+ Serial.print("Block ");Serial.print(currentblock, DEC);Serial.println(" unable to authenticate");
+ }
+ else
+ {
+ // Authenticated ... we should be able to read the block now
+ // Dump the data into the 'data' array
+ success = nfc.mifareclassic_ReadDataBlock(currentblock, data);
+ if (success)
+ {
+ // Read successful
+ Serial.print("Block ");Serial.print(currentblock, DEC);
+ if (currentblock < 10)
+ {
+ Serial.print(" ");
+ }
+ else
+ {
+ Serial.print(" ");
+ }
+ // Dump the raw data
+ nfc.PrintHexChar(data, 16);
+ }
+ else
+ {
+ // Oops ... something happened
+ Serial.print("Block ");Serial.print(currentblock, DEC);
+ Serial.println(" unable to read this block");
+ }
+ }
+ }
+ }
+ else
+ {
+ Serial.println("Ooops ... this doesn't seem to be a Mifare Classic card!");
+ }
+ }
+ // Wait a bit before trying again
+ Serial.println("\n\nSend a character to run the mem dumper again!");
+ Serial.flush();
+ while (!Serial.available());
+ while (Serial.available()) {
+ Serial.read();
+ }
+ Serial.flush();
+}
diff --git a/.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/examples/mifareclassic_ndeftoclassic/mifareclassic_ndeftoclassic.ino b/.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/examples/mifareclassic_ndeftoclassic/mifareclassic_ndeftoclassic.ino
new file mode 100644
index 0000000..1c9a06a
--- /dev/null
+++ b/.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/examples/mifareclassic_ndeftoclassic/mifareclassic_ndeftoclassic.ino
@@ -0,0 +1,207 @@
+/**************************************************************************/
+/*!
+ @file mifareclassic_ndeftoclassic.pde
+ @author KTOWN (Adafruit Industries)
+ @license BSD (see license.txt)
+
+ This examples attempts to take a Mifare Classic 1K card that has been
+ formatted for NDEF messages using mifareclassic_formatndef, and resets
+ the authentication keys back to the Mifare Classic defaults
+
+ This is an example sketch for the Adafruit PN532 NFC/RFID breakout boards
+ This library works with the Adafruit NFC Shield
+ ----> https://www.adafruit.com/products/789
+
+ Check out the links above for our tutorials and wiring diagrams
+ These chips use SPI or I2C to communicate
+
+ Adafruit invests time and resources providing this open source code,
+ please support Adafruit and open-source hardware by purchasing
+ products from Adafruit!
+
+*/
+/**************************************************************************/
+
+#include <Wire.h>
+#include <SPI.h>
+#include <Adafruit_PN532.h>
+
+// If using the breakout with SPI, define the pins for SPI communication.
+#define PN532_SCK (2)
+#define PN532_MOSI (3)
+#define PN532_SS (4)
+#define PN532_MISO (5)
+
+// If using the breakout or shield with I2C, define just the pins connected
+// to the IRQ and reset lines. Use the values below (2, 3) for the shield!
+#define PN532_IRQ (2)
+#define PN532_RESET (3) // Not connected by default on the NFC Shield
+
+// Uncomment just _one_ line below depending on how your breakout or shield
+// is connected to the Arduino:
+
+// Use this line for a breakout with a SPI connection:
+Adafruit_PN532 nfc(PN532_SCK, PN532_MISO, PN532_MOSI, PN532_SS);
+
+// Use this line for a breakout with a hardware SPI connection. Note that
+// the PN532 SCK, MOSI, and MISO pins need to be connected to the Arduino's
+// hardware SPI SCK, MOSI, and MISO pins. On an Arduino Uno these are
+// SCK = 13, MOSI = 11, MISO = 12. The SS line can be any digital IO pin.
+//Adafruit_PN532 nfc(PN532_SS);
+
+// Or use this line for a breakout or shield with an I2C connection:
+//Adafruit_PN532 nfc(PN532_IRQ, PN532_RESET);
+
+#define NR_SHORTSECTOR (32) // Number of short sectors on Mifare 1K/4K
+#define NR_LONGSECTOR (8) // Number of long sectors on Mifare 4K
+#define NR_BLOCK_OF_SHORTSECTOR (4) // Number of blocks in a short sector
+#define NR_BLOCK_OF_LONGSECTOR (16) // Number of blocks in a long sector
+
+// Determine the sector trailer block based on sector number
+#define BLOCK_NUMBER_OF_SECTOR_TRAILER(sector) (((sector)<NR_SHORTSECTOR)? \
+ ((sector)*NR_BLOCK_OF_SHORTSECTOR + NR_BLOCK_OF_SHORTSECTOR-1):\
+ (NR_SHORTSECTOR*NR_BLOCK_OF_SHORTSECTOR + (sector-NR_SHORTSECTOR)*NR_BLOCK_OF_LONGSECTOR + NR_BLOCK_OF_LONGSECTOR-1))
+
+// Determine the sector's first block based on the sector number
+#define BLOCK_NUMBER_OF_SECTOR_1ST_BLOCK(sector) (((sector)<NR_SHORTSECTOR)? \
+ ((sector)*NR_BLOCK_OF_SHORTSECTOR):\
+ (NR_SHORTSECTOR*NR_BLOCK_OF_SHORTSECTOR + (sector-NR_SHORTSECTOR)*NR_BLOCK_OF_LONGSECTOR))
+
+// The default Mifare Classic key
+static const uint8_t KEY_DEFAULT_KEYAB[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
+
+
+void setup(void) {
+ Serial.begin(115200);
+ while (!Serial) delay(10); // for Leonardo/Micro/Zero
+
+ Serial.println("Looking for PN532...");
+
+ nfc.begin();
+
+ uint32_t versiondata = nfc.getFirmwareVersion();
+ if (! versiondata) {
+ Serial.print("Didn't find PN53x board");
+ while (1); // halt
+ }
+
+ // Got ok data, print it out!
+ 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);
+}
+
+void loop(void) {
+ uint8_t success; // Flag to check if there was an error with the PN532
+ uint8_t uid[] = { 0, 0, 0, 0, 0, 0, 0 }; // Buffer to store the returned UID
+ uint8_t uidLength; // Length of the UID (4 or 7 bytes depending on ISO14443A card type)
+ uint8_t blockBuffer[16]; // Buffer to store block contents
+ uint8_t blankAccessBits[3] = { 0xff, 0x07, 0x80 };
+ uint8_t idx = 0;
+ uint8_t numOfSector = 16; // Assume Mifare Classic 1K for now (16 4-block sectors)
+
+ Serial.println("Place your NDEF formatted Mifare Classic 1K card on the reader");
+ Serial.println("and press any key to continue ...");
+
+ // Wait for user input before proceeding
+ while (!Serial.available());
+ while (Serial.available()) Serial.read();
+
+ // Wait for an ISO14443A type card (Mifare, etc.). When one is found
+ // 'uid' will be populated with the UID, and uidLength will indicate
+ // if the uid is 4 bytes (Mifare Classic) or 7 bytes (Mifare Ultralight)
+ success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, uid, &uidLength);
+
+ if (success)
+ {
+ // We seem to have a tag ...
+ // Display some basic information about it
+ Serial.println("Found an ISO14443A card/tag");
+ Serial.print(" UID Length: ");Serial.print(uidLength, DEC);Serial.println(" bytes");
+ Serial.print(" UID Value: ");
+ nfc.PrintHex(uid, uidLength);
+ Serial.println("");
+
+ // Make sure this is a Mifare Classic card
+ if (uidLength != 4)
+ {
+ Serial.println("Ooops ... this doesn't seem to be a Mifare Classic card!");
+ return;
+ }
+
+ Serial.println("Seems to be a Mifare Classic card (4 byte UID)");
+ Serial.println("");
+ Serial.println("Reformatting card for Mifare Classic (please don't touch it!) ... ");
+
+ // Now run through the card sector by sector
+ for (idx = 0; idx < numOfSector; idx++)
+ {
+ // Step 1: Authenticate the current sector using key B 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF
+ success = nfc.mifareclassic_AuthenticateBlock (uid, uidLength, BLOCK_NUMBER_OF_SECTOR_TRAILER(idx), 1, (uint8_t *)KEY_DEFAULT_KEYAB);
+ if (!success)
+ {
+ Serial.print("Authentication failed for sector "); Serial.println(numOfSector);
+ return;
+ }
+
+ // Step 2: Write to the other blocks
+ if (idx == 16)
+ {
+ memset(blockBuffer, 0, sizeof(blockBuffer));
+ if (!(nfc.mifareclassic_WriteDataBlock((BLOCK_NUMBER_OF_SECTOR_TRAILER(idx)) - 3, blockBuffer)))
+ {
+ Serial.print("Unable to write to sector "); Serial.println(numOfSector);
+ return;
+ }
+ }
+ if ((idx == 0) || (idx == 16))
+ {
+ memset(blockBuffer, 0, sizeof(blockBuffer));
+ if (!(nfc.mifareclassic_WriteDataBlock((BLOCK_NUMBER_OF_SECTOR_TRAILER(idx)) - 2, blockBuffer)))
+ {
+ Serial.print("Unable to write to sector "); Serial.println(numOfSector);
+ return;
+ }
+ }
+ else
+ {
+ memset(blockBuffer, 0, sizeof(blockBuffer));
+ if (!(nfc.mifareclassic_WriteDataBlock((BLOCK_NUMBER_OF_SECTOR_TRAILER(idx)) - 3, blockBuffer)))
+ {
+ Serial.print("Unable to write to sector "); Serial.println(numOfSector);
+ return;
+ }
+ if (!(nfc.mifareclassic_WriteDataBlock((BLOCK_NUMBER_OF_SECTOR_TRAILER(idx)) - 2, blockBuffer)))
+ {
+ Serial.print("Unable to write to sector "); Serial.println(numOfSector);
+ return;
+ }
+ }
+ memset(blockBuffer, 0, sizeof(blockBuffer));
+ if (!(nfc.mifareclassic_WriteDataBlock((BLOCK_NUMBER_OF_SECTOR_TRAILER(idx)) - 1, blockBuffer)))
+ {
+ Serial.print("Unable to write to sector "); Serial.println(numOfSector);
+ return;
+ }
+
+ // Step 3: Reset both keys to 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF
+ memcpy(blockBuffer, KEY_DEFAULT_KEYAB, sizeof(KEY_DEFAULT_KEYAB));
+ memcpy(blockBuffer + 6, blankAccessBits, sizeof(blankAccessBits));
+ blockBuffer[9] = 0x69;
+ memcpy(blockBuffer + 10, KEY_DEFAULT_KEYAB, sizeof(KEY_DEFAULT_KEYAB));
+
+ // Step 4: Write the trailer block
+ if (!(nfc.mifareclassic_WriteDataBlock((BLOCK_NUMBER_OF_SECTOR_TRAILER(idx)), blockBuffer)))
+ {
+ Serial.print("Unable to write trailer block of sector "); Serial.println(numOfSector);
+ return;
+ }
+ }
+ }
+
+ // Wait a bit before trying again
+ Serial.println("\n\nDone!");
+ delay(1000);
+ Serial.flush();
+ while(Serial.available()) Serial.read();
+}
diff --git a/.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/examples/mifareclassic_updatendef/mifareclassic_updatendef.ino b/.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/examples/mifareclassic_updatendef/mifareclassic_updatendef.ino
new file mode 100644
index 0000000..0bdf126
--- /dev/null
+++ b/.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/examples/mifareclassic_updatendef/mifareclassic_updatendef.ino
@@ -0,0 +1,177 @@
+/**************************************************************************/
+/*!
+ @file mifareclassic_updatendef.pde
+ @author Adafruit Industries
+ @license BSD (see license.txt)
+
+ Updates a sector that is already formatted for NDEF (using
+ mifareclassic_formatndef.pde for example), inserting a new url
+
+ This is an example sketch for the Adafruit PN532 NFC/RFID breakout boards
+ This library works with the Adafruit NFC Shield
+ ----> https://www.adafruit.com/products/789
+
+ Check out the links above for our tutorials and wiring diagrams
+ These chips use SPI or I2C to communicate
+
+ Adafruit invests time and resources providing this open source code,
+ please support Adafruit and open-source hardware by purchasing
+ products from Adafruit!
+
+*/
+/**************************************************************************/
+
+#include <Wire.h>
+#include <SPI.h>
+#include <Adafruit_PN532.h>
+
+// If using the breakout with SPI, define the pins for SPI communication.
+#define PN532_SCK (2)
+#define PN532_MOSI (3)
+#define PN532_SS (4)
+#define PN532_MISO (5)
+
+// If using the breakout or shield with I2C, define just the pins connected
+// to the IRQ and reset lines. Use the values below (2, 3) for the shield!
+#define PN532_IRQ (2)
+#define PN532_RESET (3) // Not connected by default on the NFC Shield
+
+// Uncomment just _one_ line below depending on how your breakout or shield
+// is connected to the Arduino:
+
+// Use this line for a breakout with a SPI connection:
+Adafruit_PN532 nfc(PN532_SCK, PN532_MISO, PN532_MOSI, PN532_SS);
+
+// Use this line for a breakout with a hardware SPI connection. Note that
+// the PN532 SCK, MOSI, and MISO pins need to be connected to the Arduino's
+// hardware SPI SCK, MOSI, and MISO pins. On an Arduino Uno these are
+// SCK = 13, MOSI = 11, MISO = 12. The SS line can be any digital IO pin.
+//Adafruit_PN532 nfc(PN532_SS);
+
+// Or use this line for a breakout or shield with an I2C connection:
+//Adafruit_PN532 nfc(PN532_IRQ, PN532_RESET);
+
+/*
+ We can encode many different kinds of pointers to the card,
+ from a URL, to an Email address, to a phone number, and many more
+ check the library header .h file to see the large # of supported
+ prefixes!
+*/
+// For a http://www. url:
+const char * url = "adafruit.com/blog/";
+uint8_t ndefprefix = NDEF_URIPREFIX_HTTP_WWWDOT;
+
+// for an email address
+//const char * url = "mail@example.com";
+//uint8_t ndefprefix = NDEF_URIPREFIX_MAILTO;
+
+// for a phone number
+//const char * url = "+1 212 555 1212";
+//uint8_t ndefprefix = NDEF_URIPREFIX_TEL;
+
+
+void setup(void) {
+ Serial.begin(115200);
+ while (!Serial) delay(10); // for Leonardo/Micro/Zero
+
+ Serial.println("Looking for PN532...");
+
+ nfc.begin();
+
+ uint32_t versiondata = nfc.getFirmwareVersion();
+ if (! versiondata) {
+ Serial.print("Didn't find PN53x board");
+ while (1); // halt
+ }
+
+ // Got ok data, print it out!
+ 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);
+}
+
+void loop(void) {
+ uint8_t success; // Flag to check if there was an error with the PN532
+ uint8_t uid[] = { 0, 0, 0, 0, 0, 0, 0 }; // Buffer to store the returned UID
+ uint8_t uidLength; // Length of the UID (4 or 7 bytes depending on ISO14443A card type)
+
+ // Use the default NDEF keys (these would have have set by mifareclassic_formatndef.pde!)
+ uint8_t keyb[6] = { 0xD3, 0xF7, 0xD3, 0xF7, 0xD3, 0xF7 };
+
+ Serial.println("Place your NDEF formatted Mifare Classic card on the reader to update the");
+ Serial.println("NDEF record and press any key to continue ...");
+ // Wait for user input before proceeding
+ while (!Serial.available());
+ // a key was pressed1
+ while (Serial.available()) Serial.read();
+
+ // Wait for an ISO14443A type card (Mifare, etc.). When one is found
+ // 'uid' will be populated with the UID, and uidLength will indicate
+ // if the uid is 4 bytes (Mifare Classic) or 7 bytes (Mifare Ultralight)
+ success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, uid, &uidLength);
+
+ if (success)
+ {
+ // Display some basic information about the card
+ Serial.println("Found an ISO14443A card");
+ Serial.print(" UID Length: ");Serial.print(uidLength, DEC);Serial.println(" bytes");
+ Serial.print(" UID Value: ");
+ nfc.PrintHex(uid, uidLength);
+ Serial.println("");
+
+ // Make sure this is a Mifare Classic card
+ if (uidLength != 4)
+ {
+ Serial.println("Ooops ... this doesn't seem to be a Mifare Classic card!");
+ return;
+ }
+
+ // We probably have a Mifare Classic card ...
+ Serial.println("Seems to be a Mifare Classic card (4 byte UID)");
+
+ // Check if this is an NDEF card (using first block of sector 1 from mifareclassic_formatndef.pde)
+ // Must authenticate on the first key using 0xD3 0xF7 0xD3 0xF7 0xD3 0xF7
+ success = nfc.mifareclassic_AuthenticateBlock (uid, uidLength, 4, 0, keyb);
+ if (!success)
+ {
+ Serial.println("Unable to authenticate block 4 ... is this card NDEF formatted?");
+ return;
+ }
+
+ Serial.println("Authentication succeeded (seems to be an NDEF/NFC Forum tag) ...");
+
+ // Authenticated seems to have worked
+ // Try to write an NDEF record to sector 1
+ // Use 0x01 for the URI Identifier Code to prepend "http://www."
+ // to the url (and save some space). For information on URI ID Codes
+ // see http://www.ladyada.net/wiki/private/articlestaging/nfc/ndef
+ if (strlen(url) > 38)
+ {
+ // The length is also checked in the WriteNDEFURI function, but lets
+ // warn users here just in case they change the value and it's bigger
+ // than it should be
+ Serial.println("URI is too long ... must be less than 38 characters!");
+ return;
+ }
+
+ Serial.println("Updating sector 1 with URI as NDEF Message");
+
+ // URI is within size limits ... write it to the card and report success/failure
+ success = nfc.mifareclassic_WriteNDEFURI(1, ndefprefix, url);
+ if (success)
+ {
+ Serial.println("NDEF URI Record written to sector 1");
+ Serial.println("");
+ }
+ else
+ {
+ Serial.println("NDEF Record creation failed! :(");
+ }
+ }
+
+ // Wait a bit before trying again
+ Serial.println("\n\nDone!");
+ delay(1000);
+ Serial.flush();
+ while(Serial.available()) Serial.read();
+}
diff --git a/.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/examples/ntag2xx_erase/ntag2xx_erase.ino b/.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/examples/ntag2xx_erase/ntag2xx_erase.ino
new file mode 100644
index 0000000..4bc5d42
--- /dev/null
+++ b/.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/examples/ntag2xx_erase/ntag2xx_erase.ino
@@ -0,0 +1,158 @@
+/**************************************************************************/
+/*!
+ @file ntag2xx_erase.pde
+ @author KTOWN (Adafruit Industries)
+ @license BSD (see license.txt)
+
+ This example will wait for any NTAG203 or NTAG213 card or tag,
+ and will attempt to erase the user data section of the card (setting
+ all user bytes to 0x00)
+
+ This is an example sketch for the Adafruit PN532 NFC/RFID breakout boards
+ This library works with the Adafruit NFC breakout
+ ----> https://www.adafruit.com/products/364
+
+ Check out the links above for our tutorials and wiring diagrams
+ These chips use SPI or I2C to communicate.
+
+ Adafruit invests time and resources providing this open source code,
+ please support Adafruit and open-source hardware by purchasing
+ products from Adafruit!
+*/
+/**************************************************************************/
+#include <Wire.h>
+#include <SPI.h>
+#include <Adafruit_PN532.h>
+
+// If using the breakout with SPI, define the pins for SPI communication.
+#define PN532_SCK (2)
+#define PN532_MOSI (3)
+#define PN532_SS (4)
+#define PN532_MISO (5)
+
+// If using the breakout or shield with I2C, define just the pins connected
+// to the IRQ and reset lines. Use the values below (2, 3) for the shield!
+#define PN532_IRQ (2)
+#define PN532_RESET (3) // Not connected by default on the NFC Shield
+
+// Uncomment just _one_ line below depending on how your breakout or shield
+// is connected to the Arduino:
+
+// Use this line for a breakout with a software SPI connection (recommended):
+Adafruit_PN532 nfc(PN532_SCK, PN532_MISO, PN532_MOSI, PN532_SS);
+
+// Use this line for a breakout with a hardware SPI connection. Note that
+// the PN532 SCK, MOSI, and MISO pins need to be connected to the Arduino's
+// hardware SPI SCK, MOSI, and MISO pins. On an Arduino Uno these are
+// SCK = 13, MOSI = 11, MISO = 12. The SS line can be any digital IO pin.
+//Adafruit_PN532 nfc(PN532_SS);
+
+// Or use this line for a breakout or shield with an I2C connection:
+//Adafruit_PN532 nfc(PN532_IRQ, PN532_RESET);
+
+void setup(void) {
+ Serial.begin(115200);
+ while (!Serial) delay(10); // for Leonardo/Micro/Zero
+
+ Serial.println("Hello!");
+
+ nfc.begin();
+
+ uint32_t versiondata = nfc.getFirmwareVersion();
+ if (! versiondata) {
+ Serial.print("Didn't find PN53x board");
+ while (1); // halt
+ }
+ // Got ok data, print it out!
+ 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);
+
+ Serial.println("Waiting for an ISO14443A Card ...");
+}
+
+void loop(void) {
+ uint8_t success;
+ uint8_t uid[] = { 0, 0, 0, 0, 0, 0, 0 }; // Buffer to store the returned UID
+ uint8_t uidLength; // Length of the UID (4 or 7 bytes depending on ISO14443A card type)
+
+ // Wait for an NTAG203 card. When one is found 'uid' will be populated with
+ // the UID, and uidLength will indicate the size of the UUID (normally 7)
+ success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, uid, &uidLength);
+
+ if (success) {
+ // Display some basic information about the card
+ Serial.println("Found an ISO14443A card");
+ Serial.print(" UID Length: ");Serial.print(uidLength, DEC);Serial.println(" bytes");
+ Serial.print(" UID Value: ");
+ nfc.PrintHex(uid, uidLength);
+ Serial.println("");
+
+ if (uidLength == 7)
+ {
+ uint8_t data[32];
+
+ // We probably have an NTAG2xx card (though it could be Ultralight as well)
+ Serial.println("Seems to be an NTAG2xx tag (7 byte UID)");
+
+ // NTAG2x3 cards have 39*4 bytes of user pages (156 user bytes),
+ // starting at page 4 ... larger cards just add pages to the end of
+ // this range:
+
+ // See: http://www.nxp.com/documents/short_data_sheet/NTAG203_SDS.pdf
+
+ // TAG Type PAGES USER START USER STOP
+ // -------- ----- ---------- ---------
+ // NTAG 203 42 4 39
+ // NTAG 213 45 4 39
+ // NTAG 215 135 4 129
+ // NTAG 216 231 4 225
+
+ Serial.println("");
+ Serial.println("Writing 0x00 0x00 0x00 0x00 to pages 4..39");
+ Serial.println("");
+ for (uint8_t i = 4; i < 39; i++)
+ {
+ memset(data, 0, 4);
+ success = nfc.ntag2xx_WritePage(i, data);
+
+ // Display the current page number
+ Serial.print("Page ");
+ if (i < 10)
+ {
+ Serial.print("0");
+ Serial.print(i);
+ }
+ else
+ {
+ Serial.print(i);
+ }
+ Serial.print(": ");
+
+ // Display the results, depending on 'success'
+ if (success)
+ {
+ Serial.println("Erased");
+ }
+ else
+ {
+ Serial.println("Unable to write to the requested page!");
+ }
+ }
+ }
+ else
+ {
+ Serial.println("This doesn't seem to be an NTAG203 tag (UUID length != 7 bytes)!");
+ }
+
+ // Wait a bit before trying again
+ Serial.println("\n\nSend a character to scan another tag!");
+ Serial.flush();
+ while (!Serial.available());
+ while (Serial.available()) {
+ Serial.read();
+ }
+ Serial.flush();
+ }
+}
+
diff --git a/.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/examples/ntag2xx_read/ntag2xx_read.ino b/.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/examples/ntag2xx_read/ntag2xx_read.ino
new file mode 100644
index 0000000..b0bd365
--- /dev/null
+++ b/.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/examples/ntag2xx_read/ntag2xx_read.ino
@@ -0,0 +1,155 @@
+/**************************************************************************/
+/*!
+ @file readntag203.pde
+ @author KTOWN (Adafruit Industries)
+ @license BSD (see license.txt)
+
+ This example will wait for any NTAG203 or NTAG213 card or tag,
+ and will attempt to read from it.
+
+ This is an example sketch for the Adafruit PN532 NFC/RFID breakout boards
+ This library works with the Adafruit NFC breakout
+ ----> https://www.adafruit.com/products/364
+
+ Check out the links above for our tutorials and wiring diagrams
+ These chips use SPI or I2C to communicate.
+
+ Adafruit invests time and resources providing this open source code,
+ please support Adafruit and open-source hardware by purchasing
+ products from Adafruit!
+*/
+/**************************************************************************/
+#include <Wire.h>
+#include <SPI.h>
+#include <Adafruit_PN532.h>
+
+// If using the breakout with SPI, define the pins for SPI communication.
+#define PN532_SCK (2)
+#define PN532_MOSI (3)
+#define PN532_SS (4)
+#define PN532_MISO (5)
+
+// If using the breakout or shield with I2C, define just the pins connected
+// to the IRQ and reset lines. Use the values below (2, 3) for the shield!
+#define PN532_IRQ (2)
+#define PN532_RESET (3) // Not connected by default on the NFC Shield
+
+// Uncomment just _one_ line below depending on how your breakout or shield
+// is connected to the Arduino:
+
+// Use this line for a breakout with a software SPI connection (recommended):
+Adafruit_PN532 nfc(PN532_SCK, PN532_MISO, PN532_MOSI, PN532_SS);
+
+// Use this line for a breakout with a hardware SPI connection. Note that
+// the PN532 SCK, MOSI, and MISO pins need to be connected to the Arduino's
+// hardware SPI SCK, MOSI, and MISO pins. On an Arduino Uno these are
+// SCK = 13, MOSI = 11, MISO = 12. The SS line can be any digital IO pin.
+//Adafruit_PN532 nfc(PN532_SS);
+
+// Or use this line for a breakout or shield with an I2C connection:
+//Adafruit_PN532 nfc(PN532_IRQ, PN532_RESET);
+
+
+void setup(void) {
+ Serial.begin(115200);
+ while (!Serial) delay(10); // for Leonardo/Micro/Zero
+
+ Serial.println("Hello!");
+
+ nfc.begin();
+
+ uint32_t versiondata = nfc.getFirmwareVersion();
+ if (! versiondata) {
+ Serial.print("Didn't find PN53x board");
+ while (1); // halt
+ }
+ // Got ok data, print it out!
+ 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);
+
+ Serial.println("Waiting for an ISO14443A Card ...");
+}
+
+void loop(void) {
+ uint8_t success;
+ uint8_t uid[] = { 0, 0, 0, 0, 0, 0, 0 }; // Buffer to store the returned UID
+ uint8_t uidLength; // Length of the UID (4 or 7 bytes depending on ISO14443A card type)
+
+ // Wait for an NTAG203 card. When one is found 'uid' will be populated with
+ // the UID, and uidLength will indicate the size of the UUID (normally 7)
+ success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, uid, &uidLength);
+
+ if (success) {
+ // Display some basic information about the card
+ Serial.println("Found an ISO14443A card");
+ Serial.print(" UID Length: ");Serial.print(uidLength, DEC);Serial.println(" bytes");
+ Serial.print(" UID Value: ");
+ nfc.PrintHex(uid, uidLength);
+ Serial.println("");
+
+ if (uidLength == 7)
+ {
+ uint8_t data[32];
+
+ // We probably have an NTAG2xx card (though it could be Ultralight as well)
+ Serial.println("Seems to be an NTAG2xx tag (7 byte UID)");
+
+ // NTAG2x3 cards have 39*4 bytes of user pages (156 user bytes),
+ // starting at page 4 ... larger cards just add pages to the end of
+ // this range:
+
+ // See: http://www.nxp.com/documents/short_data_sheet/NTAG203_SDS.pdf
+
+ // TAG Type PAGES USER START USER STOP
+ // -------- ----- ---------- ---------
+ // NTAG 203 42 4 39
+ // NTAG 213 45 4 39
+ // NTAG 215 135 4 129
+ // NTAG 216 231 4 225
+
+ for (uint8_t i = 0; i < 42; i++)
+ {
+ success = nfc.ntag2xx_ReadPage(i, data);
+
+ // Display the current page number
+ Serial.print("PAGE ");
+ if (i < 10)
+ {
+ Serial.print("0");
+ Serial.print(i);
+ }
+ else
+ {
+ Serial.print(i);
+ }
+ Serial.print(": ");
+
+ // Display the results, depending on 'success'
+ if (success)
+ {
+ // Dump the page data
+ nfc.PrintHexChar(data, 4);
+ }
+ else
+ {
+ Serial.println("Unable to read the requested page!");
+ }
+ }
+ }
+ else
+ {
+ Serial.println("This doesn't seem to be an NTAG203 tag (UUID length != 7 bytes)!");
+ }
+
+ // Wait a bit before trying again
+ Serial.println("\n\nSend a character to scan another tag!");
+ Serial.flush();
+ while (!Serial.available());
+ while (Serial.available()) {
+ Serial.read();
+ }
+ Serial.flush();
+ }
+}
+
diff --git a/.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/examples/ntag2xx_updatendef/ntag2xx_updatendef.ino b/.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/examples/ntag2xx_updatendef/ntag2xx_updatendef.ino
new file mode 100644
index 0000000..3616686
--- /dev/null
+++ b/.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/examples/ntag2xx_updatendef/ntag2xx_updatendef.ino
@@ -0,0 +1,212 @@
+/**************************************************************************/
+/*!
+ @file ntag2xx_updatendef.pde
+ @author KTOWN (Adafruit Industries)
+ @license BSD (see license.txt)
+
+ This example will wait for any NTAG203 or NTAG213 card or tag,
+ and will attempt to add or update an NDEF URI at the start of the
+ tag's memory.
+
+ This is an example sketch for the Adafruit PN532 NFC/RFID breakout boards
+ This library works with the Adafruit NFC breakout
+ ----> https://www.adafruit.com/products/364
+
+ Check out the links above for our tutorials and wiring diagrams
+ These chips use SPI or I2C to communicate.
+
+ Adafruit invests time and resources providing this open source code,
+ please support Adafruit and open-source hardware by purchasing
+ products from Adafruit!
+*/
+/**************************************************************************/
+#include <Wire.h>
+#include <SPI.h>
+#include <Adafruit_PN532.h>
+
+// If using the breakout with SPI, define the pins for SPI communication.
+#define PN532_SCK (2)
+#define PN532_MOSI (3)
+#define PN532_SS (4)
+#define PN532_MISO (5)
+
+// If using the breakout or shield with I2C, define just the pins connected
+// to the IRQ and reset lines. Use the values below (2, 3) for the shield!
+#define PN532_IRQ (2)
+#define PN532_RESET (3) // Not connected by default on the NFC Shield
+
+// Uncomment just _one_ line below depending on how your breakout or shield
+// is connected to the Arduino:
+
+// Use this line for a breakout with a software SPI connection (recommended):
+Adafruit_PN532 nfc(PN532_SCK, PN532_MISO, PN532_MOSI, PN532_SS);
+
+// Use this line for a breakout with a hardware SPI connection. Note that
+// the PN532 SCK, MOSI, and MISO pins need to be connected to the Arduino's
+// hardware SPI SCK, MOSI, and MISO pins. On an Arduino Uno these are
+// SCK = 13, MOSI = 11, MISO = 12. The SS line can be any digital IO pin.
+//Adafruit_PN532 nfc(PN532_SS);
+
+// Or use this line for a breakout or shield with an I2C connection:
+//Adafruit_PN532 nfc(PN532_IRQ, PN532_RESET);
+
+/*
+ We can encode many different kinds of pointers to the card,
+ from a URL, to an Email address, to a phone number, and many more
+ check the library header .h file to see the large # of supported
+ prefixes!
+*/
+// For a http://www. url:
+char * url = "adafruit.com/blog/";
+uint8_t ndefprefix = NDEF_URIPREFIX_HTTP_WWWDOT;
+
+// for an email address
+//char * url = "mail@example.com";
+//uint8_t ndefprefix = NDEF_URIPREFIX_MAILTO;
+
+// for a phone number
+//char * url = "+1 212 555 1212";
+//uint8_t ndefprefix = NDEF_URIPREFIX_TEL;
+
+void setup(void) {
+ Serial.begin(115200);
+ while (!Serial) delay(10); // for Leonardo/Micro/Zero
+
+ Serial.println("Hello!");
+
+ nfc.begin();
+
+ uint32_t versiondata = nfc.getFirmwareVersion();
+ if (! versiondata) {
+ Serial.print("Didn't find PN53x board");
+ while (1); // halt
+ }
+ // Got ok data, print it out!
+ 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);
+}
+
+void loop(void)
+{
+ uint8_t success;
+ uint8_t uid[] = { 0, 0, 0, 0, 0, 0, 0 }; // Buffer to store the returned UID
+ uint8_t uidLength; // Length of the UID (4 or 7 bytes depending on ISO14443A card type)
+ uint8_t dataLength;
+
+ // Require some user feedback before running this example!
+ Serial.println("\r\nPlace your NDEF formatted NTAG2xx tag on the reader to update the");
+ Serial.println("NDEF record and press any key to continue ...\r\n");
+ // Wait for user input before proceeding
+ while (!Serial.available());
+ // a key was pressed1
+ while (Serial.available()) Serial.read();
+
+ // 1.) Wait for an NTAG203 card. When one is found 'uid' will be populated with
+ // the UID, and uidLength will indicate the size of the UID (normally 7)
+ success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, uid, &uidLength);
+
+ // It seems we found a valid ISO14443A Tag!
+ if (success)
+ {
+ // 2.) Display some basic information about the card
+ Serial.println("Found an ISO14443A card");
+ Serial.print(" UID Length: ");Serial.print(uidLength, DEC);Serial.println(" bytes");
+ Serial.print(" UID Value: ");
+ nfc.PrintHex(uid, uidLength);
+ Serial.println("");
+
+ if (uidLength != 7)
+ {
+ Serial.println("This doesn't seem to be an NTAG203 tag (UUID length != 7 bytes)!");
+ }
+ else
+ {
+ uint8_t data[32];
+
+ // We probably have an NTAG2xx card (though it could be Ultralight as well)
+ Serial.println("Seems to be an NTAG2xx tag (7 byte UID)");
+
+ // NTAG2x3 cards have 39*4 bytes of user pages (156 user bytes),
+ // starting at page 4 ... larger cards just add pages to the end of
+ // this range:
+
+ // See: http://www.nxp.com/documents/short_data_sheet/NTAG203_SDS.pdf
+
+ // TAG Type PAGES USER START USER STOP
+ // -------- ----- ---------- ---------
+ // NTAG 203 42 4 39
+ // NTAG 213 45 4 39
+ // NTAG 215 135 4 129
+ // NTAG 216 231 4 225
+
+
+ // 3.) Check if the NDEF Capability Container (CC) bits are already set
+ // in OTP memory (page 3)
+ memset(data, 0, 4);
+ success = nfc.ntag2xx_ReadPage(3, data);
+ if (!success)
+ {
+ Serial.println("Unable to read the Capability Container (page 3)");
+ return;
+ }
+ else
+ {
+ // If the tag has already been formatted as NDEF, byte 0 should be:
+ // Byte 0 = Magic Number (0xE1)
+ // Byte 1 = NDEF Version (Should be 0x10)
+ // Byte 2 = Data Area Size (value * 8 bytes)
+ // Byte 3 = Read/Write Access (0x00 for full read and write)
+ if (!((data[0] == 0xE1) && (data[1] == 0x10)))
+ {
+ Serial.println("This doesn't seem to be an NDEF formatted tag.");
+ Serial.println("Page 3 should start with 0xE1 0x10.");
+ }
+ else
+ {
+ // 4.) Determine and display the data area size
+ dataLength = data[2]*8;
+ Serial.print("Tag is NDEF formatted. Data area size = ");
+ Serial.print(dataLength);
+ Serial.println(" bytes");
+
+ // 5.) Erase the old data area
+ Serial.print("Erasing previous data area ");
+ for (uint8_t i = 4; i < (dataLength/4)+4; i++)
+ {
+ memset(data, 0, 4);
+ success = nfc.ntag2xx_WritePage(i, data);
+ Serial.print(".");
+ if (!success)
+ {
+ Serial.println(" ERROR!");
+ return;
+ }
+ }
+ Serial.println(" DONE!");
+
+ // 6.) Try to add a new NDEF URI record
+ Serial.print("Writing URI as NDEF Record ... ");
+ success = nfc.ntag2xx_WriteNDEFURI(ndefprefix, url, dataLength);
+ if (success)
+ {
+ Serial.println("DONE!");
+ }
+ else
+ {
+ Serial.println("ERROR! (URI length?)");
+ }
+
+ } // CC contents NDEF record check
+ } // CC page read check
+ } // UUID length check
+
+ // Wait a bit before trying again
+ Serial.flush();
+ while (!Serial.available());
+ while (Serial.available()) {
+ Serial.read();
+ }
+ Serial.flush();
+ } // Start waiting for a new ISO14443A tag
+} \ No newline at end of file
diff --git a/.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/examples/readMifare/readMifare.ino b/.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/examples/readMifare/readMifare.ino
new file mode 100644
index 0000000..ecd4d28
--- /dev/null
+++ b/.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/examples/readMifare/readMifare.ino
@@ -0,0 +1,184 @@
+/**************************************************************************/
+/*!
+ @file readMifare.pde
+ @author Adafruit Industries
+ @license BSD (see license.txt)
+
+ This example will wait for any ISO14443A card or tag, and
+ depending on the size of the UID will attempt to read from it.
+
+ If the card has a 4-byte UID it is probably a Mifare
+ Classic card, and the following steps are taken:
+
+ - Authenticate block 4 (the first block of Sector 1) using
+ the default KEYA of 0XFF 0XFF 0XFF 0XFF 0XFF 0XFF
+ - If authentication succeeds, we can then read any of the
+ 4 blocks in that sector (though only block 4 is read here)
+
+ If the card has a 7-byte UID it is probably a Mifare
+ Ultralight card, and the 4 byte pages can be read directly.
+ Page 4 is read by default since this is the first 'general-
+ purpose' page on the tags.
+
+
+This is an example sketch for the Adafruit PN532 NFC/RFID breakout boards
+This library works with the Adafruit NFC breakout
+ ----> https://www.adafruit.com/products/364
+
+Check out the links above for our tutorials and wiring diagrams
+These chips use SPI or I2C to communicate.
+
+Adafruit invests time and resources providing this open source code,
+please support Adafruit and open-source hardware by purchasing
+products from Adafruit!
+
+*/
+/**************************************************************************/
+#include <Wire.h>
+#include <SPI.h>
+#include <Adafruit_PN532.h>
+
+// If using the breakout with SPI, define the pins for SPI communication.
+#define PN532_SCK (2)
+#define PN532_MOSI (3)
+#define PN532_SS (4)
+#define PN532_MISO (5)
+
+// If using the breakout or shield with I2C, define just the pins connected
+// to the IRQ and reset lines. Use the values below (2, 3) for the shield!
+#define PN532_IRQ (2)
+#define PN532_RESET (3) // Not connected by default on the NFC Shield
+
+// Uncomment just _one_ line below depending on how your breakout or shield
+// is connected to the Arduino:
+
+// Use this line for a breakout with a software SPI connection (recommended):
+Adafruit_PN532 nfc(PN532_SCK, PN532_MISO, PN532_MOSI, PN532_SS);
+
+// Use this line for a breakout with a hardware SPI connection. Note that
+// the PN532 SCK, MOSI, and MISO pins need to be connected to the Arduino's
+// hardware SPI SCK, MOSI, and MISO pins. On an Arduino Uno these are
+// SCK = 13, MOSI = 11, MISO = 12. The SS line can be any digital IO pin.
+//Adafruit_PN532 nfc(PN532_SS);
+
+// Or use this line for a breakout or shield with an I2C connection:
+//Adafruit_PN532 nfc(PN532_IRQ, PN532_RESET);
+
+// Or use hardware Serial:
+//Adafruit_PN532 nfc(PN532_RESET, &Serial1);
+
+void setup(void) {
+ Serial.begin(115200);
+ while (!Serial) delay(10); // for Leonardo/Micro/Zero
+
+ Serial.println("Hello!");
+
+ nfc.begin();
+
+ uint32_t versiondata = nfc.getFirmwareVersion();
+ if (! versiondata) {
+ Serial.print("Didn't find PN53x board");
+ while (1); // halt
+ }
+ // Got ok data, print it out!
+ 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);
+
+ Serial.println("Waiting for an ISO14443A Card ...");
+}
+
+
+void loop(void) {
+ uint8_t success;
+ uint8_t uid[] = { 0, 0, 0, 0, 0, 0, 0 }; // Buffer to store the returned UID
+ uint8_t uidLength; // Length of the UID (4 or 7 bytes depending on ISO14443A card type)
+
+ // Wait for an ISO14443A type cards (Mifare, etc.). When one is found
+ // 'uid' will be populated with the UID, and uidLength will indicate
+ // if the uid is 4 bytes (Mifare Classic) or 7 bytes (Mifare Ultralight)
+ success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, uid, &uidLength);
+
+ if (success) {
+ // Display some basic information about the card
+ Serial.println("Found an ISO14443A card");
+ Serial.print(" UID Length: ");Serial.print(uidLength, DEC);Serial.println(" bytes");
+ Serial.print(" UID Value: ");
+ nfc.PrintHex(uid, uidLength);
+ Serial.println("");
+
+ if (uidLength == 4)
+ {
+ // We probably have a Mifare Classic card ...
+ Serial.println("Seems to be a Mifare Classic card (4 byte UID)");
+
+ // Now we need to try to authenticate it for read/write access
+ // Try with the factory default KeyA: 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF
+ Serial.println("Trying to authenticate block 4 with default KEYA value");
+ uint8_t keya[6] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
+
+ // Start with block 4 (the first block of sector 1) since sector 0
+ // contains the manufacturer data and it's probably better just
+ // to leave it alone unless you know what you're doing
+ success = nfc.mifareclassic_AuthenticateBlock(uid, uidLength, 4, 0, keya);
+
+ if (success)
+ {
+ Serial.println("Sector 1 (Blocks 4..7) has been authenticated");
+ uint8_t data[16];
+
+ // If you want to write something to block 4 to test with, uncomment
+ // the following line and this text should be read back in a minute
+ //memcpy(data, (const uint8_t[]){ 'a', 'd', 'a', 'f', 'r', 'u', 'i', 't', '.', 'c', 'o', 'm', 0, 0, 0, 0 }, sizeof data);
+ // success = nfc.mifareclassic_WriteDataBlock (4, data);
+
+ // Try to read the contents of block 4
+ success = nfc.mifareclassic_ReadDataBlock(4, data);
+
+ if (success)
+ {
+ // Data seems to have been read ... spit it out
+ Serial.println("Reading Block 4:");
+ nfc.PrintHexChar(data, 16);
+ Serial.println("");
+
+ // Wait a bit before reading the card again
+ delay(1000);
+ }
+ else
+ {
+ Serial.println("Ooops ... unable to read the requested block. Try another key?");
+ }
+ }
+ else
+ {
+ Serial.println("Ooops ... authentication failed: Try another key?");
+ }
+ }
+
+ if (uidLength == 7)
+ {
+ // We probably have a Mifare Ultralight card ...
+ Serial.println("Seems to be a Mifare Ultralight tag (7 byte UID)");
+
+ // Try to read the first general-purpose user page (#4)
+ Serial.println("Reading page 4");
+ uint8_t data[32];
+ success = nfc.mifareultralight_ReadPage (4, data);
+ if (success)
+ {
+ // Data seems to have been read ... spit it out
+ nfc.PrintHexChar(data, 4);
+ Serial.println("");
+
+ // Wait a bit before reading the card again
+ delay(1000);
+ }
+ else
+ {
+ Serial.println("Ooops ... unable to read the requested page!?");
+ }
+ }
+ }
+}
+
diff --git a/.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/examples/readMifareClassic/readMifareClassic.ino b/.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/examples/readMifareClassic/readMifareClassic.ino
new file mode 100644
index 0000000..a2edaf8
--- /dev/null
+++ b/.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/examples/readMifareClassic/readMifareClassic.ino
@@ -0,0 +1,119 @@
+/**************************************************************************/
+/*!
+ @file readMifareClassic.pde
+ @author Adafruit Industries
+ @license BSD (see license.txt)
+
+ This example will wait for any ISO14443A card or tag, and
+ depending on the size of the UID will attempt to read from it.
+
+ If the card has a 4-byte UID it is probably a Mifare
+ Classic card, and the following steps are taken:
+
+ Reads the 4 byte (32 bit) ID of a MiFare Classic card.
+ Since the classic cards have only 32 bit identifiers you can stick
+ them in a single variable and use that to compare card ID's as a
+ number. This doesn't work for ultralight cards that have longer 7
+ byte IDs!
+
+ Note that you need the baud rate to be 115200 because we need to
+ print out the data and read from the card at the same time!
+
+This is an example sketch for the Adafruit PN532 NFC/RFID breakout boards
+This library works with the Adafruit NFC breakout
+ ----> https://www.adafruit.com/products/364
+
+Check out the links above for our tutorials and wiring diagrams
+These chips use SPI to communicate, 4 required to interface
+
+Adafruit invests time and resources providing this open source code,
+please support Adafruit and open-source hardware by purchasing
+products from Adafruit!
+*/
+/**************************************************************************/
+#include <Wire.h>
+#include <SPI.h>
+#include <Adafruit_PN532.h>
+
+// If using the breakout with SPI, define the pins for SPI communication.
+#define PN532_SCK (2)
+#define PN532_MOSI (3)
+#define PN532_SS (4)
+#define PN532_MISO (5)
+
+// If using the breakout or shield with I2C, define just the pins connected
+// to the IRQ and reset lines. Use the values below (2, 3) for the shield!
+#define PN532_IRQ (2)
+#define PN532_RESET (3) // Not connected by default on the NFC Shield
+
+// Uncomment just _one_ line below depending on how your breakout or shield
+// is connected to the Arduino:
+
+// Use this line for a breakout with a SPI connection:
+Adafruit_PN532 nfc(PN532_SCK, PN532_MISO, PN532_MOSI, PN532_SS);
+
+// Use this line for a breakout with a hardware SPI connection. Note that
+// the PN532 SCK, MOSI, and MISO pins need to be connected to the Arduino's
+// hardware SPI SCK, MOSI, and MISO pins. On an Arduino Uno these are
+// SCK = 13, MOSI = 11, MISO = 12. The SS line can be any digital IO pin.
+//Adafruit_PN532 nfc(PN532_SS);
+
+// Or use this line for a breakout or shield with an I2C connection:
+//Adafruit_PN532 nfc(PN532_IRQ, PN532_RESET);
+
+void setup(void) {
+ Serial.begin(115200);
+ while (!Serial) delay(10); // for Leonardo/Micro/Zero
+
+ Serial.println("Hello!");
+
+ nfc.begin();
+
+ uint32_t versiondata = nfc.getFirmwareVersion();
+ if (! versiondata) {
+ Serial.print("Didn't find PN53x board");
+ while (1); // halt
+ }
+ // Got ok data, print it out!
+ 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);
+
+ Serial.println("Waiting for an ISO14443A Card ...");
+}
+
+
+void loop(void) {
+ uint8_t success;
+ uint8_t uid[] = { 0, 0, 0, 0, 0, 0, 0 }; // Buffer to store the returned UID
+ uint8_t uidLength; // Length of the UID (4 or 7 bytes depending on ISO14443A card type)
+
+ // Wait for an ISO14443A type cards (Mifare, etc.). When one is found
+ // 'uid' will be populated with the UID, and uidLength will indicate
+ // if the uid is 4 bytes (Mifare Classic) or 7 bytes (Mifare Ultralight)
+ success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, uid, &uidLength);
+
+ if (success) {
+ // Display some basic information about the card
+ Serial.println("Found an ISO14443A card");
+ Serial.print(" UID Length: ");Serial.print(uidLength, DEC);Serial.println(" bytes");
+ Serial.print(" UID Value: ");
+ nfc.PrintHex(uid, uidLength);
+
+ if (uidLength == 4)
+ {
+ // We probably have a Mifare Classic card ...
+ uint32_t cardid = uid[0];
+ cardid <<= 8;
+ cardid |= uid[1];
+ cardid <<= 8;
+ cardid |= uid[2];
+ cardid <<= 8;
+ cardid |= uid[3];
+ Serial.print("Seems to be a Mifare Classic card #");
+ Serial.println(cardid);
+ }
+ Serial.println("");
+ }
+}
+
diff --git a/.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/examples/readMifareClassicIrq/readMifareClassicIrq.ino b/.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/examples/readMifareClassicIrq/readMifareClassicIrq.ino
new file mode 100644
index 0000000..345e317
--- /dev/null
+++ b/.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/examples/readMifareClassicIrq/readMifareClassicIrq.ino
@@ -0,0 +1,156 @@
+/**************************************************************************/
+/*!
+ @file readMifareClassicIrq.pde
+ @author Adafruit Industries
+ @license BSD (see license.txt)
+
+ This example will wait for any ISO14443A card or tag, and
+ depending on the size of the UID will attempt to read from it.
+
+ If the card has a 4-byte UID it is probably a Mifare
+ Classic card, and the following steps are taken:
+
+ Reads the 4 byte (32 bit) ID of a MiFare Classic card.
+ Since the classic cards have only 32 bit identifiers you can stick
+ them in a single variable and use that to compare card ID's as a
+ number. This doesn't work for ultralight cards that have longer 7
+ byte IDs!
+
+ Note that you need the baud rate to be 115200 because we need to
+ print out the data and read from the card at the same time!
+
+This is an example sketch for the Adafruit PN532 NFC/RFID breakout boards
+This library works with the Adafruit NFC breakout
+ ----> https://www.adafruit.com/products/364
+
+Check out the links above for our tutorials and wiring diagrams
+
+This example is for communicating with the PN532 chip using I2C. Wiring
+should be as follows:
+ PN532 SDA -> SDA pin
+ PN532 SCL -> SCL pin
+ PN532 IRQ -> D2
+ PN532 SDA -> 3.3v (with 2k resistor)
+ PN532 SCL -> 3.3v (with 2k resistor)
+ PN532 3.3v -> 3.3v
+ PN532 GND -> GND
+
+Adafruit invests time and resources providing this open source code,
+please support Adafruit and open-source hardware by purchasing
+products from Adafruit!
+*/
+/**************************************************************************/
+#include <Wire.h>
+#include <SPI.h>
+#include <Adafruit_PN532.h>
+
+// If using the breakout with SPI, define the pins for SPI communication.
+#define PN532_SCK (2)
+#define PN532_MOSI (3)
+#define PN532_SS (4)
+#define PN532_MISO (5)
+
+// If using the breakout or shield with I2C, define just the pins connected
+// to the IRQ and reset lines. Use the values below (2, 3) for the shield!
+#define PN532_IRQ (2)
+#define PN532_RESET (3) // Not connected by default on the NFC Shield
+
+const int DELAY_BETWEEN_CARDS = 500;
+long timeLastCardRead = 0;
+boolean readerDisabled = false;
+int irqCurr;
+int irqPrev;
+
+// This example uses the IRQ line, which is available when in I2C mode.
+Adafruit_PN532 nfc(PN532_IRQ, PN532_RESET);
+
+void setup(void) {
+ Serial.begin(115200);
+ while (!Serial) delay(10); // for Leonardo/Micro/Zero
+
+ Serial.println("Hello!");
+
+ nfc.begin();
+
+ uint32_t versiondata = nfc.getFirmwareVersion();
+ if (! versiondata) {
+ Serial.print("Didn't find PN53x board");
+ while (1); // halt
+ }
+ // Got ok data, print it out!
+ 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);
+
+ startListeningToNFC();
+}
+
+void loop(void) {
+ if (readerDisabled) {
+ if (millis() - timeLastCardRead > DELAY_BETWEEN_CARDS) {
+ readerDisabled = false;
+ startListeningToNFC();
+ }
+ } else {
+ irqCurr = digitalRead(PN532_IRQ);
+
+ // When the IRQ is pulled low - the reader has got something for us.
+ if (irqCurr == LOW && irqPrev == HIGH) {
+ Serial.println("Got NFC IRQ");
+ handleCardDetected();
+ }
+
+ irqPrev = irqCurr;
+ }
+}
+
+void startListeningToNFC() {
+ // Reset our IRQ indicators
+ irqPrev = irqCurr = HIGH;
+
+ Serial.println("Starting passive read for an ISO14443A Card ...");
+ if (!nfc.startPassiveTargetIDDetection(PN532_MIFARE_ISO14443A)) {
+ Serial.println("No card found. Waiting...");
+ } else {
+ Serial.println("Card already present.");
+ handleCardDetected();
+ }
+}
+
+void handleCardDetected() {
+ uint8_t success = false;
+ uint8_t uid[] = { 0, 0, 0, 0, 0, 0, 0 }; // Buffer to store the returned UID
+ uint8_t uidLength; // Length of the UID (4 or 7 bytes depending on ISO14443A card type)
+
+ // read the NFC tag's info
+ success = nfc.readDetectedPassiveTargetID(uid, &uidLength);
+ Serial.println(success ? "Read successful" : "Read failed (not a card?)");
+
+ if (success) {
+ // Display some basic information about the card
+ Serial.println("Found an ISO14443A card");
+ Serial.print(" UID Length: ");Serial.print(uidLength, DEC);Serial.println(" bytes");
+ Serial.print(" UID Value: ");
+ nfc.PrintHex(uid, uidLength);
+
+ if (uidLength == 4)
+ {
+ // We probably have a Mifare Classic card ...
+ uint32_t cardid = uid[0];
+ cardid <<= 8;
+ cardid |= uid[1];
+ cardid <<= 8;
+ cardid |= uid[2];
+ cardid <<= 8;
+ cardid |= uid[3];
+ Serial.print("Seems to be a Mifare Classic card #");
+ Serial.println(cardid);
+ }
+ Serial.println("");
+
+ timeLastCardRead = millis();
+ }
+
+ // The reader will be enabled again after DELAY_BETWEEN_CARDS ms will pass.
+ readerDisabled = true;
+}
diff --git a/.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/library.properties b/.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/library.properties
new file mode 100644
index 0000000..804b3ff
--- /dev/null
+++ b/.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/library.properties
@@ -0,0 +1,10 @@
+name=Adafruit PN532
+version=1.3.4
+author=Adafruit
+maintainer=Adafruit <info@adafruit.com>
+sentence=Arduino library for SPI and I2C access to the PN532 RFID/Near Field Communication chip
+paragraph=Arduino library for SPI and I2C access to the PN532 RFID/Near Field Communication chip
+category=Communication
+url=https://github.com/adafruit/Adafruit-PN532
+architectures=*
+depends=Adafruit BusIO
diff --git a/.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/license.txt b/.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/license.txt
new file mode 100644
index 0000000..f6a0f22
--- /dev/null
+++ b/.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/license.txt
@@ -0,0 +1,26 @@
+Software License Agreement (BSD License)
+
+Copyright (c) 2012, Adafruit Industries
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+1. Redistributions of source code must retain the above copyright
+notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+notice, this list of conditions and the following disclaimer in the
+documentation and/or other materials provided with the distribution.
+3. Neither the name of the copyright holders nor the
+names of its contributors may be used to endorse or promote products
+derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.