nfc-anticol: fix bug in long UID display, and some more details
This commit is contained in:
parent
72d7b66d2b
commit
0abdf67b8b
1 changed files with 19 additions and 11 deletions
|
@ -46,6 +46,8 @@ static byte_t abtRx[MAX_FRAME_LEN];
|
||||||
static size_t szRxBits;
|
static size_t szRxBits;
|
||||||
static size_t szRx;
|
static size_t szRx;
|
||||||
static byte_t abtUid[10];
|
static byte_t abtUid[10];
|
||||||
|
static byte_t abtAtqa[2];
|
||||||
|
static byte_t abtSak;
|
||||||
static size_t szUidLen = 4;
|
static size_t szUidLen = 4;
|
||||||
static nfc_device_t *pnd;
|
static nfc_device_t *pnd;
|
||||||
|
|
||||||
|
@ -187,19 +189,23 @@ main (int argc, char *argv[])
|
||||||
nfc_disconnect (pnd);
|
nfc_disconnect (pnd);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
memcpy (abtAtqa, abtRx, 2);
|
||||||
|
|
||||||
// Anti-collision
|
// Anti-collision
|
||||||
transmit_bytes (abtSelectAll, 2);
|
transmit_bytes (abtSelectAll, 2);
|
||||||
|
|
||||||
// Save the UID
|
|
||||||
memcpy (abtUid, abtRx, 4);
|
|
||||||
memcpy (abtSelectTag + 2, abtRx, 5);
|
memcpy (abtSelectTag + 2, abtRx, 5);
|
||||||
append_iso14443a_crc (abtSelectTag, 7);
|
append_iso14443a_crc (abtSelectTag, 7);
|
||||||
transmit_bytes (abtSelectTag, 9);
|
|
||||||
|
|
||||||
// Test if we are dealing with a 4 bytes uid
|
// Test if we are dealing with a 4 bytes uid
|
||||||
if (abtUid[0] != 0x88) {
|
if (abtRx[0] != 0x88) {
|
||||||
|
// Save the UID
|
||||||
|
memcpy (abtUid, abtRx, 4);
|
||||||
szUidLen = 4;
|
szUidLen = 4;
|
||||||
} else {
|
} else {
|
||||||
|
// Save the first 3 bytes of UID
|
||||||
|
memcpy (abtUid, abtRx+1, 3);
|
||||||
|
transmit_bytes (abtSelectTag, 9);
|
||||||
// We have to do the anti-collision for cascade level 2
|
// We have to do the anti-collision for cascade level 2
|
||||||
abtSelectAll[0] = 0x95;
|
abtSelectAll[0] = 0x95;
|
||||||
abtSelectTag[0] = 0x95;
|
abtSelectTag[0] = 0x95;
|
||||||
|
@ -207,13 +213,14 @@ main (int argc, char *argv[])
|
||||||
// Anti-collision
|
// Anti-collision
|
||||||
transmit_bytes (abtSelectAll, 2);
|
transmit_bytes (abtSelectAll, 2);
|
||||||
|
|
||||||
// Save the UID
|
// Save the second part of UID
|
||||||
memcpy (abtUid + 4, abtRx, 4);
|
memcpy (abtUid + 3, abtRx, 4);
|
||||||
memcpy (abtSelectTag + 2, abtRx, 5);
|
memcpy (abtSelectTag + 2, abtRx, 5);
|
||||||
append_iso14443a_crc (abtSelectTag, 7);
|
append_iso14443a_crc (abtSelectTag, 7);
|
||||||
transmit_bytes (abtSelectTag, 9);
|
|
||||||
szUidLen = 7;
|
szUidLen = 7;
|
||||||
}
|
}
|
||||||
|
transmit_bytes (abtSelectTag, 9);
|
||||||
|
abtSak = abtRx[0];
|
||||||
|
|
||||||
// Request ATS, this only applies to tags that support ISO 14443A-4
|
// Request ATS, this only applies to tags that support ISO 14443A-4
|
||||||
if (abtRx[0] & SAK_FLAG_ATS_SUPPORTED)
|
if (abtRx[0] & SAK_FLAG_ATS_SUPPORTED)
|
||||||
|
@ -223,10 +230,11 @@ main (int argc, char *argv[])
|
||||||
transmit_bytes (abtHalt, 4);
|
transmit_bytes (abtHalt, 4);
|
||||||
|
|
||||||
printf ("\nFound tag with UID: ");
|
printf ("\nFound tag with UID: ");
|
||||||
|
printf ("%02x%02x%02x%02x", abtUid[0], abtUid[1], abtUid[2], abtUid[3]);
|
||||||
if (szUidLen == 7) {
|
if (szUidLen == 7) {
|
||||||
printf ("%02x%02x%02x", abtUid[6], abtUid[5], abtUid[4]);
|
printf ("%02x%02x%02x", abtUid[4], abtUid[5], abtUid[6]);
|
||||||
}
|
}
|
||||||
printf ("%02x%02x%02x%02x\n", abtUid[3], abtUid[2], abtUid[1], abtUid[0]);
|
printf(" ATQA: %02x%02x SAK: %02x\n", abtAtqa[1], abtAtqa[0], abtSak);
|
||||||
|
|
||||||
nfc_disconnect (pnd);
|
nfc_disconnect (pnd);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Add table
Reference in a new issue