Inform user if target UID can be emulated

New error: ETGUIDNOTSUP raised when UID is not 4 bytes long or does not start with 0x08 (Security restriction present in the NXP PN53x chips)
This commit is contained in:
Romuald Conty 2011-01-07 16:15:18 +00:00
parent 03963ef535
commit 0f8c23bddd
3 changed files with 24 additions and 14 deletions

View file

@ -147,18 +147,18 @@ CFLAGS="$CFLAGS -std=c99"
CFLAGS="$CFLAGS -Du_int8_t=uint8_t -Du_int16_t=uint16_t"
AC_CONFIG_FILES([
Doxyfile
Makefile
cmake_modules/Makefile
examples/Makefile
include/Makefile
include/nfc/Makefile
libnfc/chips/Makefile
libnfc/buses/Makefile
libnfc/drivers/Makefile
libnfc/Makefile
examples/Makefile
cmake_modules/Makefile
test/Makefile
libnfc.pc
Doxyfile
libnfc/Makefile
libnfc/buses/Makefile
libnfc/chips/Makefile
libnfc/drivers/Makefile
test/Makefile
])
AC_OUTPUT

View file

@ -128,7 +128,7 @@ extern "C" {
#define EDEPUNKCMD 0x12
#define EINVRXFRAM 0x13
#define EMFAUTH 0x14
#define ENSECNOTSUPP 0x18 // PN533
#define ENSECNOTSUPP 0x18 // PN533 only
#define EBCC 0x23
#define EDEPINVSTATE 0x25
#define EOPNOTALL 0x26
@ -140,6 +140,9 @@ extern "C" {
#define EOVCURRENT 0x2d
#define ENAD 0x2e
/* Software level errors */
#define ETGUIDNOTSUP 0x0100 /* Target UID not supported */
/* Common device-level errors */
#define DEIO 0x1000 /* Input/output error */
#define DEINVAL 0x2000 /* Invalid argument */

View file

@ -759,7 +759,9 @@ static struct sErrorMessage {
{ ENFCID3, "NFCID3 Mismatch" },
{ EOVCURRENT, "Over Current" },
{ ENAD, "NAD Missing in DEP Frame" },
/* Driver-level error */
/* Software level errors */
{ ETGUIDNOTSUP, "Target UID not supported" }, // In target mode, PN53x only support 4 bytes UID and the first byte must start with 0x08
/* Driver-level errors */
{ DENACK, "Received NACK" },
{ DEACKMISMATCH, "Expected ACK/NACK" },
{ DEISERRFRAME, "Received an error frame" },
@ -1177,9 +1179,14 @@ pn53x_target_init (nfc_device_t * pnd, nfc_target_t * pnt, byte_t * pbtRx, size_
switch (pnt->nm.nmt) {
case NMT_ISO14443A:
ptm = PTM_PASSIVE_ONLY;
if ((pnt->nti.nai.abtUid[0] != 0x08) || (pnt->nti.nai.szUidLen != 4)) {
pnd->iLastError = ETGUIDNOTSUP;
return false;
}
pn53x_set_parameter(pnd, PARAM_AUTO_ATR_RES, false);
if (pnd->nc == NC_PN532) { // We have a PN532
if ((pnt->nti.nai.btSak & SAK_ISO14443_4_COMPLIANT) && (pnd->bAutoIso14443_4)) { // We have a ISO14443-4 tag to emulate and NDO_AUTO_14443_4A option is enabled
if ((pnt->nti.nai.btSak & SAK_ISO14443_4_COMPLIANT) && (pnd->bAutoIso14443_4)) {
// We have a ISO14443-4 tag to emulate and NDO_AUTO_14443_4A option is enabled
ptm |= PTM_ISO14443_4_PICC_ONLY; // We add ISO14443-4 restriction
pn53x_set_parameter(pnd, PARAM_14443_4_PICC, true);
} else {