diff options
| author | krolyxon <me@krolyxon.com> | 2026-06-08 23:10:46 +0530 |
|---|---|---|
| committer | krolyxon <me@krolyxon.com> | 2026-06-08 23:10:46 +0530 |
| commit | 3120783000d0025b183b0397acaa8b769499eb38 (patch) | |
| tree | 1c4f93be213f1b1d48f59e554562d847b4e7c25e /.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/examples | |
Initial gh-pages firmware hosting
Diffstat (limited to '.pio/libdeps/esp32-s3-n16r8/Adafruit PN532/examples')
22 files changed, 2608 insertions, 0 deletions
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; +} |
