mirror of
https://github.com/nfc-tools/libnfc.git
synced 2026-02-27 04:06:38 +00:00
simplify quick_start_example1 and add quick_start_example2
This commit is contained in:
@@ -3,15 +3,27 @@
|
||||
* @brief Quick start example that presents how to use libnfc
|
||||
*/
|
||||
|
||||
// To compile this simple example:
|
||||
// $ gcc -o quick_start_example1 -lnfc quick_start_example1.c
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif // HAVE_CONFIG_H
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <err.h>
|
||||
#include <nfc/nfc.h>
|
||||
|
||||
#include "utils/nfc-utils.h"
|
||||
#include "libnfc/chips/pn53x.h"
|
||||
static void
|
||||
print_hex(const uint8_t *pbtData, const size_t szBytes)
|
||||
{
|
||||
size_t szPos;
|
||||
|
||||
for (szPos = 0; szPos < szBytes; szPos++) {
|
||||
printf("%02x ", pbtData[szPos]);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, const char *argv[])
|
||||
@@ -29,7 +41,7 @@ main(int argc, const char *argv[])
|
||||
pnd = nfc_open(NULL, NULL);
|
||||
|
||||
if (pnd == NULL) {
|
||||
ERR("%s", "Unable to open NFC device.");
|
||||
warnx("ERROR: %s", "Unable to open NFC device.");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
// Set opened NFC device to initiator mode
|
||||
|
||||
Reference in New Issue
Block a user