simplify quick_start_example1 and add quick_start_example2
This commit is contained in:
parent
fda8d60ce0
commit
7437f76007
2 changed files with 84 additions and 3 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue