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
|
@ -14,11 +14,13 @@ main (int argc, const char *argv[])
|
|||
nfc_device *pnd;
|
||||
nfc_target nt;
|
||||
|
||||
nfc_init();
|
||||
|
||||
// Display libnfc version
|
||||
const char *acLibnfcVersion = nfc_version ();
|
||||
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);
|
||||
|
||||
if (pnd == NULL) {
|
||||
|
|
|
@ -148,6 +148,8 @@ main (int argc, char *argv[])
|
|||
}
|
||||
}
|
||||
|
||||
nfc_init();
|
||||
|
||||
// Try to open the NFC reader
|
||||
pnd = nfc_open (NULL);
|
||||
|
||||
|
|
|
@ -72,6 +72,8 @@ main (int argc, const char *argv[])
|
|||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
nfc_init();
|
||||
|
||||
pnd = nfc_open (NULL);
|
||||
if (!pnd) {
|
||||
printf("Unable to open NFC device.\n");
|
||||
|
|
|
@ -71,6 +71,7 @@ main (int argc, const char *argv[])
|
|||
// the same machine: if there is more than one readers opened
|
||||
// nfc-dep-target will open the second reader
|
||||
// (we hope they're always detected in the same order)
|
||||
nfc_init ();
|
||||
if (szDeviceFound == 1) {
|
||||
pnd = nfc_open (connstrings[0]);
|
||||
} else if (szDeviceFound > 1) {
|
||||
|
|
|
@ -182,6 +182,7 @@ main(int argc, char *argv[])
|
|||
};
|
||||
|
||||
signal (SIGINT, stop_emulation);
|
||||
nfc_init ();
|
||||
pnd = nfc_open (NULL);
|
||||
|
||||
if (pnd == NULL) {
|
||||
|
|
|
@ -179,6 +179,8 @@ main (int argc, char *argv[])
|
|||
signal (SIGINT, (void (*)()) intr_hdlr);
|
||||
#endif
|
||||
|
||||
nfc_init();
|
||||
|
||||
// Try to open the NFC reader
|
||||
pnd = nfc_open (NULL);
|
||||
|
||||
|
|
|
@ -125,6 +125,8 @@ main (int argc, char *argv[])
|
|||
signal (SIGINT, (void (*)()) intr_hdlr);
|
||||
#endif
|
||||
|
||||
nfc_init ();
|
||||
|
||||
// Try to open the NFC device
|
||||
pnd = nfc_open (NULL);
|
||||
|
||||
|
|
|
@ -103,6 +103,8 @@ main (int argc, const char *argv[])
|
|||
nfc_target nt;
|
||||
int res = 0;
|
||||
|
||||
nfc_init ();
|
||||
|
||||
pnd = nfc_open (NULL);
|
||||
|
||||
if (pnd == NULL) {
|
||||
|
|
|
@ -115,6 +115,9 @@ main (int argc, char *argv[])
|
|||
ERR ("%zd device found but two opened devices are needed to relay NFC.", szFound);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
nfc_init ();
|
||||
|
||||
// Try to open the NFC emulator device
|
||||
pndTag = nfc_open (connstrings[0]);
|
||||
if (pndTag == NULL) {
|
||||
|
|
|
@ -67,6 +67,9 @@ main (int argc, const char *argv[])
|
|||
if (argc > 1) {
|
||||
errx (1, "usage: %s", argv[0]);
|
||||
}
|
||||
|
||||
nfc_init();
|
||||
|
||||
// Display libnfc version
|
||||
acLibnfcVersion = nfc_version ();
|
||||
printf ("%s uses libnfc %s\n", argv[0], acLibnfcVersion);
|
||||
|
|
|
@ -77,6 +77,8 @@ main (int argc, const char *argv[])
|
|||
(void) argc;
|
||||
(void) argv;
|
||||
|
||||
nfc_init ();
|
||||
|
||||
// Display libnfc version
|
||||
const char *acLibnfcVersion = nfc_version ();
|
||||
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
|
||||
pnd = nfc_open(NULL);
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ const struct nfc_driver *nfc_drivers[] = {
|
|||
|
||||
/**
|
||||
* @brief Initialize libnfc.
|
||||
*
|
||||
* This function must be called before calling any other libnfc function
|
||||
*/
|
||||
void
|
||||
nfc_init()
|
||||
|
@ -133,7 +133,6 @@ nfc_get_default_device (nfc_connstring *connstring)
|
|||
nfc_device *
|
||||
nfc_open (const nfc_connstring connstring)
|
||||
{
|
||||
log_init ();
|
||||
nfc_device *pnd = NULL;
|
||||
|
||||
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 **pndr = nfc_drivers;
|
||||
|
||||
log_init ();
|
||||
while ((ndr = *pndr)) {
|
||||
szN = 0;
|
||||
if (ndr->probe (connstrings + (szDeviceFound), szDevices - (szDeviceFound), &szN)) {
|
||||
|
|
|
@ -17,6 +17,8 @@ test_access_storm (void)
|
|||
nfc_connstring connstrings[MAX_DEVICE_COUNT];
|
||||
int res = 0;
|
||||
|
||||
nfc_init ();
|
||||
|
||||
size_t ref_device_count = nfc_list_devices (connstrings, MAX_DEVICE_COUNT);
|
||||
if (!ref_device_count)
|
||||
cut_omit ("No NFC device found");
|
||||
|
|
|
@ -31,7 +31,7 @@ cut_setup (void)
|
|||
if (n < 2) {
|
||||
cut_omit ("At least two NFC devices must be plugged-in to run this test");
|
||||
}
|
||||
|
||||
nfc_init ();
|
||||
devices[TARGET] = nfc_open (connstrings[TARGET]);
|
||||
devices[INITIATOR] = nfc_open (connstrings[INITIATOR]);
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@ cut_setup (void)
|
|||
cut_omit ("At least two NFC devices must be plugged-in to run this test");
|
||||
}
|
||||
|
||||
nfc_init ();
|
||||
devices[TARGET] = nfc_open (connstrings[TARGET]);
|
||||
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");
|
||||
}
|
||||
|
||||
nfc_init ();
|
||||
second_device = nfc_open (connstrings[0]);
|
||||
first_device = nfc_open (connstrings[1]);
|
||||
|
||||
|
|
|
@ -12,6 +12,8 @@ test_register_endianness (void)
|
|||
nfc_connstring connstrings[MAX_DEVICE_COUNT];
|
||||
int res = 0;
|
||||
|
||||
nfc_init ();
|
||||
|
||||
size_t device_count = nfc_list_devices (connstrings, MAX_DEVICE_COUNT);
|
||||
if (!device_count)
|
||||
cut_omit ("No NFC device found");
|
||||
|
|
|
@ -13,6 +13,8 @@ test_register_endianness (void)
|
|||
nfc_connstring connstrings[MAX_DEVICE_COUNT];
|
||||
int res = 0;
|
||||
|
||||
nfc_init ();
|
||||
|
||||
size_t device_count = nfc_list_devices (connstrings, MAX_DEVICE_COUNT);
|
||||
if (!device_count)
|
||||
cut_omit ("No NFC device found");
|
||||
|
|
|
@ -346,6 +346,8 @@ main (int argc, char *argv[])
|
|||
}
|
||||
}
|
||||
|
||||
nfc_init ();
|
||||
|
||||
// Try to open the NFC reader
|
||||
pnd = nfc_open (NULL);
|
||||
|
||||
|
|
|
@ -75,6 +75,8 @@ main (int argc, const char *argv[])
|
|||
bool verbose = false;
|
||||
int res = 0;
|
||||
|
||||
nfc_init ();
|
||||
|
||||
// Display libnfc version
|
||||
acLibnfcVersion = nfc_version ();
|
||||
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");
|
||||
|
||||
nfc_init ();
|
||||
|
||||
// Try to open the NFC reader
|
||||
pnd = nfc_open (NULL);
|
||||
if (pnd == NULL) {
|
||||
|
|
|
@ -177,6 +177,8 @@ main (int argc, char *argv[])
|
|||
}
|
||||
}
|
||||
|
||||
nfc_init ();
|
||||
|
||||
// Try to open the NFC reader
|
||||
pnd = nfc_open (NULL);
|
||||
|
||||
|
|
|
@ -204,6 +204,8 @@ main (int argc, const char *argv[])
|
|||
}
|
||||
DBG ("Successfully opened the dump file\n");
|
||||
|
||||
nfc_init ();
|
||||
|
||||
// Try to open the NFC device
|
||||
pnd = nfc_open (NULL);
|
||||
if (pnd == NULL) {
|
||||
|
|
|
@ -195,6 +195,8 @@ main(int argc, char *argv[])
|
|||
}
|
||||
}
|
||||
|
||||
nfc_init ();
|
||||
|
||||
pnd = nfc_open (NULL);
|
||||
|
||||
if (pnd == NULL) {
|
||||
|
|
|
@ -190,6 +190,8 @@ main (int argc, char *argv[])
|
|||
signal (SIGINT, (void (*)()) intr_hdlr);
|
||||
#endif
|
||||
|
||||
nfc_init ();
|
||||
|
||||
nfc_connstring connstrings[MAX_DEVICE_COUNT];
|
||||
// List available devices
|
||||
size_t szFound = nfc_list_devices (connstrings, MAX_DEVICE_COUNT);
|
||||
|
|
Loading…
Reference in a new issue