codestyle and move new code to right pos
- add doc and author
This commit is contained in:
76
MFRC522.cpp
76
MFRC522.cpp
@@ -1110,6 +1110,49 @@ MFRC522::StatusCode MFRC522::MIFARE_SetValue(byte blockAddr, long value) {
|
|||||||
return MIFARE_Write(blockAddr, buffer, 16);
|
return MIFARE_Write(blockAddr, buffer, 16);
|
||||||
} // End MIFARE_SetValue()
|
} // End MIFARE_SetValue()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Authenticate with a NTAG216.
|
||||||
|
*
|
||||||
|
* Only for NTAG216. First implemented by Gargantuanman.
|
||||||
|
*
|
||||||
|
* @param[in] passWord password.
|
||||||
|
* @param[in] pACK result success???.
|
||||||
|
* @return STATUS_OK on success, STATUS_??? otherwise.
|
||||||
|
*/
|
||||||
|
MFRC522::StatusCode MFRC522::PCD_NTAG216_AUTH(byte* passWord, byte pACK[]) //Authenticate with 32bit password
|
||||||
|
{
|
||||||
|
MFRC522::StatusCode result;
|
||||||
|
byte cmdBuffer[18]; // We need room for 16 bytes data and 2 bytes CRC_A.
|
||||||
|
|
||||||
|
cmdBuffer[0] = 0x1B; //Comando de autentificacion
|
||||||
|
|
||||||
|
for (byte i = 0; i<4; i++)
|
||||||
|
cmdBuffer[i+1] = passWord[i];
|
||||||
|
|
||||||
|
result = PCD_CalculateCRC(cmdBuffer, 5, &cmdBuffer[5]);
|
||||||
|
|
||||||
|
if (result!=STATUS_OK) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Transceive the data, store the reply in cmdBuffer[]
|
||||||
|
byte waitIRq = 0x30; // RxIRq and IdleIRq
|
||||||
|
byte cmdBufferSize = sizeof(cmdBuffer);
|
||||||
|
byte validBits = 0;
|
||||||
|
byte rxlength = 5;
|
||||||
|
result = PCD_CommunicateWithPICC(PCD_Transceive, waitIRq, cmdBuffer, 7, cmdBuffer, &rxlength, &validBits);
|
||||||
|
|
||||||
|
pACK[0] = cmdBuffer[0];
|
||||||
|
pACK[1] = cmdBuffer[1];
|
||||||
|
|
||||||
|
if (result!=STATUS_OK) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
return STATUS_OK;
|
||||||
|
} // End PCD_NTAG216_AUTH()
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Support functions
|
// Support functions
|
||||||
/////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
@@ -1768,36 +1811,3 @@ bool MFRC522::PICC_ReadCardSerial() {
|
|||||||
byte result = PICC_Select(&uid);
|
byte result = PICC_Select(&uid);
|
||||||
return (result == STATUS_OK);
|
return (result == STATUS_OK);
|
||||||
} // End
|
} // End
|
||||||
|
|
||||||
MFRC522::StatusCode MFRC522::PCD_NTAG216_AUTH(byte *passWord, byte pACK[]) //Authenticate with 32bit password
|
|
||||||
{
|
|
||||||
MFRC522::StatusCode result;
|
|
||||||
byte cmdBuffer[18]; // We need room for 16 bytes data and 2 bytes CRC_A.
|
|
||||||
|
|
||||||
cmdBuffer[0] = 0x1B; //Comando de autentificacion
|
|
||||||
|
|
||||||
for(byte i = 0; i < 4; i++)
|
|
||||||
cmdBuffer[i + 1] = passWord[i];
|
|
||||||
|
|
||||||
result = PCD_CalculateCRC(cmdBuffer, 5, &cmdBuffer[5]);
|
|
||||||
|
|
||||||
if (result != STATUS_OK) {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Transceive the data, store the reply in cmdBuffer[]
|
|
||||||
byte waitIRq = 0x30; // RxIRq and IdleIRq
|
|
||||||
byte cmdBufferSize = sizeof(cmdBuffer);
|
|
||||||
byte validBits = 0;
|
|
||||||
byte rxlength = 5;
|
|
||||||
result = PCD_CommunicateWithPICC(PCD_Transceive, waitIRq, cmdBuffer, 7, cmdBuffer, &rxlength, &validBits);
|
|
||||||
|
|
||||||
pACK[0] = cmdBuffer[0];
|
|
||||||
pACK[1] = cmdBuffer[1];
|
|
||||||
|
|
||||||
if (result != STATUS_OK) {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
return STATUS_OK;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -373,7 +373,6 @@ public:
|
|||||||
MFRC522::StatusCode MIFARE_GetValue(byte blockAddr, long *value);
|
MFRC522::StatusCode MIFARE_GetValue(byte blockAddr, long *value);
|
||||||
MFRC522::StatusCode MIFARE_SetValue(byte blockAddr, long value);
|
MFRC522::StatusCode MIFARE_SetValue(byte blockAddr, long value);
|
||||||
MFRC522::StatusCode PCD_NTAG216_AUTH(byte *passWord, byte pACK[]);
|
MFRC522::StatusCode PCD_NTAG216_AUTH(byte *passWord, byte pACK[]);
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Support functions
|
// Support functions
|
||||||
|
|||||||
Reference in New Issue
Block a user