Fix nfc-poll, improve pn53x_target_type_t decoding
This commit is contained in:
parent
adba90684d
commit
9d9b5a629e
3 changed files with 35 additions and 17 deletions
|
@ -272,6 +272,7 @@ str_nfc_baud_rate (const nfc_baud_rate_t nbr)
|
||||||
return "424 kbps";
|
return "424 kbps";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -299,4 +300,5 @@ print_nfc_target (const nfc_target_t nt)
|
||||||
print_nfc_dep_info (nt.nti.ndi);
|
print_nfc_dep_info (nt.nti.ndi);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
|
@ -288,7 +288,6 @@ typedef enum {
|
||||||
* @brief NFC modulation type enumeration
|
* @brief NFC modulation type enumeration
|
||||||
*/
|
*/
|
||||||
typedef enum {
|
typedef enum {
|
||||||
NMT_UNKNOWN,
|
|
||||||
NMT_ISO14443A,
|
NMT_ISO14443A,
|
||||||
NMT_ISO14443B,
|
NMT_ISO14443B,
|
||||||
NMT_FELICA,
|
NMT_FELICA,
|
||||||
|
|
|
@ -82,7 +82,7 @@ static const byte_t pn53x_nack_frame[] = { 0x00, 0x00, 0xff, 0xff, 0x00, 0x00 };
|
||||||
static const byte_t pn53x_error_frame[] = { 0x00, 0x00, 0xff, 0x01, 0xff, 0x7f, 0x81, 0x00 };
|
static const byte_t pn53x_error_frame[] = { 0x00, 0x00, 0xff, 0x01, 0xff, 0x7f, 0x81, 0x00 };
|
||||||
|
|
||||||
/* prototypes */
|
/* prototypes */
|
||||||
const nfc_modulation_type_t pn53x_ptt_to_nmt( const pn53x_target_type_t ptt );
|
const nfc_modulation_t pn53x_ptt_to_nm( const pn53x_target_type_t ptt );
|
||||||
const pn53x_modulation_t pn53x_nm_to_pm(const nfc_modulation_t nm);
|
const pn53x_modulation_t pn53x_nm_to_pm(const nfc_modulation_t nm);
|
||||||
const pn53x_target_type_t pn53x_nm_to_ptt(const nfc_modulation_t nm);
|
const pn53x_target_type_t pn53x_nm_to_ptt(const nfc_modulation_t nm);
|
||||||
|
|
||||||
|
@ -653,20 +653,20 @@ pn53x_InAutoPoll (nfc_device_t * pnd,
|
||||||
/* 1st target */
|
/* 1st target */
|
||||||
// Target type
|
// Target type
|
||||||
pn53x_target_type_t ptt = *(pbt++);
|
pn53x_target_type_t ptt = *(pbt++);
|
||||||
pntTargets[0].nm.nmt = pn53x_ptt_to_nmt(ptt);
|
pntTargets[0].nm = pn53x_ptt_to_nm(ptt);
|
||||||
// AutoPollTargetData length
|
// AutoPollTargetData length
|
||||||
ln = *(pbt++);
|
ln = *(pbt++);
|
||||||
pn53x_decode_target_data (pbt, ln, pnd->nc, ptt, &(pntTargets[0].nti));
|
pn53x_decode_target_data (pbt, ln, pnd->nc, pntTargets[0].nm.nmt, &(pntTargets[0].nti));
|
||||||
pbt += ln;
|
pbt += ln;
|
||||||
|
|
||||||
if (abtRx[0] > 1) {
|
if (abtRx[0] > 1) {
|
||||||
/* 2nd target */
|
/* 2nd target */
|
||||||
// Target type
|
// Target type
|
||||||
ptt = *(pbt++);
|
ptt = *(pbt++);
|
||||||
pntTargets[1].nm.nmt = pn53x_ptt_to_nmt(ptt);
|
pntTargets[1].nm = pn53x_ptt_to_nm(ptt);
|
||||||
// AutoPollTargetData length
|
// AutoPollTargetData length
|
||||||
ln = *(pbt++);
|
ln = *(pbt++);
|
||||||
pn53x_decode_target_data (pbt, ln, pnd->nc, ptt, &(pntTargets[1].nti));
|
pn53x_decode_target_data (pbt, ln, pnd->nc, pntTargets[1].nm.nmt, &(pntTargets[1].nti));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1149,6 +1149,11 @@ pn53x_target_init (nfc_device_t * pnd, const nfc_target_mode_t ntm, const nfc_ta
|
||||||
szGB = nt.nti.ndi.szGB;
|
szGB = nt.nti.ndi.szGB;
|
||||||
if (szGB) pbtGB = nt.nti.ndi.abtGB;
|
if (szGB) pbtGB = nt.nti.ndi.abtGB;
|
||||||
break;
|
break;
|
||||||
|
case NMT_ISO14443B:
|
||||||
|
case NMT_JEWEL:
|
||||||
|
pnd->iLastError = DENOTSUP;
|
||||||
|
return false;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!pn53x_TgInitAsTarget(pnd, ntm, pbtMifareParams, pbtFeliCaParams, pbtNFCID3t, pbtGB, szGB, pbtRx, pszRx, NULL)) {
|
if(!pn53x_TgInitAsTarget(pnd, ntm, pbtMifareParams, pbtFeliCaParams, pbtNFCID3t, pbtGB, szGB, pbtRx, pszRx, NULL)) {
|
||||||
|
@ -1377,6 +1382,9 @@ pn53x_nm_to_pm(const nfc_modulation_t nm)
|
||||||
case NBR_424:
|
case NBR_424:
|
||||||
return PM_ISO14443B_424;
|
return PM_ISO14443B_424;
|
||||||
break;
|
break;
|
||||||
|
case NBR_UNDEFINED:
|
||||||
|
// XXX What to do ?
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -1392,49 +1400,58 @@ pn53x_nm_to_pm(const nfc_modulation_t nm)
|
||||||
case NBR_424:
|
case NBR_424:
|
||||||
return PM_FELICA_424;
|
return PM_FELICA_424;
|
||||||
break;
|
break;
|
||||||
|
case NBR_106:
|
||||||
|
case NBR_UNDEFINED:
|
||||||
|
// XXX What to do ?
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME How to handle corner case ?
|
// FIXME How to handle corner case ?
|
||||||
const nfc_modulation_type_t
|
const nfc_modulation_t
|
||||||
pn53x_ptt_to_nmt( const pn53x_target_type_t ptt )
|
pn53x_ptt_to_nm( const pn53x_target_type_t ptt )
|
||||||
{
|
{
|
||||||
switch (ptt) {
|
switch (ptt) {
|
||||||
case PTT_GENERIC_PASSIVE_106:
|
case PTT_GENERIC_PASSIVE_106:
|
||||||
case PTT_GENERIC_PASSIVE_212:
|
case PTT_GENERIC_PASSIVE_212:
|
||||||
case PTT_GENERIC_PASSIVE_424:
|
case PTT_GENERIC_PASSIVE_424:
|
||||||
// XXX This should not happend, how handle it cleanly ?
|
// XXX This should not happend, how handle it cleanly ?
|
||||||
return NMT_UNKNOWN;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PTT_MIFARE:
|
case PTT_MIFARE:
|
||||||
case PTT_ISO14443_4A_106:
|
case PTT_ISO14443_4A_106:
|
||||||
return NMT_ISO14443A;
|
return (const nfc_modulation_t){ .nmt = NMT_ISO14443A, .nbr = NBR_106 };
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PTT_ISO14443_4B_106:
|
case PTT_ISO14443_4B_106:
|
||||||
case PTT_ISO14443_4B_TCL_106:
|
case PTT_ISO14443_4B_TCL_106:
|
||||||
return NMT_ISO14443B;
|
return (const nfc_modulation_t){ .nmt = NMT_ISO14443B, .nbr = NBR_106 };
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PTT_JEWEL_106:
|
case PTT_JEWEL_106:
|
||||||
return NMT_JEWEL;
|
return (const nfc_modulation_t){ .nmt = NMT_JEWEL, .nbr = NBR_106 };
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PTT_FELICA_212:
|
case PTT_FELICA_212:
|
||||||
|
return (const nfc_modulation_t){ .nmt = NMT_FELICA, .nbr = NBR_212 };
|
||||||
|
break;
|
||||||
case PTT_FELICA_424:
|
case PTT_FELICA_424:
|
||||||
return NMT_FELICA;
|
return (const nfc_modulation_t){ .nmt = NMT_FELICA, .nbr = NBR_424 };
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PTT_DEP_PASSIVE_106:
|
case PTT_DEP_PASSIVE_106:
|
||||||
case PTT_DEP_PASSIVE_212:
|
|
||||||
case PTT_DEP_PASSIVE_424:
|
|
||||||
case PTT_DEP_ACTIVE_106:
|
case PTT_DEP_ACTIVE_106:
|
||||||
|
return (const nfc_modulation_t){ .nmt = NMT_DEP, .nbr = NBR_106 };
|
||||||
|
break;
|
||||||
|
case PTT_DEP_PASSIVE_212:
|
||||||
case PTT_DEP_ACTIVE_212:
|
case PTT_DEP_ACTIVE_212:
|
||||||
|
return (const nfc_modulation_t){ .nmt = NMT_DEP, .nbr = NBR_212 };
|
||||||
|
break;
|
||||||
|
case PTT_DEP_PASSIVE_424:
|
||||||
case PTT_DEP_ACTIVE_424:
|
case PTT_DEP_ACTIVE_424:
|
||||||
return NMT_DEP;
|
return (const nfc_modulation_t){ .nmt = NMT_DEP, .nbr = NBR_424 };
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue