refactor and split class

move hardware manipulation functions into new class
This commit is contained in:
Rotzbua
2017-05-22 12:25:18 +02:00
parent 9c221e59ee
commit 0b258bfe0f
8 changed files with 299 additions and 242 deletions

View File

@@ -25,11 +25,13 @@
#include <SPI.h>
#include <MFRC522.h>
#include <MFRC522Hack.h>
constexpr uint8_t RST_PIN = 9; // Configurable, see typical pin layout above
constexpr uint8_t SS_PIN = 10; // Configurable, see typical pin layout above
MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance
MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance.
MFRC522Hack mfrc522Hack(&mfrc522); // Create MFRC522Hack instance.
/* Set your new UID here! */
byte newUid[] = {0xDE, 0xAD, 0xBE, 0xEF};
@@ -92,7 +94,7 @@ void loop() {
// }
// Set new UID
if ( mfrc522.MIFARE_SetUid(newUid, (byte)4, true) ) {
if ( mfrc522Hack.MIFARE_SetUid(newUid, (byte)4, true) ) {
Serial.println(F("Wrote new UID to card."));
}

View File

@@ -24,11 +24,13 @@
#include <SPI.h>
#include <MFRC522.h>
#include <MFRC522Hack.h>
constexpr uint8_t RST_PIN = 9; // Configurable, see typical pin layout above
constexpr uint8_t SS_PIN = 10; // Configurable, see typical pin layout above
MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance
MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance.
MFRC522Hack mfrc522Hack(&mfrc522); // Create MFRC522Hack instance.
MFRC522::MIFARE_Key key;
@@ -46,7 +48,7 @@ void setup() {
}
void loop() {
if ( mfrc522.MIFARE_UnbrickUidSector(false) ) {
if ( mfrc522Hack.MIFARE_UnbrickUidSector(false) ) {
Serial.println(F("Cleared sector 0, set UID to 1234. Card should be responsive again now."));
}
delay(1000);