44 #endif // HAVE_CONFIG_H
59 #define MAX_DEVICE_COUNT 16
64 static void stop_polling(
int sig)
76 print_usage(
const char *progname)
78 printf(
"usage: %s [-v]\n", progname);
79 printf(
" -v\t verbose display\n");
83 main(
int argc,
const char *argv[])
87 signal(SIGINT, stop_polling);
92 printf(
"%s uses libnfc %s\n", argv[0], acLibnfcVersion);
94 if ((argc == 2) && (0 == strcmp(
"-v", argv[1]))) {
102 const uint8_t uiPollNr = 20;
103 const uint8_t uiPeriod = 2;
105 { .nmt = NMT_ISO14443A, .nbr = NBR_106 },
106 { .nmt = NMT_ISO14443B, .nbr = NBR_106 },
107 { .nmt = NMT_FELICA, .nbr = NBR_212 },
108 { .nmt = NMT_FELICA, .nbr = NBR_424 },
109 { .nmt = NMT_JEWEL, .nbr = NBR_106 },
111 const size_t szModulations = 5;
117 if (context == NULL) {
118 ERR(
"Unable to init libnfc (malloc)");
125 ERR(
"%s",
"Unable to open NFC device.");
138 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);
147 print_nfc_target(&nt, verbose);
149 printf(
"No target found.\n");
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.
int nfc_initiator_init(nfc_device *pnd)
Initialize NFC device as initiator (reader)
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_perror(const nfc_device *pnd, const char *pcString)
Display the last error occured on a nfc_device.
void nfc_exit(nfc_context *context)
Deinitialize libnfc. Should be called after closing all open devices and before your application term...
nfc_device * nfc_open(nfc_context *context, const nfc_connstring connstring)
Open a NFC device.
NFC modulation structure.
const char * nfc_device_get_name(nfc_device *pnd)
Returns the device name.
int nfc_abort_command(nfc_device *pnd)
Abort current running command.
#define ERR(...)
Print a error message.
void nfc_close(nfc_device *pnd)
Close from a NFC device.
NFC library context Struct which contains internal options, references, pointers, etc...
Provide some examples shared functions like print, parity calculation, options parsing.