Fork of PN532 by Components

Revision:
9:70abe4844114
Parent:
8:30bba738e292
Child:
10:2fcf2448d199
diff -r 30bba738e292 -r 70abe4844114 PN532.cpp
--- a/PN532.cpp	Wed Feb 10 08:41:44 2016 +0000
+++ b/PN532.cpp	Wed Feb 10 10:25:02 2016 +0000
@@ -409,6 +409,42 @@
     return 1;
 }
 
+uint8_t* PN532::sendRequestCommand(uint8_t cardbaudrate, uint16_t timeout){
+    // for the request commands see: http://www.nxp.com/documents/user_manual/141520.pdf
+    // the InListPassiveTarget command is explaned at page 115
+    pn532_packetbuffer[0] = PN532_COMMAND_INLISTPASSIVETARGET;
+    pn532_packetbuffer[1] = 1;  // max 1 cards at once (we can set this to 2 later)
+    pn532_packetbuffer[2] = cardbaudrate;
+    if(cardbaudrate == PN532_MIFARE_ISO14443B){
+        //printf("tag-type = type b");
+        pn532_packetbuffer[3] = 0;
+        pn532_packetbuffer[4] = 0x01;
+    }
+
+    if (HAL(writeCommand)(pn532_packetbuffer, 5)) {
+        return 0x0;  // command failed
+    }
+
+    // read data packet
+    if (HAL(readResponse)(pn532_packetbuffer, sizeof(pn532_packetbuffer), timeout) < 0) {
+        return 0x0;
+    }
+    if (pn532_packetbuffer[0] != 1)
+        return 0;
+    // check some basic stuff
+    /* ISO14443A card response should be in the following format:
+
+      byte            Description
+      -------------   ------------------------------------------
+      b0              Tags Found
+      b1              Tag Number (only one used in this example)
+      b2..3           SENS_RES
+      b4              SEL_RES
+      b5              NFCID Length
+      b6..NFCIDLen    NFCID
+    */
+    return pn532_packetbuffer;
+}
 /***** Mifare Classic Functions ******/
 
 /**************************************************************************/
@@ -438,6 +474,7 @@
         return ((uiBlock + 1) % 4 == 0);
     else
         return ((uiBlock + 1) % 16 == 0);
+        
 }
 
 /**************************************************************************/