Indent whole code using make indent. (Fixes issue 84).
This commit is contained in:
parent
f93b4939f4
commit
18cc86a613
42 changed files with 2613 additions and 2479 deletions
|
|
@ -17,70 +17,70 @@
|
|||
* After a successful authentication it will be possible to execute other commands (e.g. Read/Write).
|
||||
* The MIFARE Classic Specification (http://www.nxp.com/acrobat/other/identification/M001053_MF1ICS50_rev5_3.pdf) explains more about this process.
|
||||
*/
|
||||
bool nfc_initiator_mifare_cmd(nfc_device_t* pnd, const mifare_cmd mc, const uint8_t ui8Block, mifare_param* pmp)
|
||||
bool
|
||||
nfc_initiator_mifare_cmd (nfc_device_t * pnd, const mifare_cmd mc, const uint8_t ui8Block, mifare_param * pmp)
|
||||
{
|
||||
byte_t abtRx[265];
|
||||
size_t szRxLen;
|
||||
size_t szParamLen;
|
||||
byte_t abtCmd[265];
|
||||
byte_t abtRx[265];
|
||||
size_t szRxLen;
|
||||
size_t szParamLen;
|
||||
byte_t abtCmd[265];
|
||||
|
||||
// Make sure we are dealing with a active device
|
||||
if (!pnd->bActive) return false;
|
||||
if (!pnd->bActive)
|
||||
return false;
|
||||
|
||||
abtCmd[0] = mc; // The MIFARE Classic command
|
||||
abtCmd[1] = ui8Block; // The block address (1K=0x00..0x39, 4K=0x00..0xff)
|
||||
abtCmd[0] = mc; // The MIFARE Classic command
|
||||
abtCmd[1] = ui8Block; // The block address (1K=0x00..0x39, 4K=0x00..0xff)
|
||||
|
||||
switch (mc)
|
||||
{
|
||||
switch (mc) {
|
||||
// Read and store command have no parameter
|
||||
case MC_READ:
|
||||
case MC_STORE:
|
||||
szParamLen = 0;
|
||||
case MC_READ:
|
||||
case MC_STORE:
|
||||
szParamLen = 0;
|
||||
break;
|
||||
|
||||
// Authenticate command
|
||||
case MC_AUTH_A:
|
||||
case MC_AUTH_B:
|
||||
szParamLen = sizeof(mifare_param_auth);
|
||||
case MC_AUTH_A:
|
||||
case MC_AUTH_B:
|
||||
szParamLen = sizeof (mifare_param_auth);
|
||||
break;
|
||||
|
||||
// Data command
|
||||
case MC_WRITE:
|
||||
szParamLen = sizeof(mifare_param_data);
|
||||
case MC_WRITE:
|
||||
szParamLen = sizeof (mifare_param_data);
|
||||
break;
|
||||
|
||||
// Value command
|
||||
case MC_DECREMENT:
|
||||
case MC_INCREMENT:
|
||||
case MC_TRANSFER:
|
||||
szParamLen = sizeof(mifare_param_value);
|
||||
case MC_DECREMENT:
|
||||
case MC_INCREMENT:
|
||||
case MC_TRANSFER:
|
||||
szParamLen = sizeof (mifare_param_value);
|
||||
break;
|
||||
|
||||
// Please fix your code, you never should reach this statement
|
||||
default:
|
||||
return false;
|
||||
default:
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
|
||||
// When available, copy the parameter bytes
|
||||
if (szParamLen) memcpy(abtCmd+2,(byte_t*)pmp,szParamLen);
|
||||
if (szParamLen)
|
||||
memcpy (abtCmd + 2, (byte_t *) pmp, szParamLen);
|
||||
|
||||
// Fire the mifare command
|
||||
if (!nfc_initiator_transceive_bytes(pnd,abtCmd,2+szParamLen,abtRx,&szRxLen)) {
|
||||
if (!nfc_initiator_transceive_bytes (pnd, abtCmd, 2 + szParamLen, abtRx, &szRxLen)) {
|
||||
if (pnd->iLastError != 0x14)
|
||||
nfc_perror (pnd, "nfc_initiator_transceive_bytes");
|
||||
nfc_perror (pnd, "nfc_initiator_transceive_bytes");
|
||||
return false;
|
||||
}
|
||||
|
||||
// When we have executed a read command, copy the received bytes into the param
|
||||
if (mc == MC_READ) {
|
||||
if(szRxLen == 16) {
|
||||
memcpy(pmp->mpd.abtData,abtRx,16);
|
||||
if (szRxLen == 16) {
|
||||
memcpy (pmp->mpd.abtData, abtRx, 16);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Command succesfully executed
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue