Change some nfc_target_mode_t to insist on the restrictions offer these mode

This commit is contained in:
Romuald Conty 2010-10-13 11:35:28 +00:00
parent 572499f598
commit 0fe30e3db7
7 changed files with 12 additions and 12 deletions

View file

@ -87,7 +87,7 @@ main (int argc, const char *argv[])
printf ("NFC device will now act as this D.E.P. target:\n");
print_nfc_dep_info ( nt.nti.ndi );
printf ("Waiting for initiator request...\n");
if(!nfc_target_init (pnd, NTM_DEP, nt, abtRx, &szRx)) {
if(!nfc_target_init (pnd, NTM_DEP_ONLY, nt, abtRx, &szRx)) {
nfc_perror(pnd, "nfc_target_init");
return EXIT_FAILURE;
}

View file

@ -120,7 +120,7 @@ main (int argc, char *argv[])
.nti.nai.szAtsLen = 0,
};
if (!nfc_target_init (pnd, NTM_ISO14443_4_PICC, nt, abtRx, &szRx)) {
if (!nfc_target_init (pnd, NTM_ISO14443_4_PICC_ONLY, nt, abtRx, &szRx)) {
nfc_perror (pnd, "nfc_target_init");
ERR("Could not come out of auto-emulation, no command was received");
return EXIT_FAILURE;

View file

@ -118,7 +118,7 @@ nfc_target_emulate_tag(nfc_device_t* pnd, const nfc_target_t nt)
byte_t abtTx[MAX_FRAME_LEN];
bool loop = true;
if (!nfc_target_init (pnd, NTM_PASSIVE, nt, abtRx, &szRx)) {
if (!nfc_target_init (pnd, NTM_PASSIVE_ONLY, nt, abtRx, &szRx)) {
nfc_perror (pnd, "nfc_target_init");
return false;
}

View file

@ -139,7 +139,7 @@ main (int argc, char *argv[])
.nti.nai.szUidLen = 4,
.nti.nai.szAtsLen = 0,
};
if (!nfc_target_init (pnd, NTM_PASSIVE, nt, abtRecv, &szRecvBits)) {
if (!nfc_target_init (pnd, NTM_PASSIVE_ONLY, nt, abtRecv, &szRecvBits)) {
ERR ("Could not come out of auto-emulation, no command was received");
exit(EXIT_FAILURE);
}

View file

@ -135,7 +135,7 @@ main (int argc, char *argv[])
.nti.nai.szAtsLen = 0,
};
if (!nfc_target_init (pndTag, NTM_PASSIVE, nt, abtReaderRx, &szReaderRxBits)) {
if (!nfc_target_init (pndTag, NTM_PASSIVE_ONLY, nt, abtReaderRx, &szReaderRxBits)) {
ERR ("%s", "Initialization of NFC emulator failed");
nfc_disconnect (pndTag);
return EXIT_FAILURE;

View file

@ -245,7 +245,7 @@ typedef struct {
*/
typedef struct {
/** abtPupi store PUPI contained in ATQB (Answer To reQuest of type B) (see ISO14443-3) */
byte_t abtPupi[4];
byte_t abtPupi[4];
/** abtApplicationData store Application Data contained in ATQB (see ISO14443-3) */
byte_t abtApplicationData[4];
/** abtProtocolInfo store Protocol Info contained in ATQB (see ISO14443-3) */
@ -283,11 +283,11 @@ typedef enum {
/** Configure the PN53x to accept all initiator mode */
NTM_NORMAL = 0x00,
/** Configure the PN53x to accept to be initialized only in passive mode */
NTM_PASSIVE = 0x01,
NTM_PASSIVE_ONLY = 0x01,
/** Configure the PN53x to accept to be initialized only as DEP target */
NTM_DEP = 0x02,
NTM_DEP_ONLY = 0x02,
/** Configure the PN532 to accept to be initialized only as ISO/IEC14443-4 PICC */
NTM_ISO14443_4_PICC = 0x04
NTM_ISO14443_4_PICC_ONLY = 0x04
} nfc_target_mode_t;
/**

View file

@ -1026,17 +1026,17 @@ pn53x_target_init (nfc_device_t * pnd, const nfc_target_mode_t ntm, const nfc_ta
// XXX I (Romuald) don't think that a good thing to select NDO_EASY_FRAMING here, that's a user choice...
switch(ntm)
{
case NTM_PASSIVE:
case NTM_PASSIVE_ONLY:
pn53x_set_parameter(pnd, PARAM_AUTO_ATR_RES, false);
pn53x_configure(pnd, NDO_EASY_FRAMING, false);
break;
case NTM_DEP:
case NTM_DEP_ONLY:
pn53x_set_parameter(pnd, PARAM_AUTO_ATR_RES, true);
pn53x_configure(pnd, NDO_EASY_FRAMING, true);
break;
case NTM_ISO14443_4_PICC:
case NTM_ISO14443_4_PICC_ONLY:
if(pnd->nc != NC_PN532) {
// This mode is not supported by pn531 neither pn533
pnd->iLastError = DENOTSUP;