PN532 customized
Fork of PN532 by
Revision 10:2fcf2448d199, committed 2016-02-11
- Comitter:
- stanvn
- Date:
- Thu Feb 11 11:56:00 2016 +0000
- Parent:
- 9:70abe4844114
- Commit message:
- Working code for reading type-a and type-b cards
Changed in this revision
PN532.cpp | Show annotated file Show diff for this revision Revisions of this file |
PN532.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/PN532.cpp Wed Feb 10 10:25:02 2016 +0000 +++ b/PN532.cpp Thu Feb 11 11:56:00 2016 +0000 @@ -409,9 +409,10 @@ return 1; } -uint8_t* PN532::sendRequestCommand(uint8_t cardbaudrate, uint16_t timeout){ +int8_t PN532::sendRequestCommand(uint8_t cardbaudrate, uint16_t timeout, uint8_t* answere){ // for the request commands see: http://www.nxp.com/documents/user_manual/141520.pdf // the InListPassiveTarget command is explaned at page 115 + int8_t packageSize = 3; 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; @@ -419,16 +420,20 @@ //printf("tag-type = type b"); pn532_packetbuffer[3] = 0; pn532_packetbuffer[4] = 0x01; + packageSize = 5; } - if (HAL(writeCommand)(pn532_packetbuffer, 5)) { + if (HAL(writeCommand)(pn532_packetbuffer, packageSize)) { return 0x0; // command failed } - // read data packet if (HAL(readResponse)(pn532_packetbuffer, sizeof(pn532_packetbuffer), timeout) < 0) { return 0x0; } + //for(int i = 0; i< 12; i++){ +// printf("%02X ",pn532_packetbuffer[i]); +// } +// printf("\n"); if (pn532_packetbuffer[0] != 1) return 0; // check some basic stuff @@ -442,8 +447,9 @@ b4 SEL_RES b5 NFCID Length b6..NFCIDLen NFCID - */ - return pn532_packetbuffer; + */ + memcpy(answere,pn532_packetbuffer,32); + return 0x01; } /***** Mifare Classic Functions ******/
--- a/PN532.h Wed Feb 10 10:25:02 2016 +0000 +++ b/PN532.h Thu Feb 11 11:56:00 2016 +0000 @@ -148,7 +148,7 @@ bool inDataExchange(uint8_t *send, uint8_t sendLength, uint8_t *response, uint8_t *responseLength); // ISO14443 requestes - uint8_t* sendRequestCommand(uint8_t cardbaudrate, uint16_t timeout); + int8_t sendRequestCommand(uint8_t cardbaudrate, uint16_t timeout, uint8_t* answere); // Mifare Classic functions bool mifareclassic_IsFirstBlock (uint32_t uiBlock);