examples/nfc-emulate-forum-tag4: this example now fails with ENOTSUPP when used with a non-PN532 chip.

This commit is contained in:
Romuald Conty 2011-06-27 09:14:19 +00:00
parent 7b6baafd1d
commit 0b42cbfb8f
2 changed files with 16 additions and 10 deletions

View file

@ -112,17 +112,17 @@ nfcforum_tag4_io (struct nfc_emulator *emulator, const byte_t *data_in, const si
struct nfcforum_tag4_ndef_data *ndef_data = (struct nfcforum_tag4_ndef_data *)(emulator->user_data);
struct nfcforum_tag4_state_machine_data *state_machine_data = (struct nfcforum_tag4_state_machine_data *)(emulator->state_machine->data);
if (data_in_len == 0) {
// No input data, nothing to do
return res;
}
// Show transmitted command
if (!quiet_output) {
printf (" In: ");
print_hex (data_in, data_in_len);
}
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)
return -ENOTSUP;
@ -168,7 +168,6 @@ nfcforum_tag4_io (struct nfc_emulator *emulator, const byte_t *data_in, const si
return -ENOTSUP;
}
break;
case ISO7816_READ_BINARY:
if ((size_t)(data_in[LC] + 2) > data_out_len) {
@ -210,12 +209,13 @@ nfcforum_tag4_io (struct nfc_emulator *emulator, const byte_t *data_in, const si
// Show transmitted command
if (!quiet_output) {
if (res < 0) {
ERR ("%s (%d)", strerror (-res), -res);
} else {
printf (" Out: ");
if (res < 0)
printf ("No data (returning with an error %d)\n", res);
else
print_hex (data_out, res);
}
}
return res;
}

View file

@ -1629,6 +1629,12 @@ pn53x_target_init (nfc_device_t * pnd, nfc_target_t * pnt, byte_t * pbtRx, size_
}
CHIP_DATA (pnd)->current_target = malloc (sizeof(nfc_target_t));
memcpy (CHIP_DATA (pnd)->current_target, pnt, sizeof(nfc_target_t));
if (ptm & PTM_ISO14443_4_PICC_ONLY) {
// When PN532 is in PICC target mode, it automatically reply to RATS so
// we don't need to forward this command
*pszRx = 0;
}
}
}