44 #endif // HAVE_CONFIG_H
56 #define MAX_DEVICE_COUNT 16
57 #define MAX_TARGET_COUNT 16
62 print_usage(
const char *progname)
64 printf(
"usage: %s [-v] [-t X]\n", progname);
65 printf(
" -v\t verbose display\n");
66 printf(
" -t X\t poll only for types according to bitfield X:\n");
67 printf(
"\t 1: ISO14443A\n");
68 printf(
"\t 2: Felica (212 kbps)\n");
69 printf(
"\t 4: Felica (424 kbps)\n");
70 printf(
"\t 8: ISO14443B\n");
71 printf(
"\t 16: ISO14443B'\n");
72 printf(
"\t 32: ISO14443B-2 ST SRx\n");
73 printf(
"\t 64: ISO14443B-2 ASK CTx\n");
74 printf(
"\t 128: Jewel\n");
75 printf(
"\tSo 255 (default) polls for all types.\n");
76 printf(
"\tNote that if 16, 32 or 64 then 8 is selected too.\n");
80 main(
int argc,
const char *argv[])
83 const char *acLibnfcVersion;
92 if (context == NULL) {
93 ERR(
"Unable to init libnfc (malloc)");
99 printf(
"%s uses libnfc %s\n", argv[0], acLibnfcVersion);
102 for (arg = 1; arg < argc; arg++) {
103 if (0 == strcmp(argv[arg],
"-h")) {
104 print_usage(argv[0]);
106 }
else if (0 == strcmp(argv[arg],
"-v")) {
108 }
else if ((0 == strcmp(argv[arg],
"-t")) && (arg + 1 < argc)) {
110 mask = atoi(argv[arg]);
111 if ((mask < 1) || (mask > 255)) {
112 ERR(
"%i is invalid value for type bitfield.", mask);
113 print_usage(argv[0]);
120 ERR(
"%s is not supported option.", argv[arg]);
121 print_usage(argv[0]);
134 pnd =
nfc_open(context,
"pn532_uart:/dev/ttyUSB1");
138 size_t szDeviceFound =
nfc_list_devices(context, connstrings, MAX_DEVICE_COUNT);
140 if (szDeviceFound == 0) {
141 printf(
"No NFC device found.\n");
144 for (i = 0; i < szDeviceFound; i++) {
146 pnd =
nfc_open(context, connstrings[i]);
149 ERR(
"Unable to open NFC device: %s", connstrings[i]);
163 nm.nmt = NMT_ISO14443A;
168 if (verbose || (res > 0)) {
169 printf(
"%d ISO14443A passive target(s) found%s\n", res, (res == 0) ?
".\n" :
":");
171 for (n = 0; n < res; n++) {
172 print_nfc_target(&ant[n], verbose);
184 if (verbose || (res > 0)) {
185 printf(
"%d Felica (212 kbps) passive target(s) found%s\n", res, (res == 0) ?
".\n" :
":");
187 for (n = 0; n < res; n++) {
188 print_nfc_target(&ant[n], verbose);
199 if (verbose || (res > 0)) {
200 printf(
"%d Felica (424 kbps) passive target(s) found%s\n", res, (res == 0) ?
".\n" :
":");
202 for (n = 0; n < res; n++) {
203 print_nfc_target(&ant[n], verbose);
210 nm.nmt = NMT_ISO14443B;
215 if (verbose || (res > 0)) {
216 printf(
"%d ISO14443B passive target(s) found%s\n", res, (res == 0) ?
".\n" :
":");
218 for (n = 0; n < res; n++) {
219 print_nfc_target(&ant[n], verbose);
226 nm.nmt = NMT_ISO14443BI;
231 if (verbose || (res > 0)) {
232 printf(
"%d ISO14443B' passive target(s) found%s\n", res, (res == 0) ?
".\n" :
":");
234 for (n = 0; n < res; n++) {
235 print_nfc_target(&ant[n], verbose);
242 nm.nmt = NMT_ISO14443B2SR;
247 if (verbose || (res > 0)) {
248 printf(
"%d ISO14443B-2 ST SRx passive target(s) found%s\n", res, (res == 0) ?
".\n" :
":");
250 for (n = 0; n < res; n++) {
251 print_nfc_target(&ant[n], verbose);
258 nm.nmt = NMT_ISO14443B2CT;
263 if (verbose || (res > 0)) {
264 printf(
"%d ISO14443B-2 ASK CTx passive target(s) found%s\n", res, (res == 0) ?
".\n" :
":");
266 for (n = 0; n < res; n++) {
267 print_nfc_target(&ant[n], verbose);
279 if (verbose || (res > 0)) {
280 printf(
"%d Jewel passive target(s) found%s\n", res, (res == 0) ?
".\n" :
":");
282 for (n = 0; n < res; n++) {
283 print_nfc_target(&ant[n], verbose);