Merge r551-563 from trunk.

This commit is contained in:
Romain Tartiere 2010-08-20 10:41:30 +00:00
commit 5b0589c381
4 changed files with 21 additions and 6 deletions

View file

@ -439,6 +439,9 @@ main (int argc, const char *argv[])
exit (EXIT_FAILURE); exit (EXIT_FAILURE);
} }
// Disable ISO14443-4 switching in order to read devices that emulate Mifare Classic with ISO14443-4 compliance.
nfc_configure(pnd, NDO_AUTO_ISO14443_4, false);
printf ("Connected to NFC reader: %s\n", pnd->acName); printf ("Connected to NFC reader: %s\n", pnd->acName);
// Try to find a MIFARE Classic tag // Try to find a MIFARE Classic tag
@ -461,14 +464,14 @@ main (int argc, const char *argv[])
// Compare if key dump UID is the same as the current tag UID // Compare if key dump UID is the same as the current tag UID
if (memcmp (nti.nai.abtUid, pbtUID, 4) != 0) { if (memcmp (nti.nai.abtUid, pbtUID, 4) != 0) {
printf ("Expected MIFARE Classic %cK card with UID: %02x%02x%02x%02x\n", b4K ? '4' : '1', pbtUID[3], pbtUID[2], printf ("Expected MIFARE Classic %ck card with UID: %02x%02x%02x%02x\n", b4K ? '4' : '1', pbtUID[3], pbtUID[2],
pbtUID[1], pbtUID[0]); pbtUID[1], pbtUID[0]);
} }
} }
// Get the info from the current tag // Get the info from the current tag
pbtUID = nti.nai.abtUid; pbtUID = nti.nai.abtUid;
b4K = (nti.nai.abtAtqa[1] == 0x02); b4K = (nti.nai.abtAtqa[1] == 0x02);
printf ("Found MIFARE Classic %cK card with UID: %02x%02x%02x%02x\n", b4K ? '4' : '1', pbtUID[3], pbtUID[2], printf ("Found MIFARE Classic %ck card with UID: %02x%02x%02x%02x\n", b4K ? '4' : '1', pbtUID[3], pbtUID[2],
pbtUID[1], pbtUID[0]); pbtUID[1], pbtUID[0]);
uiBlocks = (b4K) ? 0xff : 0x3f; uiBlocks = (b4K) ? 0xff : 0x3f;

View file

@ -151,7 +151,9 @@ typedef enum {
/** If this option is enabled, frames that carry less than 4 bits are allowed. According to the standards these frames should normally be handles as invalid frames. */ /** If this option is enabled, frames that carry less than 4 bits are allowed. According to the standards these frames should normally be handles as invalid frames. */
NDO_ACCEPT_INVALID_FRAMES = 0x30, NDO_ACCEPT_INVALID_FRAMES = 0x30,
/** If the NFC device should only listen to frames, it could be useful to let it gather multiple frames in a sequence. They will be stored in the internal FIFO of the PN53X chip. This could be retrieved by using the receive data functions. Note that if the chip runs out of bytes (FIFO = 64 bytes long), it will overwrite the first received frames, so quick retrieving of the received data is desirable. */ /** If the NFC device should only listen to frames, it could be useful to let it gather multiple frames in a sequence. They will be stored in the internal FIFO of the PN53X chip. This could be retrieved by using the receive data functions. Note that if the chip runs out of bytes (FIFO = 64 bytes long), it will overwrite the first received frames, so quick retrieving of the received data is desirable. */
NDO_ACCEPT_MULTIPLE_FRAMES = 0x31 NDO_ACCEPT_MULTIPLE_FRAMES = 0x31,
/** This option can be used to enable or disable the auto-switching mode to ISO14443-4 is device is compliant */
NDO_AUTO_ISO14443_4 = 0x40,
} nfc_device_option_t; } nfc_device_option_t;
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////

View file

@ -50,6 +50,9 @@
#define REG_CIU_BIT_FRAMING 0x633D #define REG_CIU_BIT_FRAMING 0x633D
#define SYMBOL_TX_LAST_BITS 0x07 #define SYMBOL_TX_LAST_BITS 0x07
#define SYMBOL_PARAM_fAutomaticRATS 0x10
#define SYMBOL_PARAM_fAutomaticATR_RES 0x04
// Internal parameters flags // Internal parameters flags
#define PARAM_NONE 0x00 #define PARAM_NONE 0x00
#define PARAM_NAD_USED 0x01 #define PARAM_NAD_USED 0x01

View file

@ -313,7 +313,14 @@ bool nfc_configure(nfc_device_t* pnd, const nfc_device_option_t ndo, const bool
btValue = (bEnable) ? SYMBOL_RX_MULTIPLE : 0x00; btValue = (bEnable) ? SYMBOL_RX_MULTIPLE : 0x00;
if (!pn53x_set_reg(pnd,REG_CIU_RX_MODE,SYMBOL_RX_MULTIPLE,btValue)) return false; if (!pn53x_set_reg(pnd,REG_CIU_RX_MODE,SYMBOL_RX_MULTIPLE,btValue)) return false;
return true; return true;
break;
case NDO_AUTO_ISO14443_4:
// TODO: PN53x parameters could not be read, so we have to buffered current value in order to prevent from configuration overwrite
// ATM, buffered current value is not needed due to a single usage of these parameters
btValue = (bEnable) ? (SYMBOL_PARAM_fAutomaticRATS | SYMBOL_PARAM_fAutomaticATR_RES): SYMBOL_PARAM_fAutomaticATR_RES;
if(!pn53x_set_parameters(pnd,btValue)) return false;
return true;
break; break;
} }