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:
parent
6710ca943e
commit
e4802de965
16 changed files with 269 additions and 69 deletions
6
NEWS
6
NEWS
|
@ -5,6 +5,12 @@ API Changes:
|
|||
* Types
|
||||
- New NFC_ESOFT error to handle software errors (allocations, pie creation, etc.)
|
||||
|
||||
* Functions
|
||||
- New enum-to-string converter functions str_nfc_modulation_type() and
|
||||
str_nfc_baud_rate()
|
||||
- New nfc_device_get_information_about() function to retreive some device's
|
||||
information
|
||||
|
||||
New in 1.6.0-rc1:
|
||||
|
||||
API Changes:
|
||||
|
|
|
@ -114,7 +114,14 @@ extern "C" {
|
|||
NFC_EXPORT void iso14443a_crc (uint8_t *pbtData, size_t szLen, uint8_t *pbtCrc);
|
||||
NFC_EXPORT void iso14443a_crc_append (uint8_t *pbtData, size_t szLen);
|
||||
NFC_EXPORT uint8_t *iso14443a_locate_historical_bytes (uint8_t *pbtAts, size_t szAts, size_t *pszTk);
|
||||
|
||||
NFC_EXPORT const char *nfc_version (void);
|
||||
NFC_EXPORT int nfc_device_get_information_about (nfc_device *pnd, char *buf, size_t buflen);
|
||||
|
||||
/* String converter functions */
|
||||
NFC_EXPORT const char * str_nfc_modulation_type (const nfc_modulation_type nmt);
|
||||
NFC_EXPORT const char * str_nfc_baud_rate (const nfc_baud_rate nbr);
|
||||
|
||||
|
||||
/* Error codes */
|
||||
/** @ingroup error
|
||||
|
|
|
@ -18,7 +18,7 @@ libnfc_la_SOURCES = \
|
|||
nfc-emulation.c \
|
||||
nfc-internal.c
|
||||
|
||||
libnfc_la_LDFLAGS = -no-undefined -version-info 3:0:0 -export-symbols-regex '^nfc_|^iso14443a_|pn53x_transceive|pn53x_SAMConfiguration'
|
||||
libnfc_la_LDFLAGS = -no-undefined -version-info 3:0:0 -export-symbols-regex '^nfc_|^iso14443a_|^str_nfc_|pn53x_transceive|pn53x_SAMConfiguration'
|
||||
libnfc_la_CFLAGS = @DRIVERS_CFLAGS@
|
||||
libnfc_la_LIBADD = \
|
||||
$(top_builddir)/libnfc/chips/libnfcchips.la \
|
||||
|
|
|
@ -68,8 +68,7 @@ pn53x_init(struct nfc_device *pnd)
|
|||
{
|
||||
int res = 0;
|
||||
// GetFirmwareVersion command is used to set PN53x chips type (PN531, PN532 or PN533)
|
||||
char abtFirmwareText[22];
|
||||
if ((res = pn53x_get_firmware_version (pnd, abtFirmwareText)) < 0) {
|
||||
if ((res = pn53x_decode_firmware_version (pnd)) < 0) {
|
||||
return res;
|
||||
}
|
||||
|
||||
|
@ -113,12 +112,6 @@ pn53x_init(struct nfc_device *pnd)
|
|||
if ((res = pn53x_reset_settings(pnd)) < 0) {
|
||||
return res;
|
||||
}
|
||||
|
||||
// Add the firmware revision to the device name
|
||||
char *pcName;
|
||||
pcName = strdup (pnd->name);
|
||||
snprintf (pnd->name, DEVICE_NAME_LENGTH - 1, "%s - %s", pcName, abtFirmwareText);
|
||||
free (pcName);
|
||||
return NFC_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -690,7 +683,7 @@ pn53x_writeback_register (struct nfc_device *pnd)
|
|||
}
|
||||
|
||||
int
|
||||
pn53x_get_firmware_version (struct nfc_device *pnd, char abtFirmwareText[22])
|
||||
pn53x_decode_firmware_version (struct nfc_device *pnd)
|
||||
{
|
||||
const uint8_t abtCmd[] = { GetFirmwareVersion };
|
||||
uint8_t abtFw[4];
|
||||
|
@ -723,16 +716,16 @@ pn53x_get_firmware_version (struct nfc_device *pnd, char abtFirmwareText[22])
|
|||
// Convert firmware info in text, PN531 gives 2 bytes info, but PN532 and PN533 gives 4
|
||||
switch (CHIP_DATA(pnd)->type) {
|
||||
case PN531:
|
||||
snprintf (abtFirmwareText, 22, "PN531 v%d.%d", abtFw[0], abtFw[1]);
|
||||
snprintf (CHIP_DATA(pnd)->firmware_text, sizeof(CHIP_DATA(pnd)->firmware_text), "PN531 v%d.%d", abtFw[0], abtFw[1]);
|
||||
pnd->btSupportByte = SUPPORT_ISO14443A | SUPPORT_ISO18092;
|
||||
break;
|
||||
case PN532:
|
||||
snprintf (abtFirmwareText, 22, "PN532 v%d.%d (0x%02x)", abtFw[1], abtFw[2], abtFw[3]);
|
||||
snprintf (CHIP_DATA(pnd)->firmware_text, sizeof(CHIP_DATA(pnd)->firmware_text), "PN532 v%d.%d", abtFw[1], abtFw[2]);
|
||||
pnd->btSupportByte = abtFw[3];
|
||||
break;
|
||||
case PN533:
|
||||
case RCS360:
|
||||
snprintf (abtFirmwareText, 22, "PN533 v%d.%d (0x%02x)", abtFw[1], abtFw[2], abtFw[3]);
|
||||
snprintf (CHIP_DATA(pnd)->firmware_text, sizeof(CHIP_DATA(pnd)->firmware_text), "PN533 v%d.%d", abtFw[1], abtFw[2]);
|
||||
pnd->btSupportByte = abtFw[3];
|
||||
break;
|
||||
case PN53X:
|
||||
|
@ -2869,6 +2862,132 @@ pn53x_get_supported_baud_rate (nfc_device *pnd, const nfc_modulation_type nmt, c
|
|||
return NFC_SUCCESS;
|
||||
}
|
||||
|
||||
int
|
||||
pn53x_get_information_about (nfc_device *pnd, char *buf, size_t buflen)
|
||||
{
|
||||
int res;
|
||||
if ((res = snprintf (buf, buflen, "chip: %s\n", CHIP_DATA(pnd)->firmware_text)) < 0) {
|
||||
return NFC_ESOFT;
|
||||
}
|
||||
buf += res;
|
||||
if (buflen <= (size_t)res) {
|
||||
return NFC_EOVFLOW;
|
||||
}
|
||||
buflen -= res;
|
||||
|
||||
if ((res = snprintf (buf, buflen, "initator mode modulations: ")) < 0) {
|
||||
return NFC_ESOFT;
|
||||
}
|
||||
buf += res;
|
||||
if (buflen <= (size_t)res) {
|
||||
return NFC_EOVFLOW;
|
||||
}
|
||||
buflen -= res;
|
||||
const nfc_modulation_type *nmt;
|
||||
if ((res = nfc_device_get_supported_modulation(pnd, N_INITIATOR, &nmt)) < 0) {
|
||||
return res;
|
||||
}
|
||||
|
||||
for (int i=0; nmt[i]; i++) {
|
||||
if ((res = snprintf (buf, buflen, "%s%s (", (i==0)?"":", ", str_nfc_modulation_type (nmt[i]))) < 0) {
|
||||
return NFC_ESOFT;
|
||||
}
|
||||
buf += res;
|
||||
if (buflen <= (size_t)res) {
|
||||
return NFC_EOVFLOW;
|
||||
}
|
||||
buflen -= res;
|
||||
const nfc_baud_rate *nbr;
|
||||
if ((res = nfc_device_get_supported_baud_rate (pnd, nmt[i], &nbr)) < 0) {
|
||||
return res;
|
||||
}
|
||||
|
||||
for (int j=0; nbr[j]; j++) {
|
||||
if ((res = snprintf (buf, buflen, "%s%s", (j==0)?"":", ", str_nfc_baud_rate (nbr[j]))) < 0) {
|
||||
return NFC_ESOFT;
|
||||
}
|
||||
buf += res;
|
||||
if (buflen <= (size_t)res) {
|
||||
return NFC_EOVFLOW;
|
||||
}
|
||||
buflen -= res;
|
||||
}
|
||||
if ((res = snprintf (buf, buflen, ")")) < 0) {
|
||||
return NFC_ESOFT;
|
||||
}
|
||||
buf += res;
|
||||
if (buflen <= (size_t)res) {
|
||||
return NFC_EOVFLOW;
|
||||
}
|
||||
buflen -= res;
|
||||
|
||||
}
|
||||
if ((res = snprintf (buf, buflen, "\n")) < 0) {
|
||||
return NFC_ESOFT;
|
||||
}
|
||||
buf += res;
|
||||
if (buflen <= (size_t)res) {
|
||||
return NFC_EOVFLOW;
|
||||
}
|
||||
buflen -= res;
|
||||
if ((res = snprintf (buf, buflen, "target mode modulations: ")) < 0) {
|
||||
return NFC_ESOFT;
|
||||
}
|
||||
buf += res;
|
||||
if (buflen <= (size_t)res) {
|
||||
return NFC_EOVFLOW;
|
||||
}
|
||||
buflen -= res;
|
||||
if ((res = nfc_device_get_supported_modulation(pnd, N_TARGET, &nmt)) < 0) {
|
||||
return res;
|
||||
}
|
||||
|
||||
for (int i=0; nmt[i]; i++) {
|
||||
if ((res = snprintf (buf, buflen, "%s%s (", (i==0)?"":", ", str_nfc_modulation_type (nmt[i]))) < 0) {
|
||||
return NFC_ESOFT;
|
||||
}
|
||||
buf += res;
|
||||
if (buflen <= (size_t)res) {
|
||||
return NFC_EOVFLOW;
|
||||
}
|
||||
buflen -= res;
|
||||
const nfc_baud_rate *nbr;
|
||||
if ((res = nfc_device_get_supported_baud_rate (pnd, nmt[i], &nbr)) < 0) {
|
||||
return res;
|
||||
}
|
||||
|
||||
for (int j=0; nbr[j]; j++) {
|
||||
if ((res = snprintf (buf, buflen, "%s%s", (j==0)?"":", ", str_nfc_baud_rate (nbr[j]))) < 0) {
|
||||
return NFC_ESOFT;
|
||||
}
|
||||
buf += res;
|
||||
if (buflen <= (size_t)res) {
|
||||
return NFC_EOVFLOW;
|
||||
}
|
||||
buflen -= res;
|
||||
}
|
||||
if ((res = snprintf (buf, buflen, ")")) < 0) {
|
||||
return NFC_ESOFT;
|
||||
}
|
||||
buf += res;
|
||||
if (buflen <= (size_t)res) {
|
||||
return NFC_EOVFLOW;
|
||||
}
|
||||
buflen -= res;
|
||||
|
||||
}
|
||||
if ((res = snprintf (buf, buflen, "\n")) < 0) {
|
||||
return NFC_ESOFT;
|
||||
}
|
||||
buf += res;
|
||||
if (buflen <= (size_t)res) {
|
||||
return NFC_EOVFLOW;
|
||||
}
|
||||
buflen -= res;
|
||||
|
||||
return NFC_SUCCESS;
|
||||
}
|
||||
|
||||
void
|
||||
pn53x_data_new (struct nfc_device *pnd, const struct pn53x_io *io)
|
||||
{
|
||||
|
|
|
@ -155,8 +155,10 @@ struct pn53x_io {
|
|||
* @brief PN53x data structure
|
||||
*/
|
||||
struct pn53x_data {
|
||||
/** Chip type (PN531, PN532 or PN533)*/
|
||||
/** Chip type (PN531, PN532 or PN533) */
|
||||
pn53x_type type;
|
||||
/** Chip firmware text */
|
||||
char firmware_text[22];
|
||||
/** Current power mode */
|
||||
pn53x_power_mode power_mode;
|
||||
/** Current operating mode */
|
||||
|
@ -301,7 +303,7 @@ int pn53x_decode_target_data (const uint8_t *pbtRawData, size_t szRawData,
|
|||
nfc_target_info *pnti);
|
||||
int pn53x_read_register (struct nfc_device *pnd, uint16_t ui16Reg, uint8_t *ui8Value);
|
||||
int pn53x_write_register (struct nfc_device *pnd, uint16_t ui16Reg, uint8_t ui8SymbolMask, uint8_t ui8Value);
|
||||
int pn53x_get_firmware_version (struct nfc_device *pnd, char abtFirmwareText[22]);
|
||||
int pn53x_decode_firmware_version (struct nfc_device *pnd);
|
||||
int pn53x_set_property_int (struct nfc_device *pnd, const nfc_property property, const int value);
|
||||
int pn53x_set_property_bool (struct nfc_device *pnd, const nfc_property property, const bool bEnable);
|
||||
|
||||
|
@ -382,6 +384,7 @@ int pn53x_check_error_frame (struct nfc_device *pnd, const uint8_t *pbtRxFram
|
|||
int pn53x_build_frame (uint8_t *pbtFrame, size_t *pszFrame, const uint8_t *pbtData, const size_t szData);
|
||||
int pn53x_get_supported_modulation (nfc_device *pnd, const nfc_mode mode, const nfc_modulation_type **const supported_mt);
|
||||
int pn53x_get_supported_baud_rate (nfc_device *pnd, const nfc_modulation_type nmt, const nfc_baud_rate **const supported_br);
|
||||
int pn53x_get_information_about (nfc_device *pnd, char *buf, size_t buflen);
|
||||
|
||||
void pn53x_data_new (struct nfc_device *pnd, const struct pn53x_io *io);
|
||||
void pn53x_data_free (struct nfc_device *pnd);
|
||||
|
|
|
@ -492,10 +492,11 @@ const struct nfc_driver acr122_pcsc_driver = {
|
|||
.target_send_bits = pn53x_target_send_bits,
|
||||
.target_receive_bits = pn53x_target_receive_bits,
|
||||
|
||||
.device_set_property_bool = pn53x_set_property_bool,
|
||||
.device_set_property_int = pn53x_set_property_int,
|
||||
.get_supported_modulation = pn53x_get_supported_modulation,
|
||||
.get_supported_baud_rate = pn53x_get_supported_baud_rate,
|
||||
.device_set_property_bool = pn53x_set_property_bool,
|
||||
.device_set_property_int = pn53x_set_property_int,
|
||||
.get_supported_modulation = pn53x_get_supported_modulation,
|
||||
.get_supported_baud_rate = pn53x_get_supported_baud_rate,
|
||||
.device_get_information_about = pn53x_get_information_about,
|
||||
|
||||
.abort_command = NULL, // FIXME: abort is not supported in this driver
|
||||
.idle = NULL, // FIXME: idle is not supported in this driver
|
||||
|
|
|
@ -766,8 +766,11 @@ const struct nfc_driver acr122_usb_driver = {
|
|||
.target_send_bits = pn53x_target_send_bits,
|
||||
.target_receive_bits = pn53x_target_receive_bits,
|
||||
|
||||
.device_set_property_bool = pn53x_set_property_bool,
|
||||
.device_set_property_int = pn53x_set_property_int,
|
||||
.device_set_property_bool = pn53x_set_property_bool,
|
||||
.device_set_property_int = pn53x_set_property_int,
|
||||
.get_supported_modulation = pn53x_get_supported_modulation,
|
||||
.get_supported_baud_rate = pn53x_get_supported_baud_rate,
|
||||
.device_get_information_about = pn53x_get_information_about,
|
||||
|
||||
.abort_command = acr122_usb_abort_command,
|
||||
.idle = pn53x_idle,
|
||||
|
|
|
@ -744,10 +744,11 @@ const struct nfc_driver acr122s_driver = {
|
|||
.target_send_bits = pn53x_target_send_bits,
|
||||
.target_receive_bits = pn53x_target_receive_bits,
|
||||
|
||||
.device_set_property_bool = pn53x_set_property_bool,
|
||||
.device_set_property_int = pn53x_set_property_int,
|
||||
.get_supported_modulation = pn53x_get_supported_modulation,
|
||||
.get_supported_baud_rate = pn53x_get_supported_baud_rate,
|
||||
.device_set_property_bool = pn53x_set_property_bool,
|
||||
.device_set_property_int = pn53x_set_property_int,
|
||||
.get_supported_modulation = pn53x_get_supported_modulation,
|
||||
.get_supported_baud_rate = pn53x_get_supported_baud_rate,
|
||||
.device_get_information_about = pn53x_get_information_about,
|
||||
|
||||
.abort_command = acr122s_abort_command,
|
||||
.idle = NULL,
|
||||
|
|
|
@ -586,10 +586,11 @@ const struct nfc_driver arygon_driver = {
|
|||
.target_send_bits = pn53x_target_send_bits,
|
||||
.target_receive_bits = pn53x_target_receive_bits,
|
||||
|
||||
.device_set_property_bool = pn53x_set_property_bool,
|
||||
.device_set_property_int = pn53x_set_property_int,
|
||||
.get_supported_modulation = pn53x_get_supported_modulation,
|
||||
.get_supported_baud_rate = pn53x_get_supported_baud_rate,
|
||||
.device_set_property_bool = pn53x_set_property_bool,
|
||||
.device_set_property_int = pn53x_set_property_int,
|
||||
.get_supported_modulation = pn53x_get_supported_modulation,
|
||||
.get_supported_baud_rate = pn53x_get_supported_baud_rate,
|
||||
.device_get_information_about = pn53x_get_information_about,
|
||||
|
||||
.abort_command = arygon_abort_command,
|
||||
.idle = NULL, // FIXME arygon driver does not support idle()
|
||||
|
|
|
@ -528,10 +528,11 @@ const struct nfc_driver pn532_uart_driver = {
|
|||
.target_send_bits = pn53x_target_send_bits,
|
||||
.target_receive_bits = pn53x_target_receive_bits,
|
||||
|
||||
.device_set_property_bool = pn53x_set_property_bool,
|
||||
.device_set_property_int = pn53x_set_property_int,
|
||||
.get_supported_modulation = pn53x_get_supported_modulation,
|
||||
.get_supported_baud_rate = pn53x_get_supported_baud_rate,
|
||||
.device_set_property_bool = pn53x_set_property_bool,
|
||||
.device_set_property_int = pn53x_set_property_int,
|
||||
.get_supported_modulation = pn53x_get_supported_modulation,
|
||||
.get_supported_baud_rate = pn53x_get_supported_baud_rate,
|
||||
.device_get_information_about = pn53x_get_information_about,
|
||||
|
||||
.abort_command = pn532_uart_abort_command,
|
||||
.idle = pn53x_idle,
|
||||
|
|
|
@ -779,10 +779,11 @@ const struct nfc_driver pn53x_usb_driver = {
|
|||
.target_send_bits = pn53x_target_send_bits,
|
||||
.target_receive_bits = pn53x_target_receive_bits,
|
||||
|
||||
.device_set_property_bool = pn53x_usb_set_property_bool,
|
||||
.device_set_property_int = pn53x_set_property_int,
|
||||
.get_supported_modulation = pn53x_get_supported_modulation,
|
||||
.get_supported_baud_rate = pn53x_get_supported_baud_rate,
|
||||
.device_set_property_bool = pn53x_usb_set_property_bool,
|
||||
.device_set_property_int = pn53x_set_property_int,
|
||||
.get_supported_modulation = pn53x_get_supported_modulation,
|
||||
.get_supported_baud_rate = pn53x_get_supported_baud_rate,
|
||||
.device_get_information_about = pn53x_get_information_about,
|
||||
|
||||
.abort_command = pn53x_usb_abort_command,
|
||||
.idle = pn53x_idle,
|
||||
|
|
|
@ -160,6 +160,7 @@ struct nfc_driver {
|
|||
int (*device_set_property_int) (struct nfc_device *pnd, const nfc_property property, const int value);
|
||||
int (*get_supported_modulation) (struct nfc_device *pnd, const nfc_mode mode, const nfc_modulation_type **const supported_mt);
|
||||
int (*get_supported_baud_rate) (struct nfc_device *pnd, const nfc_modulation_type nmt, const nfc_baud_rate **const supported_br);
|
||||
int (*device_get_information_about) (struct nfc_device *pnd, char *buf, size_t buflen);
|
||||
|
||||
int (*abort_command) (struct nfc_device *pnd);
|
||||
int (*idle) (struct nfc_device *pnd);
|
||||
|
|
80
libnfc/nfc.c
80
libnfc/nfc.c
|
@ -1041,3 +1041,83 @@ nfc_version (void)
|
|||
return PACKAGE_VERSION;
|
||||
#endif // SVN_REVISION
|
||||
}
|
||||
|
||||
/** @ingroup misc
|
||||
* @brief Print information about NFC device
|
||||
* @return Upon successful return, this function returns the number of characters printed (excluding the null byte used to end output to strings), otherwise returns libnfc's error code (negative value)
|
||||
* @param pnd \a nfc_device struct pointer that represent currently used device
|
||||
* @param buf string to print information
|
||||
* @param buflen buf length
|
||||
*/
|
||||
int
|
||||
nfc_device_get_information_about (nfc_device *pnd, char *buf, size_t buflen)
|
||||
{
|
||||
HAL (device_get_information_about, pnd, buf, buflen);
|
||||
}
|
||||
|
||||
/** @ingroup string-converter
|
||||
* @brief Convert \a nfc_baud_rate value to string
|
||||
* @return Returns nfc baud rate
|
||||
* @param \a nfc_baud_rate to convert
|
||||
*/
|
||||
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;
|
||||
}
|
||||
// Should never go there..
|
||||
return "";
|
||||
}
|
||||
|
||||
/** @ingroup string-converter
|
||||
* @brief Convert \a nfc_modulation_type value to string
|
||||
* @return Returns nfc modulation type
|
||||
* @param \a nfc_modulation_type to convert
|
||||
*/
|
||||
const char *
|
||||
str_nfc_modulation_type (const nfc_modulation_type nmt)
|
||||
{
|
||||
switch(nmt) {
|
||||
case NMT_ISO14443A:
|
||||
return "ISO/IEC 14443A";
|
||||
break;
|
||||
case NMT_ISO14443B:
|
||||
return "ISO/IEC 14443-4B";
|
||||
break;
|
||||
case NMT_ISO14443BI:
|
||||
return "ISO/IEC 14443-4B'";
|
||||
break;
|
||||
case NMT_ISO14443B2CT:
|
||||
return "ISO/IEC 14443-2B ASK CTx";
|
||||
break;
|
||||
case NMT_ISO14443B2SR:
|
||||
return "ISO/IEC 14443-2B ST SRx";
|
||||
break;
|
||||
case NMT_FELICA:
|
||||
return "FeliCa";
|
||||
break;
|
||||
case NMT_JEWEL:
|
||||
return "Innovision Jewel";
|
||||
break;
|
||||
case NMT_DEP:
|
||||
return "D.E.P.";
|
||||
break;
|
||||
}
|
||||
// Should never go there..
|
||||
return "";
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in a new issue