Skip to content

Commit

Permalink
支持 ESP8266。
Browse files Browse the repository at this point in the history
  • Loading branch information
Sucareto committed Aug 9, 2021
1 parent 4902704 commit ae2426f
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 15 deletions.
6 changes: 3 additions & 3 deletions Arduino-Aime-Reader.ino
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "cmd.h"

#define SerialDevice SerialUSB //32u4,samd21
//#define SerialDevice Serial
//#define SerialDevice SerialUSB //32u4,samd21
#define SerialDevice Serial //esp8266

void SerialCheck() {
switch (packet_read()) {
Expand Down Expand Up @@ -59,7 +59,7 @@ void SerialCheck() {

void setup() {
SerialDevice.begin(38400);
// SerialUSB.begin(119200);//high_baudrate=true
// SerialDevice.begin(119200);//high_baudrate=true
SerialDevice.setTimeout(0);
FastLED.addLeds<WS2812B, DATA_PIN, GRB>(leds, NUM_LEDS);
nfc.begin();
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Arduino 和 PN532 接好 VCC,GND,SDA,SCL;
#### 已测试开发板:
- SparkFun Pro Micro(ATmega32U4),需要发送 DTR/RTS
- SparkFun SAMD21 Dev Breakout(ATSAMD21G18)
- NodeMCU 1.0(ESP-12E + CP2102),SDA=D2,SCL=D1
- NodeMCU 1.0(ESP-12E + CP2102 & CH340),SDA=D2,SCL=D1

#### 引用库:
- [驱动WS2812B FastLED.h](https://github.com/FastLED/FastLED)
Expand Down
2 changes: 1 addition & 1 deletion cmd.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "FastLED.h"
#define NUM_LEDS 6
#define DATA_PIN A3
#define DATA_PIN D4
#define BRI 50
CRGB leds[NUM_LEDS];

Expand Down
23 changes: 13 additions & 10 deletions tools/ReaderTest.ino
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
#include <PN532_I2C.h>
#include <PN532.h>

//#define SerialDevice SerialUSB //32u4,samd21
#define SerialDevice Serial //esp8266

PN532_I2C pn532i2c(Wire);
PN532 nfc(pn532i2c);

Expand All @@ -23,12 +26,12 @@ uint8_t MifareKey[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
#define M2F_B 1

void setup() {
SerialUSB.begin(38400);
SerialUSB.setTimeout(0);
while (!SerialUSB);
SerialDevice.begin(38400);
SerialDevice.setTimeout(0);
while (!SerialDevice);
nfc.begin();
while (!nfc.getFirmwareVersion()) {
SerialUSB.println("Didn't find PN53x board");
SerialDevice.println("Didn't find PN53x board");
delay(2000);
}
nfc.setPassiveActivationRetries(0x10);
Expand All @@ -40,25 +43,25 @@ void loop() {
delay(1000);

if (nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, uid, &uL) && nfc.mifareclassic_AuthenticateBlock(uid, uL, 1, 1, AimeKey)) {
SerialUSB.println("Aime");
SerialDevice.println("Aime");
return;
}
if (nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, uid, &uL) && nfc.mifareclassic_AuthenticateBlock(uid, uL, 1, 0, BanaKey)) {
SerialUSB.println("Bana");
SerialDevice.println("Bana");
return;
}
if (nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, uid, &uL) && nfc.mifareclassic_AuthenticateBlock(uid, uL, M2F_B, 0, MifareKey)) {
SerialUSB.println("Default Key Mifare");
SerialDevice.println("Default Key Mifare");
return;
}
if (nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, uid, &uL)) {
SerialUSB.println("Mifare:Unknown key");
SerialDevice.println("Mifare:Unknown key");
return;
}

if (nfc.felica_Polling(systemCode, requestCode, card.IDm, card.PMm, &systemCodeResponse, 200)) {
SerialUSB.println("Found a Felica card!");
SerialDevice.println("Found a Felica card!");
return;
}
SerialUSB.println("Didn't find card");
SerialDevice.println("Didn't find card");
}

0 comments on commit ae2426f

Please sign in to comment.