1 /**************************************************************************/
5 /**************************************************************************/
9 #include "pn532_mifare.h"
11 bool pn532MifareCmd(const pn532_mifare_cmd_t mc
, const uint8_t ui8Block
, pn532_mifare_param_t
* pmp
)
14 size_t szRx
= sizeof(abtRx
);
19 abtCmd
[0] = mc
; // The MIFARE Classic command
20 abtCmd
[1] = ui8Block
; // The block address (1K=0x00..0x39, 4K=0x00..0xff)
23 // Read and store command have no parameter
24 case PN532_MIFARE_CMD_READ
:
25 case PN532_MIFARE_CMD_STORE
:
29 // Authenticate command
30 case PN532_MIFARE_CMD_AUTH_A
:
31 case PN532_MIFARE_CMD_AUTH_B
:
32 szParamLen
= sizeof (pn532_mifare_param_auth_t
);
36 case PN532_MIFARE_CMD_WRITE
:
37 szParamLen
= sizeof (pn532_mifare_param_data_t
);
41 case PN532_MIFARE_CMD_DECREMENT
:
42 case PN532_MIFARE_CMD_INCREMENT
:
43 case PN532_MIFARE_CMD_TRANSFER
:
44 szParamLen
= sizeof (pn532_mifare_param_value_t
);
47 // Please fix your code, you never should reach this statement
53 // When available, copy the parameter bytes
55 memcpy (abtCmd
+ 2, (byte_t
*) pmp
, szParamLen
);
57 // bEasyFraming = pnd->bEasyFraming;
58 // if (!nfc_configure (pnd, NDO_EASY_FRAMING, true)) {
59 // nfc_perror (pnd, "nfc_configure");
63 // // Fire the mifare command
64 // if (!nfc_initiator_transceive_bytes (pnd, abtCmd, 2 + szParamLen, abtRx, &szRx)) {
65 // if (pnd->iLastError == EINVRXFRAM) {
66 // // "Invalid received frame" AKA EINVRXFRAM, usual means we are
67 // // authenticated on a sector but the requested MIFARE cmd (read, write)
68 // // is not permitted by current acces bytes;
69 // // So there is nothing to do here.
71 // nfc_perror (pnd, "nfc_initiator_transceive_bytes");
73 // nfc_configure (pnd, NDO_EASY_FRAMING, bEasyFraming);
76 // if (!nfc_configure (pnd, NDO_EASY_FRAMING, bEasyFraming)) {
77 // nfc_perror (pnd, "nfc_configure");
81 // // When we have executed a read command, copy the received bytes into the param
82 // if (mc == MC_READ) {
84 // memcpy (pmp->mpd.abtData, abtRx, 16);
90 // Command succesfully executed