Fix ISO/IEC 14443-4 hardware emulation.
NDO_AUTO_ISO14443_4 is now set to _true_ by default with nfc_target_init(); nfc_emulate_target() now fails (return _false_) when emulator->state_machine->io() failed; Initialize nfc_device_t variables to _false_ in order to send correctly (see notes in nfc-device.c); nfc_emulate_forum_tag4 prints error when nfc_emulate_target() failed.
This commit is contained in:
parent
975cd275d1
commit
78ce62e7b6
4 changed files with 20 additions and 11 deletions
|
@ -118,11 +118,10 @@ nfcforum_tag4_io (struct nfc_emulator *emulator, const byte_t *data_in, const si
|
|||
print_hex (data_in, data_in_len);
|
||||
}
|
||||
|
||||
/*
|
||||
* The PN532 already handle RATS
|
||||
*/
|
||||
if ((data_in_len == 2) && (data_in[0] == ISO144434A_RATS))
|
||||
return res;
|
||||
if ((data_in_len == 2) && (data_in[0] == ISO144434A_RATS)) {
|
||||
// The PN532 already handle RATS, so there is nothing to do
|
||||
return res;
|
||||
}
|
||||
|
||||
if(data_in_len >= 4) {
|
||||
if (data_in[CLA] != 0x00)
|
||||
|
@ -352,7 +351,9 @@ main (int argc, char *argv[])
|
|||
printf ("Connected to NFC device: %s\n", pnd->acName);
|
||||
printf ("Emulating NDEF tag now, please touch it with a second NFC device\n");
|
||||
|
||||
nfc_emulate_target (pnd, &emulator); // contains already nfc_target_init() call
|
||||
if (0 != nfc_emulate_target (pnd, &emulator)) { // contains already nfc_target_init() call
|
||||
nfc_perror (pnd, "nfc_emulate_target");
|
||||
}
|
||||
|
||||
nfc_disconnect(pnd);
|
||||
|
||||
|
|
|
@ -41,10 +41,14 @@ nfc_device_new (void)
|
|||
err (EXIT_FAILURE, "nfc_device_new: malloc");
|
||||
}
|
||||
|
||||
res->bCrc = true;
|
||||
res->bPar = true;
|
||||
res->bEasyFraming = true;
|
||||
res->bAutoIso14443_4 = true;
|
||||
// Variables initiatialization
|
||||
// Note: Actually, these initialization will be overwritten while the device
|
||||
// will be setup. Putting them to _false_ while the default is _true_ ensure we
|
||||
// send the command to the chip
|
||||
res->bCrc = false;
|
||||
res->bPar = false;
|
||||
res->bEasyFraming = false;
|
||||
res->bAutoIso14443_4 = false;
|
||||
res->iLastError = 0;
|
||||
res->driver_data = NULL;
|
||||
res->chip_data = NULL;
|
||||
|
|
|
@ -52,5 +52,5 @@ nfc_emulate_target (nfc_device_t* pnd, struct nfc_emulator *emulator)
|
|||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
return (res < 0) ? res : 0;
|
||||
}
|
||||
|
|
|
@ -625,6 +625,7 @@ nfc_initiator_transceive_bits_timed (nfc_device_t * pnd, const byte_t * pbtTx, c
|
|||
* - Crc is handled by the device (NDO_HANDLE_CRC = true)
|
||||
* - Parity is handled the device (NDO_HANDLE_PARITY = true)
|
||||
* - Cryto1 cipher is disabled (NDO_ACTIVATE_CRYPTO1 = false)
|
||||
* - Auto-switching in ISO14443-4 mode is enabled (NDO_AUTO_ISO14443_4 = true)
|
||||
* - Easy framing is disabled (NDO_EASY_FRAMING = false)
|
||||
* - Invalid frames are not accepted (NDO_ACCEPT_INVALID_FRAMES = false)
|
||||
* - Multiple frames are not accepted (NDO_ACCEPT_MULTIPLE_FRAMES = false)
|
||||
|
@ -649,6 +650,9 @@ nfc_target_init (nfc_device_t * pnd, nfc_target_t * pnt, byte_t * pbtRx, size_t
|
|||
return false;
|
||||
if (!nfc_configure (pnd, NDO_HANDLE_PARITY, true))
|
||||
return false;
|
||||
// Activate auto ISO14443-4 switching by default
|
||||
if (!nfc_configure (pnd, NDO_AUTO_ISO14443_4, true))
|
||||
return false;
|
||||
// Activate "easy framing" feature by default
|
||||
if (!nfc_configure (pnd, NDO_EASY_FRAMING, true))
|
||||
return false;
|
||||
|
|
Loading…
Reference in a new issue