2010-01-15 11:18:11 +01:00
|
|
|
/*-
|
2010-11-17 15:27:11 +01:00
|
|
|
* Public platform independent Near Field Communication (NFC) library examples
|
2012-05-29 02:33:22 +02:00
|
|
|
*
|
2012-10-21 16:09:16 +02:00
|
|
|
* Copyright (C) 2009 Roel Verdult
|
2012-05-29 02:33:22 +02:00
|
|
|
*
|
2010-11-17 15:27:11 +01:00
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions are met:
|
|
|
|
* 1) Redistributions of source code must retain the above copyright notice,
|
2012-05-29 02:33:22 +02:00
|
|
|
* this list of conditions and the following disclaimer.
|
2010-11-17 15:27:11 +01:00
|
|
|
* 2 )Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
|
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
|
|
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
2012-05-29 02:33:22 +02:00
|
|
|
*
|
2010-11-17 15:27:11 +01:00
|
|
|
* Note that this license only applies on the examples, NFC library itself is under LGPL
|
2009-10-12 16:52:26 +02:00
|
|
|
*
|
2010-01-15 11:18:11 +01:00
|
|
|
*/
|
|
|
|
|
2012-05-29 02:33:22 +02:00
|
|
|
/**
|
2009-10-12 16:52:26 +02:00
|
|
|
* @file nfc-anticol.c
|
2010-10-14 13:53:27 +02:00
|
|
|
* @brief Generates one ISO14443-A anti-collision process "by-hand"
|
2009-10-12 16:52:26 +02:00
|
|
|
*/
|
2009-04-29 14:47:41 +02:00
|
|
|
|
2010-01-15 11:18:11 +01:00
|
|
|
#ifdef HAVE_CONFIG_H
|
2010-09-07 19:51:03 +02:00
|
|
|
# include "config.h"
|
2010-01-15 11:18:11 +01:00
|
|
|
#endif // HAVE_CONFIG_H
|
|
|
|
|
2009-04-29 14:47:41 +02:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2009-05-27 14:18:21 +02:00
|
|
|
#include <stddef.h>
|
2009-05-27 12:13:19 +02:00
|
|
|
#include <stdint.h>
|
2009-05-27 16:05:07 +02:00
|
|
|
#include <stdbool.h>
|
2009-04-29 14:47:41 +02:00
|
|
|
#include <string.h>
|
2009-05-27 12:13:19 +02:00
|
|
|
|
2009-12-01 15:23:00 +01:00
|
|
|
#include <nfc/nfc.h>
|
2009-04-29 14:47:41 +02:00
|
|
|
|
2011-09-30 13:33:31 +02:00
|
|
|
#include "utils/nfc-utils.h"
|
2009-09-08 12:25:59 +02:00
|
|
|
|
2009-04-29 14:47:41 +02:00
|
|
|
#define SAK_FLAG_ATS_SUPPORTED 0x20
|
|
|
|
|
2009-11-10 10:47:59 +01:00
|
|
|
#define MAX_FRAME_LEN 264
|
|
|
|
|
2011-11-24 11:54:42 +01:00
|
|
|
static uint8_t abtRx[MAX_FRAME_LEN];
|
2012-01-04 16:43:08 +01:00
|
|
|
static int szRxBits;
|
2011-03-02 16:02:30 +01:00
|
|
|
static size_t szRx = sizeof(abtRx);
|
2011-11-24 11:54:42 +01:00
|
|
|
static uint8_t abtRawUid[12];
|
|
|
|
static uint8_t abtAtqa[2];
|
|
|
|
static uint8_t abtSak;
|
|
|
|
static uint8_t abtAts[MAX_FRAME_LEN];
|
|
|
|
static uint8_t szAts = 0;
|
2010-10-25 15:00:39 +02:00
|
|
|
static size_t szCL = 1;//Always start with Cascade Level 1 (CL1)
|
2011-11-23 16:55:40 +01:00
|
|
|
static nfc_device *pnd;
|
2009-04-29 14:47:41 +02:00
|
|
|
|
2010-09-07 19:51:03 +02:00
|
|
|
bool quiet_output = false;
|
2011-06-07 20:47:20 +02:00
|
|
|
bool force_rats = false;
|
|
|
|
bool iso_ats_supported = false;
|
2009-08-23 11:50:46 +02:00
|
|
|
|
2009-04-29 14:47:41 +02:00
|
|
|
// ISO14443A Anti-Collision Commands
|
2011-11-24 11:54:42 +01:00
|
|
|
uint8_t abtReqa[1] = { 0x26 };
|
|
|
|
uint8_t abtSelectAll[2] = { 0x93, 0x20 };
|
|
|
|
uint8_t abtSelectTag[9] = { 0x93, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
|
|
|
uint8_t abtRats[4] = { 0xe0, 0x50, 0x00, 0x00 };
|
|
|
|
uint8_t abtHalt[4] = { 0x50, 0x00, 0x00, 0x00 };
|
2010-10-25 15:48:01 +02:00
|
|
|
#define CASCADE_BIT 0x04
|
2010-09-07 19:51:03 +02:00
|
|
|
|
2010-09-20 17:55:55 +02:00
|
|
|
static bool
|
2012-05-29 17:54:36 +02:00
|
|
|
transmit_bits(const uint8_t *pbtTx, const size_t szTxBits)
|
2009-04-29 14:47:41 +02:00
|
|
|
{
|
|
|
|
// Show transmitted command
|
2010-09-07 19:51:03 +02:00
|
|
|
if (!quiet_output) {
|
2012-05-29 17:54:36 +02:00
|
|
|
printf("Sent bits: ");
|
|
|
|
print_hex_bits(pbtTx, szTxBits);
|
2009-08-23 11:50:46 +02:00
|
|
|
}
|
2009-04-29 14:47:41 +02:00
|
|
|
// Transmit the bit frame command, we don't use the arbitrary parity feature
|
2012-11-24 13:00:23 +01:00
|
|
|
if ((szRxBits = nfc_initiator_transceive_bits(pnd, pbtTx, szTxBits, NULL, abtRx, sizeof(abtRx), NULL)) < 0)
|
2010-09-07 19:51:03 +02:00
|
|
|
return false;
|
2009-04-29 14:47:41 +02:00
|
|
|
|
|
|
|
// Show received answer
|
2010-09-07 19:51:03 +02:00
|
|
|
if (!quiet_output) {
|
2012-05-29 17:54:36 +02:00
|
|
|
printf("Received bits: ");
|
|
|
|
print_hex_bits(abtRx, szRxBits);
|
2009-08-23 11:50:46 +02:00
|
|
|
}
|
2009-04-29 14:47:41 +02:00
|
|
|
// Succesful transfer
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-09-20 17:55:55 +02:00
|
|
|
static bool
|
2012-05-29 17:54:36 +02:00
|
|
|
transmit_bytes(const uint8_t *pbtTx, const size_t szTx)
|
2009-04-29 14:47:41 +02:00
|
|
|
{
|
|
|
|
// Show transmitted command
|
2010-09-07 19:51:03 +02:00
|
|
|
if (!quiet_output) {
|
2012-05-29 17:54:36 +02:00
|
|
|
printf("Sent bits: ");
|
|
|
|
print_hex(pbtTx, szTx);
|
2009-08-23 11:50:46 +02:00
|
|
|
}
|
2012-05-27 23:06:22 +02:00
|
|
|
int res;
|
2009-04-29 14:47:41 +02:00
|
|
|
// Transmit the command bytes
|
2012-05-29 17:54:36 +02:00
|
|
|
if ((res = nfc_initiator_transceive_bytes(pnd, pbtTx, szTx, abtRx, sizeof(abtRx), 0)) < 0)
|
2010-09-07 19:51:03 +02:00
|
|
|
return false;
|
2009-04-29 14:47:41 +02:00
|
|
|
|
|
|
|
// Show received answer
|
2010-09-07 19:51:03 +02:00
|
|
|
if (!quiet_output) {
|
2012-05-29 17:54:36 +02:00
|
|
|
printf("Received bits: ");
|
|
|
|
print_hex(abtRx, res);
|
2009-08-23 11:50:46 +02:00
|
|
|
}
|
2009-04-29 14:47:41 +02:00
|
|
|
// Succesful transfer
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-09-07 19:51:03 +02:00
|
|
|
static void
|
2012-05-29 17:54:36 +02:00
|
|
|
print_usage(char *argv[])
|
2009-09-07 12:15:34 +02:00
|
|
|
{
|
2012-05-29 17:54:36 +02:00
|
|
|
printf("Usage: %s [OPTIONS]\n", argv[0]);
|
|
|
|
printf("Options:\n");
|
|
|
|
printf("\t-h\tHelp. Print this message.\n");
|
|
|
|
printf("\t-q\tQuiet mode. Suppress output of READER and EMULATOR data (improves timing).\n");
|
|
|
|
printf("\t-f\tForce RATS.\n");
|
2009-09-07 12:15:34 +02:00
|
|
|
}
|
|
|
|
|
2010-09-07 19:51:03 +02:00
|
|
|
int
|
2012-05-29 17:54:36 +02:00
|
|
|
main(int argc, char *argv[])
|
2009-04-29 14:47:41 +02:00
|
|
|
{
|
2010-09-07 19:51:03 +02:00
|
|
|
int arg;
|
2009-08-23 11:50:46 +02:00
|
|
|
|
|
|
|
// Get commandline options
|
2010-09-07 19:51:03 +02:00
|
|
|
for (arg = 1; arg < argc; arg++) {
|
2012-05-29 17:54:36 +02:00
|
|
|
if (0 == strcmp(argv[arg], "-h")) {
|
|
|
|
print_usage(argv);
|
2010-09-20 17:55:55 +02:00
|
|
|
exit(EXIT_SUCCESS);
|
2012-05-29 17:54:36 +02:00
|
|
|
} else if (0 == strcmp(argv[arg], "-q")) {
|
2009-08-26 12:57:38 +02:00
|
|
|
quiet_output = true;
|
2012-05-29 17:54:36 +02:00
|
|
|
} else if (0 == strcmp(argv[arg], "-f")) {
|
2011-06-07 20:47:20 +02:00
|
|
|
force_rats = true;
|
2009-09-07 12:15:34 +02:00
|
|
|
} else {
|
2012-05-29 17:54:36 +02:00
|
|
|
ERR("%s is not supported option.", argv[arg]);
|
|
|
|
print_usage(argv);
|
2010-09-20 17:55:55 +02:00
|
|
|
exit(EXIT_FAILURE);
|
2009-08-23 11:50:46 +02:00
|
|
|
}
|
2009-09-07 12:15:34 +02:00
|
|
|
}
|
2009-08-23 11:50:46 +02:00
|
|
|
|
2012-12-04 19:29:57 +01:00
|
|
|
nfc_context *context;
|
|
|
|
nfc_init(&context);
|
2012-05-29 02:33:22 +02:00
|
|
|
|
2009-04-29 14:47:41 +02:00
|
|
|
// Try to open the NFC reader
|
2012-12-04 19:29:57 +01:00
|
|
|
pnd = nfc_open(context, NULL);
|
2009-09-07 12:15:34 +02:00
|
|
|
|
2010-09-07 19:51:03 +02:00
|
|
|
if (!pnd) {
|
2012-05-29 17:54:36 +02:00
|
|
|
printf("Error opening NFC reader\n");
|
2010-09-20 17:55:55 +02:00
|
|
|
exit(EXIT_FAILURE);
|
2009-04-29 14:47:41 +02:00
|
|
|
}
|
2010-09-20 17:55:55 +02:00
|
|
|
|
|
|
|
// Initialise NFC device as "initiator"
|
2012-05-29 17:54:36 +02:00
|
|
|
if (nfc_initiator_init(pnd) < 0) {
|
|
|
|
nfc_perror(pnd, "nfc_initiator_init");
|
|
|
|
exit(EXIT_FAILURE);
|
2012-01-05 11:33:50 +01:00
|
|
|
}
|
2009-04-29 14:47:41 +02:00
|
|
|
|
2010-08-18 19:22:13 +02:00
|
|
|
// Configure the CRC
|
2012-05-29 17:54:36 +02:00
|
|
|
if (nfc_device_set_property_bool(pnd, NP_HANDLE_CRC, false) < 0) {
|
|
|
|
nfc_perror(pnd, "nfc_device_set_property_bool");
|
|
|
|
exit(EXIT_FAILURE);
|
2010-08-18 19:22:13 +02:00
|
|
|
}
|
2010-09-20 17:55:55 +02:00
|
|
|
// Use raw send/receive methods
|
2012-05-29 17:54:36 +02:00
|
|
|
if (nfc_device_set_property_bool(pnd, NP_EASY_FRAMING, false) < 0) {
|
|
|
|
nfc_perror(pnd, "nfc_device_set_property_bool");
|
|
|
|
exit(EXIT_FAILURE);
|
2010-09-20 17:55:55 +02:00
|
|
|
}
|
|
|
|
// Disable 14443-4 autoswitching
|
2012-05-29 17:54:36 +02:00
|
|
|
if (nfc_device_set_property_bool(pnd, NP_AUTO_ISO14443_4, false) < 0) {
|
|
|
|
nfc_perror(pnd, "nfc_device_set_property_bool");
|
|
|
|
exit(EXIT_FAILURE);
|
2010-08-18 19:22:13 +02:00
|
|
|
}
|
2010-09-03 18:13:36 +02:00
|
|
|
|
2012-05-29 17:54:36 +02:00
|
|
|
printf("NFC reader: %s opened\n\n", nfc_device_get_name(pnd));
|
2009-04-29 14:47:41 +02:00
|
|
|
|
|
|
|
// Send the 7 bits request command specified in ISO 14443A (0x26)
|
2012-05-29 17:54:36 +02:00
|
|
|
if (!transmit_bits(abtReqa, 7)) {
|
|
|
|
printf("Error: No tag available\n");
|
|
|
|
nfc_close(pnd);
|
2012-12-04 19:29:57 +01:00
|
|
|
nfc_exit(context);
|
|
|
|
return EXIT_FAILURE;
|
2009-04-29 14:47:41 +02:00
|
|
|
}
|
2012-05-29 17:54:36 +02:00
|
|
|
memcpy(abtAtqa, abtRx, 2);
|
2010-10-20 17:23:09 +02:00
|
|
|
|
2009-04-29 14:47:41 +02:00
|
|
|
// Anti-collision
|
2012-05-29 17:54:36 +02:00
|
|
|
transmit_bytes(abtSelectAll, 2);
|
2009-10-02 11:52:02 +02:00
|
|
|
|
2010-10-25 15:48:01 +02:00
|
|
|
// Check answer
|
|
|
|
if ((abtRx[0] ^ abtRx[1] ^ abtRx[2] ^ abtRx[3] ^ abtRx[4]) != 0) {
|
|
|
|
printf("WARNING: BCC check failed!\n");
|
2010-10-25 15:00:39 +02:00
|
|
|
}
|
|
|
|
|
2010-10-25 15:48:01 +02:00
|
|
|
// Save the UID CL1
|
2012-05-29 17:54:36 +02:00
|
|
|
memcpy(abtRawUid, abtRx, 4);
|
2010-10-25 15:48:01 +02:00
|
|
|
|
2010-10-25 15:00:39 +02:00
|
|
|
//Prepare and send CL1 Select-Command
|
2012-05-29 17:54:36 +02:00
|
|
|
memcpy(abtSelectTag + 2, abtRx, 5);
|
|
|
|
iso14443a_crc_append(abtSelectTag, 7);
|
|
|
|
transmit_bytes(abtSelectTag, 9);
|
2010-10-25 15:00:39 +02:00
|
|
|
abtSak = abtRx[0];
|
|
|
|
|
2010-10-25 15:48:01 +02:00
|
|
|
// Test if we are dealing with a CL2
|
|
|
|
if (abtSak & CASCADE_BIT) {
|
|
|
|
szCL = 2;//or more
|
|
|
|
// Check answer
|
|
|
|
if (abtRawUid[0] != 0x88) {
|
|
|
|
printf("WARNING: Cascade bit set but CT != 0x88!\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-29 17:54:36 +02:00
|
|
|
if (szCL == 2) {
|
2009-04-29 14:47:41 +02:00
|
|
|
// We have to do the anti-collision for cascade level 2
|
2010-10-25 15:00:39 +02:00
|
|
|
|
|
|
|
// Prepare CL2 commands
|
2009-04-29 14:47:41 +02:00
|
|
|
abtSelectAll[0] = 0x95;
|
|
|
|
|
|
|
|
// Anti-collision
|
2012-05-29 17:54:36 +02:00
|
|
|
transmit_bytes(abtSelectAll, 2);
|
2009-10-02 11:52:02 +02:00
|
|
|
|
2010-10-25 15:48:01 +02:00
|
|
|
// Check answer
|
|
|
|
if ((abtRx[0] ^ abtRx[1] ^ abtRx[2] ^ abtRx[3] ^ abtRx[4]) != 0) {
|
|
|
|
printf("WARNING: BCC check failed!\n");
|
2010-10-25 15:00:39 +02:00
|
|
|
}
|
2010-10-25 15:48:01 +02:00
|
|
|
|
|
|
|
// Save UID CL2
|
2012-05-29 17:54:36 +02:00
|
|
|
memcpy(abtRawUid + 4, abtRx, 4);
|
2010-10-25 15:48:01 +02:00
|
|
|
|
|
|
|
// Selection
|
|
|
|
abtSelectTag[0] = 0x95;
|
2012-05-29 17:54:36 +02:00
|
|
|
memcpy(abtSelectTag + 2, abtRx, 5);
|
|
|
|
iso14443a_crc_append(abtSelectTag, 7);
|
|
|
|
transmit_bytes(abtSelectTag, 9);
|
2010-10-25 15:00:39 +02:00
|
|
|
abtSak = abtRx[0];
|
|
|
|
|
2010-10-25 15:48:01 +02:00
|
|
|
// Test if we are dealing with a CL3
|
|
|
|
if (abtSak & CASCADE_BIT) {
|
|
|
|
szCL = 3;
|
|
|
|
// Check answer
|
|
|
|
if (abtRawUid[0] != 0x88) {
|
|
|
|
printf("WARNING: Cascade bit set but CT != 0x88!\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-29 17:54:36 +02:00
|
|
|
if (szCL == 3) {
|
2010-10-25 15:48:01 +02:00
|
|
|
// We have to do the anti-collision for cascade level 3
|
2010-10-25 15:00:39 +02:00
|
|
|
|
|
|
|
// Prepare and send CL3 AC-Command
|
|
|
|
abtSelectAll[0] = 0x97;
|
2012-05-29 17:54:36 +02:00
|
|
|
transmit_bytes(abtSelectAll, 2);
|
2010-10-25 15:00:39 +02:00
|
|
|
|
2010-10-25 15:48:01 +02:00
|
|
|
// Check answer
|
|
|
|
if ((abtRx[0] ^ abtRx[1] ^ abtRx[2] ^ abtRx[3] ^ abtRx[4]) != 0) {
|
|
|
|
printf("WARNING: BCC check failed!\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
// Save UID CL3
|
2012-05-29 17:54:36 +02:00
|
|
|
memcpy(abtRawUid + 8, abtRx, 4);
|
2010-10-25 15:48:01 +02:00
|
|
|
|
2010-10-25 15:00:39 +02:00
|
|
|
// Prepare and send final Select-Command
|
|
|
|
abtSelectTag[0] = 0x97;
|
2012-05-29 17:54:36 +02:00
|
|
|
memcpy(abtSelectTag + 2, abtRx, 5);
|
|
|
|
iso14443a_crc_append(abtSelectTag, 7);
|
|
|
|
transmit_bytes(abtSelectTag, 9);
|
2010-10-25 15:00:39 +02:00
|
|
|
abtSak = abtRx[0];
|
|
|
|
}
|
2009-04-29 14:47:41 +02:00
|
|
|
}
|
2009-10-02 11:52:02 +02:00
|
|
|
|
2009-04-29 14:47:41 +02:00
|
|
|
// Request ATS, this only applies to tags that support ISO 14443A-4
|
2010-10-26 17:01:46 +02:00
|
|
|
if (abtRx[0] & SAK_FLAG_ATS_SUPPORTED) {
|
2012-05-29 17:52:51 +02:00
|
|
|
iso_ats_supported = true;
|
2011-06-07 20:47:20 +02:00
|
|
|
}
|
|
|
|
if ((abtRx[0] & SAK_FLAG_ATS_SUPPORTED) || force_rats) {
|
2010-10-29 12:59:26 +02:00
|
|
|
iso14443a_crc_append(abtRats, 2);
|
2012-05-29 17:54:36 +02:00
|
|
|
if (transmit_bytes(abtRats, 4)) {
|
|
|
|
memcpy(abtAts, abtRx, szRx);
|
2012-05-29 17:52:51 +02:00
|
|
|
szAts = szRx;
|
2011-06-07 20:47:20 +02:00
|
|
|
}
|
2010-10-26 17:01:46 +02:00
|
|
|
}
|
2009-04-29 14:47:41 +02:00
|
|
|
|
|
|
|
// Done, halt the tag now
|
2010-10-29 12:59:26 +02:00
|
|
|
iso14443a_crc_append(abtHalt, 2);
|
2012-05-29 17:54:36 +02:00
|
|
|
transmit_bytes(abtHalt, 4);
|
2009-10-02 11:52:02 +02:00
|
|
|
|
2012-05-29 17:54:36 +02:00
|
|
|
printf("\nFound tag with\n UID: ");
|
2010-10-25 15:48:01 +02:00
|
|
|
switch (szCL) {
|
|
|
|
case 1:
|
2012-05-29 17:54:36 +02:00
|
|
|
printf("%02x%02x%02x%02x", abtRawUid[0], abtRawUid[1], abtRawUid[2], abtRawUid[3]);
|
2012-05-29 17:52:51 +02:00
|
|
|
break;
|
2010-10-25 15:48:01 +02:00
|
|
|
case 2:
|
2012-05-29 17:54:36 +02:00
|
|
|
printf("%02x%02x%02x", abtRawUid[1], abtRawUid[2], abtRawUid[3]);
|
|
|
|
printf("%02x%02x%02x%02x", abtRawUid[4], abtRawUid[5], abtRawUid[6], abtRawUid[7]);
|
2012-05-29 17:52:51 +02:00
|
|
|
break;
|
2010-10-25 15:48:01 +02:00
|
|
|
case 3:
|
2012-05-29 17:54:36 +02:00
|
|
|
printf("%02x%02x%02x", abtRawUid[1], abtRawUid[2], abtRawUid[3]);
|
|
|
|
printf("%02x%02x%02x", abtRawUid[5], abtRawUid[6], abtRawUid[7]);
|
|
|
|
printf("%02x%02x%02x%02x", abtRawUid[8], abtRawUid[9], abtRawUid[10], abtRawUid[11]);
|
2012-05-29 17:52:51 +02:00
|
|
|
break;
|
2009-04-29 14:47:41 +02:00
|
|
|
}
|
2010-10-25 15:00:39 +02:00
|
|
|
printf("\n");
|
|
|
|
printf("ATQA: %02x%02x\n SAK: %02x\n", abtAtqa[1], abtAtqa[0], abtSak);
|
2011-06-07 20:47:20 +02:00
|
|
|
if (szAts > 1) { // if = 1, it's not actual ATS but error code
|
2012-05-29 17:52:51 +02:00
|
|
|
if (force_rats && ! iso_ats_supported) {
|
|
|
|
printf(" RATS forced\n");
|
|
|
|
}
|
|
|
|
printf(" ATS: ");
|
2012-05-29 17:54:36 +02:00
|
|
|
print_hex(abtAts, szAts);
|
2011-06-07 20:47:20 +02:00
|
|
|
}
|
2009-04-29 14:47:41 +02:00
|
|
|
|
2012-05-29 17:54:36 +02:00
|
|
|
nfc_close(pnd);
|
2012-12-04 19:29:57 +01:00
|
|
|
nfc_exit(context);
|
|
|
|
return EXIT_SUCCESS;
|
2009-04-29 14:47:41 +02:00
|
|
|
}
|