60 #define MAX_DEVICE_COUNT 16
65 static void stop_polling(
int sig)
77 print_usage(
const char *progname)
79 printf(
"usage: %s [-v]\n", progname);
80 printf(
" -v\t verbose display\n");
84 main(
int argc,
const char *argv[])
88 signal(SIGINT, stop_polling);
93 printf(
"%s uses libnfc %s\n", argv[0], acLibnfcVersion);
95 if ((argc == 2) && (0 == strcmp(
"-v", argv[1]))) {
103 const uint8_t uiPollNr = 20;
104 const uint8_t uiPeriod = 2;
106 { .nmt = NMT_ISO14443A, .nbr = NBR_106 },
107 { .nmt = NMT_ISO14443B, .nbr = NBR_106 },
108 { .nmt = NMT_FELICA, .nbr = NBR_212 },
109 { .nmt = NMT_FELICA, .nbr = NBR_424 },
110 { .nmt = NMT_JEWEL, .nbr = NBR_106 },
111 { .nmt = NMT_ISO14443BICLASS, .nbr = NBR_106 },
113 const size_t szModulations = 6;
119 if (context == NULL) {
120 ERR(
"Unable to init libnfc (malloc)");
127 ERR(
"%s",
"Unable to open NFC device.");
140 printf(
"NFC device will poll during %ld ms (%u pollings of %lu ms for %" PRIdPTR
" modulations)\n", (
unsigned long) uiPollNr * szModulations * uiPeriod * 150, uiPollNr, (
unsigned long) uiPeriod * 150, szModulations);
149 print_nfc_target(&nt, verbose);
150 printf(
"Waiting for card removing...");
153 nfc_perror(pnd,
"nfc_initiator_target_is_present");
156 printf(
"No target found.\n");
const char * nfc_device_get_name(nfc_device *pnd)
Returns the device name.
void nfc_close(nfc_device *pnd)
Close from a NFC device.
nfc_device * nfc_open(nfc_context *context, const nfc_connstring connstring)
Open a NFC device.
int nfc_abort_command(nfc_device *pnd)
Abort current running command.
void nfc_perror(const nfc_device *pnd, const char *pcString)
Display the last error occured on a nfc_device.
int nfc_initiator_init(nfc_device *pnd)
Initialize NFC device as initiator (reader)
int nfc_initiator_target_is_present(nfc_device *pnd, const nfc_target *pnt)
Check target presence.
int nfc_initiator_poll_target(nfc_device *pnd, const nfc_modulation *pnmModulations, const size_t szModulations, const uint8_t uiPollNr, const uint8_t uiPeriod, nfc_target *pnt)
Polling for NFC targets.
void nfc_exit(nfc_context *context)
Deinitialize libnfc. Should be called after closing all open devices and before your application term...
void nfc_init(nfc_context **context)
Initialize libnfc. This function must be called before calling any other libnfc function.
const char * nfc_version(void)
Returns the library version.
Provide some examples shared functions like print, parity calculation, options parsing.
#define ERR(...)
Print a error message.
NFC library context Struct which contains internal options, references, pointers, etc....
NFC modulation structure.