Test example

Dependencies:   mbed

Fork of readMifare by Interactive Device Design

Revision:
4:70acff42d8b4
Parent:
3:08251c301e26
Child:
5:4b238fd5f347
--- a/main.cpp	Wed Mar 16 09:52:22 2016 +0000
+++ b/main.cpp	Wed Mar 16 20:05:34 2016 +0000
@@ -40,10 +40,10 @@
 #include "mbed.h"
 #include "Adafruit_PN532.h"
 
-#define MOSI p5
-#define MISO p6
-#define SCK  p7
-#define SS   p8
+#define MOSI p11
+#define MISO p12
+#define SCK  p13
+#define SS   p20
 
 Serial pc(USBTX, USBRX);
 Adafruit_PN532 nfc(SCK, MISO, MOSI, SS);
@@ -105,12 +105,11 @@
       // Try with the factory default KeyA: 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF
       pc.printf("Trying to authenticate block 4 with default KEYA value\r\n");
       uint8_t keya[6] = { 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5 };
-      int block = 128;
       
       // 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, block, 0, keya);
+      success = nfc.mifareclassic_AuthenticateBlock(uid, uidLength, 128, 0, keya);
         
       if (success)
       { 
@@ -118,15 +117,17 @@
             int respSize = 16;
             uint8_t data[respSize];
             
-            success = nfc.mifareclassic_ReadDataBlock(block, data);
+            success = nfc.mifareclassic_ReadDataBlock(128, data);
             
             if (success)
             {
               // Data seems to have been read ... spit it out
-              pc.printf("Reading Block %d:\r\n\t", block);
+              pc.printf("Reading Block %d:\r\n\t", 128);
               nfc.PrintHexChar(data, respSize);
               pc.printf("\r\n");
               
+              
+              
               // Wait a bit before reading the card again
               wait(1);
             }