Add new public functions to grab information in string format:

- New nfc_device_get_information_about()
 - Moved nfc-utils function str_nfc_baud_rate()
 - New str_nfc_modulation_type()
 - Add new device_get_information_about callback to nfc_driver struct
 - Export new symbols
 - Changed internal pn53x firmware text handling: we now store firmware text for further operations
 - print_nfc_target() now uses str_nfc_* functions
 - nfc-probe util now have a verbose which display information on detected devices (Fix verbose set but not used warning ;-) )
This commit is contained in:
Romuald Conty 2012-05-17 00:48:47 +00:00
parent 6710ca943e
commit e4802de965
16 changed files with 269 additions and 69 deletions

View file

@ -3,6 +3,7 @@
*
* Copyright (C) 2009, Roel Verdult
* Copyright (C) 2010, Romuald Conty, Romain Tartière
* Copyright (C) 2011-2012, Romuald Conty
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@ -103,10 +104,16 @@ main (int argc, const char *argv[])
}
printf ("%d NFC device(s) found:\n", (int)szDeviceFound);
char strinfo[1024];
for (i = 0; i < szDeviceFound; i++) {
pnd = nfc_open (NULL, connstrings[i]);
if (pnd != NULL) {
printf ("- %s:\n %s\n", nfc_device_get_name (pnd), nfc_device_get_connstring (pnd));
if (verbose) {
if (nfc_device_get_information_about (pnd, strinfo, sizeof(strinfo)) >= 0) {
printf ("%s", strinfo);
}
}
nfc_close (pnd);
}
}

View file

@ -656,63 +656,33 @@ print_nfc_dep_info (const nfc_dep_info ndi, bool verbose)
}
}
const char *
str_nfc_baud_rate (const nfc_baud_rate nbr)
{
switch(nbr) {
case NBR_UNDEFINED:
return "undefined baud rate";
break;
case NBR_106:
return "106 kbps";
break;
case NBR_212:
return "212 kbps";
break;
case NBR_424:
return "424 kbps";
break;
case NBR_847:
return "847 kbps";
break;
}
return "";
}
void
print_nfc_target (const nfc_target nt, bool verbose)
{
printf ("%s (%s%s) target:\n", str_nfc_modulation_type(nt.nm.nmt), str_nfc_baud_rate(nt.nm.nbr), (nt.nm.nmt!=NMT_DEP)?"":(nt.nti.ndi.ndm == NDM_ACTIVE)? "active mode" : "passive mode");
switch(nt.nm.nmt) {
case NMT_ISO14443A:
printf ("ISO/IEC 14443A (%s) target:\n", str_nfc_baud_rate(nt.nm.nbr));
print_nfc_iso14443a_info (nt.nti.nai, verbose);
break;
case NMT_JEWEL:
printf ("Innovision Jewel (%s) target:\n", str_nfc_baud_rate(nt.nm.nbr));
print_nfc_jewel_info (nt.nti.nji, verbose);
break;
case NMT_FELICA:
printf ("FeliCa (%s) target:\n", str_nfc_baud_rate(nt.nm.nbr));
print_nfc_felica_info (nt.nti.nfi, verbose);
break;
case NMT_ISO14443B:
printf ("ISO/IEC 14443-4B (%s) target:\n", str_nfc_baud_rate(nt.nm.nbr));
print_nfc_iso14443b_info (nt.nti.nbi, verbose);
break;
case NMT_ISO14443BI:
printf ("ISO/IEC 14443-4B' (%s) target:\n", str_nfc_baud_rate(nt.nm.nbr));
print_nfc_iso14443bi_info (nt.nti.nii, verbose);
break;
case NMT_ISO14443B2SR:
printf ("ISO/IEC 14443-2B ST SRx (%s) target:\n", str_nfc_baud_rate(nt.nm.nbr));
print_nfc_iso14443b2sr_info (nt.nti.nsi, verbose);
break;
case NMT_ISO14443B2CT:
printf ("ISO/IEC 14443-2B ASK CTx (%s) target:\n", str_nfc_baud_rate(nt.nm.nbr));
print_nfc_iso14443b2ct_info (nt.nti.nci, verbose);
break;
case NMT_DEP:
printf ("D.E.P. (%s, %s) target:\n", str_nfc_baud_rate(nt.nm.nbr), (nt.nti.ndi.ndm == NDM_ACTIVE)? "active mode" : "passive mode");
print_nfc_dep_info (nt.nti.ndi, verbose);
break;
}

View file

@ -101,7 +101,6 @@ void print_nfc_iso14443b2ct_info (const nfc_iso14443b2ct_info nci, bool verbo
void print_nfc_felica_info (const nfc_felica_info nfi, bool verbose);
void print_nfc_jewel_info (const nfc_jewel_info nji, bool verbose);
void print_nfc_dep_info (const nfc_dep_info ndi, bool verbose);
const char * str_nfc_baud_rate (const nfc_baud_rate nbr);
void print_nfc_target (const nfc_target nt, bool verbose);