rework the way to determine which command is needed to send/receive a frame as target.
This commit is contained in:
parent
3a1cb72681
commit
676477e20c
1 changed files with 44 additions and 18 deletions
|
@ -1684,17 +1684,30 @@ pn53x_target_receive_bytes (nfc_device_t * pnd, byte_t * pbtRx, size_t * pszRx)
|
||||||
{
|
{
|
||||||
byte_t abtCmd[1];
|
byte_t abtCmd[1];
|
||||||
|
|
||||||
|
// XXX I think this is not a clean way to provide some kind of "EasyFraming"
|
||||||
|
// but at the moment I have no more better than this
|
||||||
if (pnd->bEasyFraming) {
|
if (pnd->bEasyFraming) {
|
||||||
if ((CHIP_DATA (pnd)->current_target->nm.nmt == NMT_DEP) || // If DEP mode
|
switch (CHIP_DATA (pnd)->current_target->nm.nmt) {
|
||||||
((CHIP_DATA(pnd)->type == PN532) && (pnd->bAutoIso14443_4) &&
|
case NMT_DEP:
|
||||||
(CHIP_DATA (pnd)->current_target->nm.nmt == NMT_ISO14443A) && (CHIP_DATA (pnd)->current_target->nti.nai.btSak & SAK_ISO14443_4_COMPLIANT)) // If ISO14443-4 PICC emulation
|
|
||||||
) {
|
|
||||||
abtCmd[0] = TgGetData;
|
abtCmd[0] = TgGetData;
|
||||||
|
break;
|
||||||
|
case NMT_ISO14443A:
|
||||||
|
if (CHIP_DATA (pnd)->current_target->nti.nai.btSak & SAK_ISO14443_4_COMPLIANT) {
|
||||||
|
// We are dealing with a ISO/IEC 14443-4 compliant target
|
||||||
|
if ((CHIP_DATA(pnd)->type == PN532) && (pnd->bAutoIso14443_4)) {
|
||||||
|
// We are using ISO/IEC 14443-4 PICC emulation capability from the PN532
|
||||||
|
abtCmd[0] = TgGetData;
|
||||||
|
break;
|
||||||
} else {
|
} else {
|
||||||
// TODO Support EasyFraming for other cases by software
|
// TODO Support EasyFraming for other cases by software
|
||||||
pnd->iLastError = ENOTIMPL;
|
pnd->iLastError = ENOTIMPL;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
abtCmd[0] = TgGetInitiatorCommand;
|
||||||
|
break;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
abtCmd[0] = TgGetInitiatorCommand;
|
abtCmd[0] = TgGetInitiatorCommand;
|
||||||
}
|
}
|
||||||
|
@ -1762,17 +1775,30 @@ pn53x_target_send_bytes (nfc_device_t * pnd, const byte_t * pbtTx, const size_t
|
||||||
if (!pnd->bPar)
|
if (!pnd->bPar)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
// XXX I think this is not a clean way to provide some kind of "EasyFraming"
|
||||||
|
// but at the moment I have no more better than this
|
||||||
if (pnd->bEasyFraming) {
|
if (pnd->bEasyFraming) {
|
||||||
if ((CHIP_DATA (pnd)->current_target->nm.nmt == NMT_DEP) || // If DEP mode
|
switch (CHIP_DATA (pnd)->current_target->nm.nmt) {
|
||||||
((CHIP_DATA(pnd)->type == PN532) && (pnd->bAutoIso14443_4) &&
|
case NMT_DEP:
|
||||||
(CHIP_DATA (pnd)->current_target->nm.nmt == NMT_ISO14443A) && (CHIP_DATA (pnd)->current_target->nti.nai.btSak & SAK_ISO14443_4_COMPLIANT)) // If ISO14443-4 PICC emulation
|
|
||||||
) {
|
|
||||||
abtCmd[0] = TgSetData;
|
abtCmd[0] = TgSetData;
|
||||||
|
break;
|
||||||
|
case NMT_ISO14443A:
|
||||||
|
if (CHIP_DATA (pnd)->current_target->nti.nai.btSak & SAK_ISO14443_4_COMPLIANT) {
|
||||||
|
// We are dealing with a ISO/IEC 14443-4 compliant target
|
||||||
|
if ((CHIP_DATA(pnd)->type == PN532) && (pnd->bAutoIso14443_4)) {
|
||||||
|
// We are using ISO/IEC 14443-4 PICC emulation capability from the PN532
|
||||||
|
abtCmd[0] = TgSetData;
|
||||||
|
break;
|
||||||
} else {
|
} else {
|
||||||
// TODO Support EasyFraming for other cases by software
|
// TODO Support EasyFraming for other cases by software
|
||||||
pnd->iLastError = ENOTIMPL;
|
pnd->iLastError = ENOTIMPL;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
abtCmd[0] = TgResponseToInitiator;
|
||||||
|
break;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
abtCmd[0] = TgResponseToInitiator;
|
abtCmd[0] = TgResponseToInitiator;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue