list_targets support for ASK CTS512B (no anticol support yet)
This commit is contained in:
parent
53f1acfdcb
commit
ab54a37678
6 changed files with 88 additions and 54 deletions
|
@ -199,30 +199,30 @@ main (int argc, const char *argv[])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
nm.nmt = NMT_ISO14443B3SR;
|
nm.nmt = NMT_ISO14443B2SR;
|
||||||
nm.nbr = NBR_106;
|
nm.nbr = NBR_106;
|
||||||
// List ISO14443B-3 ST SRx family targets
|
// List ISO14443B-2 ST SRx family targets
|
||||||
if (nfc_initiator_list_passive_targets (pnd, nm, ant, MAX_TARGET_COUNT, &szTargetFound)) {
|
if (nfc_initiator_list_passive_targets (pnd, nm, ant, MAX_TARGET_COUNT, &szTargetFound)) {
|
||||||
size_t n;
|
size_t n;
|
||||||
if (verbose || (szTargetFound > 0)) {
|
if (verbose || (szTargetFound > 0)) {
|
||||||
printf ("%d ISO14443B-3 ST SRx passive target(s) found%s\n", (int) szTargetFound, (szTargetFound == 0) ? ".\n" : ":");
|
printf ("%d ISO14443B-2 ST SRx passive target(s) found%s\n", (int) szTargetFound, (szTargetFound == 0) ? ".\n" : ":");
|
||||||
}
|
}
|
||||||
for (n = 0; n < szTargetFound; n++) {
|
for (n = 0; n < szTargetFound; n++) {
|
||||||
print_nfc_iso14443b3sr_info (ant[n].nti.nsi, verbose);
|
print_nfc_iso14443b2sr_info (ant[n].nti.nsi, verbose);
|
||||||
printf ("\n");
|
printf ("\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
nm.nmt = NMT_ISO14443B3CT;
|
nm.nmt = NMT_ISO14443B2CT;
|
||||||
nm.nbr = NBR_106;
|
nm.nbr = NBR_106;
|
||||||
// List ISO14443B-3 ASK CTx family targets
|
// List ISO14443B-2 ASK CTx family targets
|
||||||
if (nfc_initiator_list_passive_targets (pnd, nm, ant, MAX_TARGET_COUNT, &szTargetFound)) {
|
if (nfc_initiator_list_passive_targets (pnd, nm, ant, MAX_TARGET_COUNT, &szTargetFound)) {
|
||||||
size_t n;
|
size_t n;
|
||||||
if (verbose || (szTargetFound > 0)) {
|
if (verbose || (szTargetFound > 0)) {
|
||||||
printf ("%d ISO14443B-3 ASK CTx passive target(s) found%s\n", (int) szTargetFound, (szTargetFound == 0) ? ".\n" : ":");
|
printf ("%d ISO14443B-2 ASK CTx passive target(s) found%s\n", (int) szTargetFound, (szTargetFound == 0) ? ".\n" : ":");
|
||||||
}
|
}
|
||||||
for (n = 0; n < szTargetFound; n++) {
|
for (n = 0; n < szTargetFound; n++) {
|
||||||
print_nfc_iso14443b3ct_info (ant[n].nti.nci, verbose);
|
print_nfc_iso14443b2ct_info (ant[n].nti.nci, verbose);
|
||||||
printf ("\n");
|
printf ("\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -632,17 +632,22 @@ print_nfc_iso14443bi_info (const nfc_iso14443bi_info_t nii, bool verbose)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
print_nfc_iso14443b3sr_info (const nfc_iso14443b3sr_info_t nsi, bool verbose)
|
print_nfc_iso14443b2sr_info (const nfc_iso14443b2sr_info_t nsi, bool verbose)
|
||||||
{
|
{
|
||||||
printf (" UID: ");
|
printf (" UID: ");
|
||||||
print_hex (nsi.abtUID, 8);
|
print_hex (nsi.abtUID, 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
print_nfc_iso14443b3ct_info (const nfc_iso14443b3ct_info_t nci, bool verbose)
|
print_nfc_iso14443b2ct_info (const nfc_iso14443b2ct_info_t nci, bool verbose)
|
||||||
{
|
{
|
||||||
printf (" Data: ");
|
uint32_t uid;
|
||||||
print_hex (nci.abtData, nci.szDataLen);
|
uid = (nci.abtUID[3] << 24) + (nci.abtUID[2] << 16) + (nci.abtUID[1] << 8) + nci.abtUID[0];
|
||||||
|
printf (" UID: ");
|
||||||
|
print_hex (nci.abtUID, sizeof(nci.abtUID));
|
||||||
|
printf (" UID (decimal): %010u\n", uid);
|
||||||
|
printf (" Product Code: %02X\n", nci.btProdCode);
|
||||||
|
printf (" Fab Code: %02X\n", nci.btFabCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -754,13 +759,13 @@ print_nfc_target (const nfc_target_t nt, bool verbose)
|
||||||
printf ("ISO/IEC 14443-4B' (%s) target:\n", str_nfc_baud_rate(nt.nm.nbr));
|
printf ("ISO/IEC 14443-4B' (%s) target:\n", str_nfc_baud_rate(nt.nm.nbr));
|
||||||
print_nfc_iso14443bi_info (nt.nti.nii, verbose);
|
print_nfc_iso14443bi_info (nt.nti.nii, verbose);
|
||||||
break;
|
break;
|
||||||
case NMT_ISO14443B3SR:
|
case NMT_ISO14443B2SR:
|
||||||
printf ("ISO/IEC 14443-3B ST SRx (%s) target:\n", str_nfc_baud_rate(nt.nm.nbr));
|
printf ("ISO/IEC 14443-2B ST SRx (%s) target:\n", str_nfc_baud_rate(nt.nm.nbr));
|
||||||
print_nfc_iso14443b3sr_info (nt.nti.nsi, verbose);
|
print_nfc_iso14443b2sr_info (nt.nti.nsi, verbose);
|
||||||
break;
|
break;
|
||||||
case NMT_ISO14443B3CT:
|
case NMT_ISO14443B2CT:
|
||||||
printf ("ISO/IEC 14443-3B ASK CTx (%s) target:\n", str_nfc_baud_rate(nt.nm.nbr));
|
printf ("ISO/IEC 14443-2B ASK CTx (%s) target:\n", str_nfc_baud_rate(nt.nm.nbr));
|
||||||
print_nfc_iso14443b3ct_info (nt.nti.nci, verbose);
|
print_nfc_iso14443b2ct_info (nt.nti.nci, verbose);
|
||||||
break;
|
break;
|
||||||
case NMT_DEP:
|
case NMT_DEP:
|
||||||
printf ("D.E.P. (%s) target:\n", str_nfc_baud_rate(nt.nm.nbr));
|
printf ("D.E.P. (%s) target:\n", str_nfc_baud_rate(nt.nm.nbr));
|
||||||
|
|
|
@ -89,8 +89,8 @@ void print_hex_par (const byte_t * pbtData, const size_t szBits, const byte_t
|
||||||
void print_nfc_iso14443a_info (const nfc_iso14443a_info_t nai, bool verbose);
|
void print_nfc_iso14443a_info (const nfc_iso14443a_info_t nai, bool verbose);
|
||||||
void print_nfc_iso14443b_info (const nfc_iso14443b_info_t nbi, bool verbose);
|
void print_nfc_iso14443b_info (const nfc_iso14443b_info_t nbi, bool verbose);
|
||||||
void print_nfc_iso14443bi_info (const nfc_iso14443bi_info_t nii, bool verbose);
|
void print_nfc_iso14443bi_info (const nfc_iso14443bi_info_t nii, bool verbose);
|
||||||
void print_nfc_iso14443b3sr_info (const nfc_iso14443b3sr_info_t nsi, bool verbose);
|
void print_nfc_iso14443b2sr_info (const nfc_iso14443b2sr_info_t nsi, bool verbose);
|
||||||
void print_nfc_iso14443b3ct_info (const nfc_iso14443b3ct_info_t nci, bool verbose);
|
void print_nfc_iso14443b2ct_info (const nfc_iso14443b2ct_info_t nci, bool verbose);
|
||||||
void print_nfc_felica_info (const nfc_felica_info_t nfi, bool verbose);
|
void print_nfc_felica_info (const nfc_felica_info_t nfi, bool verbose);
|
||||||
void print_nfc_jewel_info (const nfc_jewel_info_t nji, bool verbose);
|
void print_nfc_jewel_info (const nfc_jewel_info_t nji, bool verbose);
|
||||||
void print_nfc_dep_info (const nfc_dep_info_t ndi, bool verbose);
|
void print_nfc_dep_info (const nfc_dep_info_t ndi, bool verbose);
|
||||||
|
|
|
@ -245,21 +245,22 @@ typedef struct {
|
||||||
} nfc_iso14443bi_info_t;
|
} nfc_iso14443bi_info_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @struct nfc_iso14443b3sr_info_t
|
* @struct nfc_iso14443b2sr_info_t
|
||||||
* @brief NFC ISO14443-3B ST SRx tag information
|
* @brief NFC ISO14443-2B ST SRx tag information
|
||||||
*/
|
*/
|
||||||
typedef struct {
|
typedef struct {
|
||||||
byte_t abtUID[8];
|
byte_t abtUID[8];
|
||||||
} nfc_iso14443b3sr_info_t;
|
} nfc_iso14443b2sr_info_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @struct nfc_iso14443b3ct_info_t
|
* @struct nfc_iso14443b2ct_info_t
|
||||||
* @brief NFC ISO14443-3B ASK CTx tag information
|
* @brief NFC ISO14443-2B ASK CTx tag information
|
||||||
*/
|
*/
|
||||||
typedef struct {
|
typedef struct {
|
||||||
byte_t abtData[256]; // No idea what data to expect...
|
byte_t abtUID[4];
|
||||||
size_t szDataLen;
|
byte_t btProdCode;
|
||||||
} nfc_iso14443b3ct_info_t;
|
byte_t btFabCode;
|
||||||
|
} nfc_iso14443b2ct_info_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @struct nfc_jewel_info_t
|
* @struct nfc_jewel_info_t
|
||||||
|
@ -279,8 +280,8 @@ typedef union {
|
||||||
nfc_felica_info_t nfi;
|
nfc_felica_info_t nfi;
|
||||||
nfc_iso14443b_info_t nbi;
|
nfc_iso14443b_info_t nbi;
|
||||||
nfc_iso14443bi_info_t nii;
|
nfc_iso14443bi_info_t nii;
|
||||||
nfc_iso14443b3sr_info_t nsi;
|
nfc_iso14443b2sr_info_t nsi;
|
||||||
nfc_iso14443b3ct_info_t nci;
|
nfc_iso14443b2ct_info_t nci;
|
||||||
nfc_jewel_info_t nji;
|
nfc_jewel_info_t nji;
|
||||||
nfc_dep_info_t ndi;
|
nfc_dep_info_t ndi;
|
||||||
} nfc_target_info_t;
|
} nfc_target_info_t;
|
||||||
|
@ -306,8 +307,8 @@ typedef enum {
|
||||||
NMT_JEWEL,
|
NMT_JEWEL,
|
||||||
NMT_ISO14443B,
|
NMT_ISO14443B,
|
||||||
NMT_ISO14443BI, // pre-ISO14443B aka ISO/IEC 14443 B' or Type B'
|
NMT_ISO14443BI, // pre-ISO14443B aka ISO/IEC 14443 B' or Type B'
|
||||||
NMT_ISO14443B3SR, // ISO14443-3B ST SRx
|
NMT_ISO14443B2SR, // ISO14443-2B ST SRx
|
||||||
NMT_ISO14443B3CT, // ISO14443-3B ASK CTx
|
NMT_ISO14443B2CT, // ISO14443-2B ASK CTx
|
||||||
NMT_FELICA,
|
NMT_FELICA,
|
||||||
NMT_DEP,
|
NMT_DEP,
|
||||||
} nfc_modulation_type_t;
|
} nfc_modulation_type_t;
|
||||||
|
|
|
@ -397,17 +397,22 @@ pn53x_decode_target_data (const byte_t * pbtRawData, size_t szRawData, pn53x_typ
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NMT_ISO14443B3SR:
|
case NMT_ISO14443B2SR:
|
||||||
// Store the UID
|
// Store the UID
|
||||||
memcpy (pnti->nsi.abtUID, pbtRawData, 8);
|
memcpy (pnti->nsi.abtUID, pbtRawData, 8);
|
||||||
pbtRawData += 8;
|
pbtRawData += 8;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NMT_ISO14443B3CT:
|
case NMT_ISO14443B2CT:
|
||||||
// Store the unknown data as one blob for now
|
// Store UID LSB
|
||||||
memcpy (pnti->nci.abtData, pbtRawData, szRawData);
|
memcpy (pnti->nci.abtUID, pbtRawData, 2);
|
||||||
pbtRawData += szRawData;
|
pbtRawData += 2;
|
||||||
pnti->nci.szDataLen = szRawData;
|
// Store Prod Code & Fab Code
|
||||||
|
pnti->nci.btProdCode = *(pbtRawData++);
|
||||||
|
pnti->nci.btFabCode = *(pbtRawData++);
|
||||||
|
// Store UID MSB
|
||||||
|
memcpy (pnti->nci.abtUID+2, pbtRawData, 2);
|
||||||
|
pbtRawData += 2;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NMT_FELICA:
|
case NMT_FELICA:
|
||||||
|
@ -844,7 +849,7 @@ pn53x_initiator_select_passive_target (nfc_device_t * pnd,
|
||||||
byte_t abtTargetsData[PN53x_EXTENDED_FRAME__DATA_MAX_LEN];
|
byte_t abtTargetsData[PN53x_EXTENDED_FRAME__DATA_MAX_LEN];
|
||||||
size_t szTargetsData = sizeof(abtTargetsData);
|
size_t szTargetsData = sizeof(abtTargetsData);
|
||||||
|
|
||||||
if (nm.nmt == NMT_ISO14443BI || nm.nmt == NMT_ISO14443B3SR || nm.nmt == NMT_ISO14443B3CT) {
|
if (nm.nmt == NMT_ISO14443BI || nm.nmt == NMT_ISO14443B2SR || nm.nmt == NMT_ISO14443B2CT) {
|
||||||
// No native support in InListPassiveTarget so we do discovery by hand
|
// No native support in InListPassiveTarget so we do discovery by hand
|
||||||
if (!nfc_configure (pnd, NDO_FORCE_ISO14443_B, true)) {
|
if (!nfc_configure (pnd, NDO_FORCE_ISO14443_B, true)) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -856,7 +861,7 @@ pn53x_initiator_select_passive_target (nfc_device_t * pnd,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
pnd->bEasyFraming = false;
|
pnd->bEasyFraming = false;
|
||||||
if (nm.nmt == NMT_ISO14443B3SR) {
|
if (nm.nmt == NMT_ISO14443B2SR) {
|
||||||
// Some work to do before getting the UID...
|
// Some work to do before getting the UID...
|
||||||
byte_t abtInitiate[]="\x06\x00";
|
byte_t abtInitiate[]="\x06\x00";
|
||||||
size_t szInitiateLen = 2;
|
size_t szInitiateLen = 2;
|
||||||
|
@ -873,9 +878,32 @@ pn53x_initiator_select_passive_target (nfc_device_t * pnd,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (nm.nmt == NMT_ISO14443B2CT) {
|
||||||
|
// Some work to do before getting the UID...
|
||||||
|
byte_t abtReqt[]="\x10";
|
||||||
|
size_t szReqtLen = 1;
|
||||||
|
byte_t abtRx[2];
|
||||||
|
size_t szRxLen = 2;
|
||||||
|
// Getting product code / fab code & store it in output buffer after the serial nr we'll obtain later
|
||||||
|
if (!pn53x_initiator_transceive_bytes (pnd, abtReqt, szReqtLen, abtTargetsData+2, &szTargetsData) || szTargetsData != 2) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (!pn53x_initiator_transceive_bytes (pnd, pbtInitData, szInitData, abtTargetsData, &szTargetsData)) {
|
if (!pn53x_initiator_transceive_bytes (pnd, pbtInitData, szInitData, abtTargetsData, &szTargetsData)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (nm.nmt == NMT_ISO14443B2CT) {
|
||||||
|
if (szTargetsData != 2)
|
||||||
|
return false;
|
||||||
|
byte_t abtRead[]="\xC4"; // Reading UID_MSB (Read address 4)
|
||||||
|
size_t szReadLen = 1;
|
||||||
|
byte_t abtRx[2];
|
||||||
|
size_t szRxLen = 2;
|
||||||
|
if (!pn53x_initiator_transceive_bytes (pnd, abtRead, szReadLen, abtTargetsData+4, &szTargetsData) || szTargetsData != 2) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
szTargetsData = 6; // u16 UID_LSB, u8 prod code, u8 fab code, u16 UID_MSB
|
||||||
|
}
|
||||||
if (pnt) {
|
if (pnt) {
|
||||||
pnt->nm = nm;
|
pnt->nm = nm;
|
||||||
// Fill the tag info struct with the values corresponding to this init modulation
|
// Fill the tag info struct with the values corresponding to this init modulation
|
||||||
|
@ -1416,8 +1444,8 @@ pn53x_target_init (nfc_device_t * pnd, nfc_target_t * pnt, byte_t * pbtRx, size_
|
||||||
break;
|
break;
|
||||||
case NMT_ISO14443B:
|
case NMT_ISO14443B:
|
||||||
case NMT_ISO14443BI:
|
case NMT_ISO14443BI:
|
||||||
case NMT_ISO14443B3SR:
|
case NMT_ISO14443B2SR:
|
||||||
case NMT_ISO14443B3CT:
|
case NMT_ISO14443B2CT:
|
||||||
case NMT_JEWEL:
|
case NMT_JEWEL:
|
||||||
pnd->iLastError = DENOTSUP;
|
pnd->iLastError = DENOTSUP;
|
||||||
return false;
|
return false;
|
||||||
|
@ -1518,8 +1546,8 @@ pn53x_target_init (nfc_device_t * pnd, nfc_target_t * pnt, byte_t * pbtRx, size_
|
||||||
break;
|
break;
|
||||||
case NMT_ISO14443B:
|
case NMT_ISO14443B:
|
||||||
case NMT_ISO14443BI:
|
case NMT_ISO14443BI:
|
||||||
case NMT_ISO14443B3SR:
|
case NMT_ISO14443B2SR:
|
||||||
case NMT_ISO14443B3CT:
|
case NMT_ISO14443B2CT:
|
||||||
case NMT_JEWEL:
|
case NMT_JEWEL:
|
||||||
pnd->iLastError = DENOTSUP;
|
pnd->iLastError = DENOTSUP;
|
||||||
return false;
|
return false;
|
||||||
|
@ -2307,8 +2335,8 @@ pn53x_nm_to_pm(const nfc_modulation_t nm)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NMT_ISO14443BI:
|
case NMT_ISO14443BI:
|
||||||
case NMT_ISO14443B3SR:
|
case NMT_ISO14443B2SR:
|
||||||
case NMT_ISO14443B3CT:
|
case NMT_ISO14443B2CT:
|
||||||
case NMT_DEP:
|
case NMT_DEP:
|
||||||
// Nothing to do...
|
// Nothing to do...
|
||||||
break;
|
break;
|
||||||
|
@ -2409,8 +2437,8 @@ pn53x_nm_to_ptt(const nfc_modulation_t nm)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NMT_ISO14443BI:
|
case NMT_ISO14443BI:
|
||||||
case NMT_ISO14443B3SR:
|
case NMT_ISO14443B2SR:
|
||||||
case NMT_ISO14443B3CT:
|
case NMT_ISO14443B2CT:
|
||||||
case NMT_DEP:
|
case NMT_DEP:
|
||||||
// Nothing to do...
|
// Nothing to do...
|
||||||
break;
|
break;
|
||||||
|
|
12
libnfc/nfc.c
12
libnfc/nfc.c
|
@ -380,16 +380,16 @@ nfc_initiator_list_passive_targets (nfc_device_t * pnd,
|
||||||
szInitDataLen = 4;
|
szInitDataLen = 4;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case NMT_ISO14443B3SR: {
|
case NMT_ISO14443B2SR: {
|
||||||
// Get_UID
|
// Get_UID
|
||||||
pbtInitData = (byte_t *) "\x0b";
|
pbtInitData = (byte_t *) "\x0b";
|
||||||
szInitDataLen = 1;
|
szInitDataLen = 1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case NMT_ISO14443B3CT: {
|
case NMT_ISO14443B2CT: {
|
||||||
// REQT
|
// SELECT-ALL
|
||||||
pbtInitData = (byte_t *) "\x10";
|
pbtInitData = (byte_t *) "\x9F\xFF\xFF";
|
||||||
szInitDataLen = 1;
|
szInitDataLen = 3;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case NMT_FELICA: {
|
case NMT_FELICA: {
|
||||||
|
@ -413,7 +413,7 @@ nfc_initiator_list_passive_targets (nfc_device_t * pnd,
|
||||||
szTargetFound++;
|
szTargetFound++;
|
||||||
// deselect has no effect on FeliCa and Jewel cards so we'll stop after one...
|
// deselect has no effect on FeliCa and Jewel cards so we'll stop after one...
|
||||||
// ISO/IEC 14443 B' cards are polled at 100% probability so it's not possible to detect correctly two cards at the same time
|
// ISO/IEC 14443 B' cards are polled at 100% probability so it's not possible to detect correctly two cards at the same time
|
||||||
if ((nm.nmt == NMT_FELICA) || (nm.nmt == NMT_JEWEL) || (nm.nmt == NMT_ISO14443BI) || (nm.nmt == NMT_ISO14443B3SR) || (nm.nmt == NMT_ISO14443B3CT)) {
|
if ((nm.nmt == NMT_FELICA) || (nm.nmt == NMT_JEWEL) || (nm.nmt == NMT_ISO14443BI) || (nm.nmt == NMT_ISO14443B2SR) || (nm.nmt == NMT_ISO14443B2CT)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue