examples, test and utils use now nfc_init() function.
This commit is contained in:
parent
d1b0e93e8e
commit
1d55b6f8c6
26 changed files with 51 additions and 7 deletions
|
@ -13,12 +13,14 @@ main (int argc, const char *argv[])
|
||||||
{
|
{
|
||||||
nfc_device *pnd;
|
nfc_device *pnd;
|
||||||
nfc_target nt;
|
nfc_target nt;
|
||||||
|
|
||||||
|
nfc_init();
|
||||||
|
|
||||||
// Display libnfc version
|
// Display libnfc version
|
||||||
const char *acLibnfcVersion = nfc_version ();
|
const char *acLibnfcVersion = nfc_version ();
|
||||||
printf ("%s uses libnfc %s\n", argv[0], acLibnfcVersion);
|
printf ("%s uses libnfc %s\n", argv[0], acLibnfcVersion);
|
||||||
|
|
||||||
// Ope, using the first available NFC device
|
// Open, using the first available NFC device
|
||||||
pnd = nfc_open (NULL);
|
pnd = nfc_open (NULL);
|
||||||
|
|
||||||
if (pnd == NULL) {
|
if (pnd == NULL) {
|
||||||
|
|
|
@ -148,6 +148,8 @@ main (int argc, char *argv[])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nfc_init();
|
||||||
|
|
||||||
// Try to open the NFC reader
|
// Try to open the NFC reader
|
||||||
pnd = nfc_open (NULL);
|
pnd = nfc_open (NULL);
|
||||||
|
|
||||||
|
|
|
@ -71,6 +71,8 @@ main (int argc, const char *argv[])
|
||||||
printf ("Usage: %s\n", argv[0]);
|
printf ("Usage: %s\n", argv[0]);
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nfc_init();
|
||||||
|
|
||||||
pnd = nfc_open (NULL);
|
pnd = nfc_open (NULL);
|
||||||
if (!pnd) {
|
if (!pnd) {
|
||||||
|
|
|
@ -71,6 +71,7 @@ main (int argc, const char *argv[])
|
||||||
// the same machine: if there is more than one readers opened
|
// the same machine: if there is more than one readers opened
|
||||||
// nfc-dep-target will open the second reader
|
// nfc-dep-target will open the second reader
|
||||||
// (we hope they're always detected in the same order)
|
// (we hope they're always detected in the same order)
|
||||||
|
nfc_init ();
|
||||||
if (szDeviceFound == 1) {
|
if (szDeviceFound == 1) {
|
||||||
pnd = nfc_open (connstrings[0]);
|
pnd = nfc_open (connstrings[0]);
|
||||||
} else if (szDeviceFound > 1) {
|
} else if (szDeviceFound > 1) {
|
||||||
|
|
|
@ -182,6 +182,7 @@ main(int argc, char *argv[])
|
||||||
};
|
};
|
||||||
|
|
||||||
signal (SIGINT, stop_emulation);
|
signal (SIGINT, stop_emulation);
|
||||||
|
nfc_init ();
|
||||||
pnd = nfc_open (NULL);
|
pnd = nfc_open (NULL);
|
||||||
|
|
||||||
if (pnd == NULL) {
|
if (pnd == NULL) {
|
||||||
|
|
|
@ -179,6 +179,8 @@ main (int argc, char *argv[])
|
||||||
signal (SIGINT, (void (*)()) intr_hdlr);
|
signal (SIGINT, (void (*)()) intr_hdlr);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
nfc_init();
|
||||||
|
|
||||||
// Try to open the NFC reader
|
// Try to open the NFC reader
|
||||||
pnd = nfc_open (NULL);
|
pnd = nfc_open (NULL);
|
||||||
|
|
||||||
|
|
|
@ -125,6 +125,8 @@ main (int argc, char *argv[])
|
||||||
signal (SIGINT, (void (*)()) intr_hdlr);
|
signal (SIGINT, (void (*)()) intr_hdlr);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
nfc_init ();
|
||||||
|
|
||||||
// Try to open the NFC device
|
// Try to open the NFC device
|
||||||
pnd = nfc_open (NULL);
|
pnd = nfc_open (NULL);
|
||||||
|
|
||||||
|
|
|
@ -102,6 +102,8 @@ main (int argc, const char *argv[])
|
||||||
|
|
||||||
nfc_target nt;
|
nfc_target nt;
|
||||||
int res = 0;
|
int res = 0;
|
||||||
|
|
||||||
|
nfc_init ();
|
||||||
|
|
||||||
pnd = nfc_open (NULL);
|
pnd = nfc_open (NULL);
|
||||||
|
|
||||||
|
|
|
@ -115,6 +115,9 @@ main (int argc, char *argv[])
|
||||||
ERR ("%zd device found but two opened devices are needed to relay NFC.", szFound);
|
ERR ("%zd device found but two opened devices are needed to relay NFC.", szFound);
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nfc_init ();
|
||||||
|
|
||||||
// Try to open the NFC emulator device
|
// Try to open the NFC emulator device
|
||||||
pndTag = nfc_open (connstrings[0]);
|
pndTag = nfc_open (connstrings[0]);
|
||||||
if (pndTag == NULL) {
|
if (pndTag == NULL) {
|
||||||
|
|
|
@ -67,6 +67,9 @@ main (int argc, const char *argv[])
|
||||||
if (argc > 1) {
|
if (argc > 1) {
|
||||||
errx (1, "usage: %s", argv[0]);
|
errx (1, "usage: %s", argv[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nfc_init();
|
||||||
|
|
||||||
// Display libnfc version
|
// Display libnfc version
|
||||||
acLibnfcVersion = nfc_version ();
|
acLibnfcVersion = nfc_version ();
|
||||||
printf ("%s uses libnfc %s\n", argv[0], acLibnfcVersion);
|
printf ("%s uses libnfc %s\n", argv[0], acLibnfcVersion);
|
||||||
|
|
|
@ -77,6 +77,8 @@ main (int argc, const char *argv[])
|
||||||
(void) argc;
|
(void) argc;
|
||||||
(void) argv;
|
(void) argv;
|
||||||
|
|
||||||
|
nfc_init ();
|
||||||
|
|
||||||
// Display libnfc version
|
// Display libnfc version
|
||||||
const char *acLibnfcVersion = nfc_version ();
|
const char *acLibnfcVersion = nfc_version ();
|
||||||
printf ("%s uses libnfc %s\n", argv[0], acLibnfcVersion);
|
printf ("%s uses libnfc %s\n", argv[0], acLibnfcVersion);
|
||||||
|
|
|
@ -86,6 +86,8 @@ int main(int argc, const char* argv[])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nfc_init ();
|
||||||
|
|
||||||
// Try to open the NFC reader
|
// Try to open the NFC reader
|
||||||
pnd = nfc_open(NULL);
|
pnd = nfc_open(NULL);
|
||||||
|
|
||||||
|
|
|
@ -63,7 +63,7 @@ const struct nfc_driver *nfc_drivers[] = {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Initialize libnfc.
|
* @brief Initialize libnfc.
|
||||||
*
|
* This function must be called before calling any other libnfc function
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
nfc_init()
|
nfc_init()
|
||||||
|
@ -75,7 +75,7 @@ nfc_init()
|
||||||
* @brief Deinitialize libnfc.
|
* @brief Deinitialize libnfc.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
nfc_exit()
|
nfc_exit()
|
||||||
{
|
{
|
||||||
log_fini ();
|
log_fini ();
|
||||||
|
@ -133,7 +133,6 @@ nfc_get_default_device (nfc_connstring *connstring)
|
||||||
nfc_device *
|
nfc_device *
|
||||||
nfc_open (const nfc_connstring connstring)
|
nfc_open (const nfc_connstring connstring)
|
||||||
{
|
{
|
||||||
log_init ();
|
|
||||||
nfc_device *pnd = NULL;
|
nfc_device *pnd = NULL;
|
||||||
|
|
||||||
nfc_connstring ncs;
|
nfc_connstring ncs;
|
||||||
|
@ -209,7 +208,6 @@ nfc_list_devices (nfc_connstring connstrings[] , size_t szDevices)
|
||||||
const struct nfc_driver *ndr;
|
const struct nfc_driver *ndr;
|
||||||
const struct nfc_driver **pndr = nfc_drivers;
|
const struct nfc_driver **pndr = nfc_drivers;
|
||||||
|
|
||||||
log_init ();
|
|
||||||
while ((ndr = *pndr)) {
|
while ((ndr = *pndr)) {
|
||||||
szN = 0;
|
szN = 0;
|
||||||
if (ndr->probe (connstrings + (szDeviceFound), szDevices - (szDeviceFound), &szN)) {
|
if (ndr->probe (connstrings + (szDeviceFound), szDevices - (szDeviceFound), &szN)) {
|
||||||
|
|
|
@ -17,6 +17,8 @@ test_access_storm (void)
|
||||||
nfc_connstring connstrings[MAX_DEVICE_COUNT];
|
nfc_connstring connstrings[MAX_DEVICE_COUNT];
|
||||||
int res = 0;
|
int res = 0;
|
||||||
|
|
||||||
|
nfc_init ();
|
||||||
|
|
||||||
size_t ref_device_count = nfc_list_devices (connstrings, MAX_DEVICE_COUNT);
|
size_t ref_device_count = nfc_list_devices (connstrings, MAX_DEVICE_COUNT);
|
||||||
if (!ref_device_count)
|
if (!ref_device_count)
|
||||||
cut_omit ("No NFC device found");
|
cut_omit ("No NFC device found");
|
||||||
|
|
|
@ -31,7 +31,7 @@ cut_setup (void)
|
||||||
if (n < 2) {
|
if (n < 2) {
|
||||||
cut_omit ("At least two NFC devices must be plugged-in to run this test");
|
cut_omit ("At least two NFC devices must be plugged-in to run this test");
|
||||||
}
|
}
|
||||||
|
nfc_init ();
|
||||||
devices[TARGET] = nfc_open (connstrings[TARGET]);
|
devices[TARGET] = nfc_open (connstrings[TARGET]);
|
||||||
devices[INITIATOR] = nfc_open (connstrings[INITIATOR]);
|
devices[INITIATOR] = nfc_open (connstrings[INITIATOR]);
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,8 @@ cut_setup (void)
|
||||||
if (n < 2) {
|
if (n < 2) {
|
||||||
cut_omit ("At least two NFC devices must be plugged-in to run this test");
|
cut_omit ("At least two NFC devices must be plugged-in to run this test");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nfc_init ();
|
||||||
devices[TARGET] = nfc_open (connstrings[TARGET]);
|
devices[TARGET] = nfc_open (connstrings[TARGET]);
|
||||||
devices[INITIATOR] = nfc_open (connstrings[INITIATOR]);
|
devices[INITIATOR] = nfc_open (connstrings[INITIATOR]);
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,7 @@ cut_setup (void)
|
||||||
cut_omit ("At least two NFC devices must be plugged-in to run this test");
|
cut_omit ("At least two NFC devices must be plugged-in to run this test");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nfc_init ();
|
||||||
second_device = nfc_open (connstrings[0]);
|
second_device = nfc_open (connstrings[0]);
|
||||||
first_device = nfc_open (connstrings[1]);
|
first_device = nfc_open (connstrings[1]);
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,8 @@ test_register_endianness (void)
|
||||||
{
|
{
|
||||||
nfc_connstring connstrings[MAX_DEVICE_COUNT];
|
nfc_connstring connstrings[MAX_DEVICE_COUNT];
|
||||||
int res = 0;
|
int res = 0;
|
||||||
|
|
||||||
|
nfc_init ();
|
||||||
|
|
||||||
size_t device_count = nfc_list_devices (connstrings, MAX_DEVICE_COUNT);
|
size_t device_count = nfc_list_devices (connstrings, MAX_DEVICE_COUNT);
|
||||||
if (!device_count)
|
if (!device_count)
|
||||||
|
|
|
@ -12,6 +12,8 @@ test_register_endianness (void)
|
||||||
{
|
{
|
||||||
nfc_connstring connstrings[MAX_DEVICE_COUNT];
|
nfc_connstring connstrings[MAX_DEVICE_COUNT];
|
||||||
int res = 0;
|
int res = 0;
|
||||||
|
|
||||||
|
nfc_init ();
|
||||||
|
|
||||||
size_t device_count = nfc_list_devices (connstrings, MAX_DEVICE_COUNT);
|
size_t device_count = nfc_list_devices (connstrings, MAX_DEVICE_COUNT);
|
||||||
if (!device_count)
|
if (!device_count)
|
||||||
|
|
|
@ -345,6 +345,8 @@ main (int argc, char *argv[])
|
||||||
err (EXIT_FAILURE, "Can't load NDEF file '%s'", argv[1]);
|
err (EXIT_FAILURE, "Can't load NDEF file '%s'", argv[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nfc_init ();
|
||||||
|
|
||||||
// Try to open the NFC reader
|
// Try to open the NFC reader
|
||||||
pnd = nfc_open (NULL);
|
pnd = nfc_open (NULL);
|
||||||
|
|
|
@ -75,6 +75,8 @@ main (int argc, const char *argv[])
|
||||||
bool verbose = false;
|
bool verbose = false;
|
||||||
int res = 0;
|
int res = 0;
|
||||||
|
|
||||||
|
nfc_init ();
|
||||||
|
|
||||||
// Display libnfc version
|
// Display libnfc version
|
||||||
acLibnfcVersion = nfc_version ();
|
acLibnfcVersion = nfc_version ();
|
||||||
printf ("%s uses libnfc %s\n", argv[0], acLibnfcVersion);
|
printf ("%s uses libnfc %s\n", argv[0], acLibnfcVersion);
|
||||||
|
|
|
@ -537,6 +537,8 @@ main (int argc, const char *argv[])
|
||||||
}
|
}
|
||||||
// printf("Successfully opened required files\n");
|
// printf("Successfully opened required files\n");
|
||||||
|
|
||||||
|
nfc_init ();
|
||||||
|
|
||||||
// Try to open the NFC reader
|
// Try to open the NFC reader
|
||||||
pnd = nfc_open (NULL);
|
pnd = nfc_open (NULL);
|
||||||
if (pnd == NULL) {
|
if (pnd == NULL) {
|
||||||
|
|
|
@ -177,6 +177,8 @@ main (int argc, char *argv[])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nfc_init ();
|
||||||
|
|
||||||
// Try to open the NFC reader
|
// Try to open the NFC reader
|
||||||
pnd = nfc_open (NULL);
|
pnd = nfc_open (NULL);
|
||||||
|
|
||||||
|
|
|
@ -204,6 +204,8 @@ main (int argc, const char *argv[])
|
||||||
}
|
}
|
||||||
DBG ("Successfully opened the dump file\n");
|
DBG ("Successfully opened the dump file\n");
|
||||||
|
|
||||||
|
nfc_init ();
|
||||||
|
|
||||||
// Try to open the NFC device
|
// Try to open the NFC device
|
||||||
pnd = nfc_open (NULL);
|
pnd = nfc_open (NULL);
|
||||||
if (pnd == NULL) {
|
if (pnd == NULL) {
|
||||||
|
|
|
@ -194,6 +194,8 @@ main(int argc, char *argv[])
|
||||||
exit (EXIT_FAILURE);
|
exit (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nfc_init ();
|
||||||
|
|
||||||
pnd = nfc_open (NULL);
|
pnd = nfc_open (NULL);
|
||||||
|
|
||||||
|
|
|
@ -190,6 +190,8 @@ main (int argc, char *argv[])
|
||||||
signal (SIGINT, (void (*)()) intr_hdlr);
|
signal (SIGINT, (void (*)()) intr_hdlr);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
nfc_init ();
|
||||||
|
|
||||||
nfc_connstring connstrings[MAX_DEVICE_COUNT];
|
nfc_connstring connstrings[MAX_DEVICE_COUNT];
|
||||||
// List available devices
|
// List available devices
|
||||||
size_t szFound = nfc_list_devices (connstrings, MAX_DEVICE_COUNT);
|
size_t szFound = nfc_list_devices (connstrings, MAX_DEVICE_COUNT);
|
||||||
|
|
Loading…
Reference in a new issue