53 #define MAX_FRAME_LEN 264
60 print_usage(
char *argv[])
62 printf(
"Usage: %s [OPTIONS]\n", argv[0]);
64 printf(
"\t-h\tHelp. Print this message.\n");
65 printf(
"\t-q\tVerbose mode.\n");
70 decode_barcode(uint8_t *pbtBarcode,
const size_t szBarcode)
73 printf(
"Manufacturer ID field: %02X\n", pbtBarcode[0]);
74 switch (pbtBarcode[0]) {
76 printf(
"Manufacturer: Thinfilm\n");
79 printf(
"Manufacturer: unknown\n");
84 printf(
"Data Format Field: %02X\n", pbtBarcode[1]);
86 switch (pbtBarcode[1]) {
88 printf(
"Data Format Field: Reserved for allocation by tag manufacturer\n");
95 switch (pbtBarcode[1]) {
97 printf(
"http://www.");
100 printf(
"https://www.");
109 for (uint8_t i = 2; i < 15; i++) {
110 if ((pbtBarcode[i] == 0xfe) || (i == 14)) {
111 pbtBarcode[i] =
'\n';
112 pbtBarcode[i + 1] = 0;
116 printf(
"%s", (
char *)pbtBarcode + 2);
120 for (uint8_t i = 0; i < 12; i++) {
121 printf(
"%02x", pbtBarcode[i + 2]);
126 printf(
"Data Format Field: unknown (%02X)\n", pbtBarcode[1]);
128 for (uint8_t i = 2; i < szBarcode - 2; i++) {
129 printf(
"%02x", pbtBarcode[i]);
138 main(
int argc,
char *argv[])
143 for (arg = 1; arg < argc; arg++) {
144 if (0 == strcmp(argv[arg],
"-h")) {
147 }
else if (0 == strcmp(argv[arg],
"-v")) {
150 ERR(
"%s is not supported option.", argv[arg]);
158 if (context == NULL) {
159 ERR(
"Unable to init libnfc (malloc)");
167 ERR(
"Error opening NFC reader");
183 nm.nmt = NMT_BARCODE;
189 for (uint8_t i = 0; i < (&ant[0])->nti.nti.szDataLen; i++) {
190 printf(
"%02x", (&ant[0])->nti.nti.abtData[i]);
194 decode_barcode((&ant[0])->nti.nti.abtData, (&ant[0])->nti.nti.szDataLen);
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.
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_list_passive_targets(nfc_device *pnd, const nfc_modulation nm, nfc_target ant[], const size_t szTargets)
List passive or emulated tags.
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.
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.