rename nfc_connect() function to nfc_open().

This commit is contained in:
Audrey Diacre 2012-01-17 15:21:56 +00:00
parent 9eb37b3eee
commit 324af418db
36 changed files with 117 additions and 117 deletions

View file

@ -18,20 +18,20 @@ main (int argc, const char *argv[])
const char *acLibnfcVersion = nfc_version ();
printf ("%s uses libnfc %s\n", argv[0], acLibnfcVersion);
// Connect using the first available NFC device
pnd = nfc_connect (NULL);
// Ope, using the first available NFC device
pnd = nfc_open (NULL);
if (pnd == NULL) {
ERR ("%s", "Unable to connect to NFC device.");
ERR ("%s", "Unable to open NFC device.");
return EXIT_FAILURE;
}
// Set connected NFC device to initiator mode
// Set opened NFC device to initiator mode
if (nfc_initiator_init (pnd) < 0) {
nfc_perror (pnd, "nfc_initiator_init");
exit (EXIT_FAILURE);
}
printf ("Connected to NFC reader: %s\n", nfc_device_get_name (pnd));
printf ("NFC reader: %s opened\n", nfc_device_get_name (pnd));
// Poll for a ISO14443A (MIFARE) tag
const nfc_modulation nmMifare = {
@ -51,7 +51,7 @@ main (int argc, const char *argv[])
print_hex (nt.nti.nai.abtAts, nt.nti.nai.szAtsLen);
}
}
// Disconnect from NFC device
// Close NFC device
nfc_close (pnd);
return EXIT_SUCCESS;
}

View file

@ -149,10 +149,10 @@ main (int argc, char *argv[])
}
// Try to open the NFC reader
pnd = nfc_connect (NULL);
pnd = nfc_open (NULL);
if (!pnd) {
printf ("Error connecting NFC reader\n");
printf ("Error opening NFC reader\n");
exit(EXIT_FAILURE);
}
@ -178,7 +178,7 @@ main (int argc, char *argv[])
exit (EXIT_FAILURE);
}
printf ("Connected to NFC reader: %s\n\n", nfc_device_get_name (pnd));
printf ("NFC reader: %s opened\n\n", nfc_device_get_name (pnd));
// Send the 7 bits request command specified in ISO 14443A (0x26)
if (!transmit_bits (abtReqa, 7)) {

View file

@ -72,12 +72,12 @@ main (int argc, const char *argv[])
return EXIT_FAILURE;
}
pnd = nfc_connect (NULL);
pnd = nfc_open (NULL);
if (!pnd) {
printf("Unable to connect to NFC device.\n");
printf("Unable to open NFC device.\n");
return EXIT_FAILURE;
}
printf ("Connected to NFC device: %s\n", nfc_device_get_name (pnd));
printf ("NFC device: %s\n opened", nfc_device_get_name (pnd));
signal (SIGINT, stop_dep_communication);

View file

@ -68,13 +68,13 @@ main (int argc, const char *argv[])
nfc_connstring connstrings[MAX_DEVICE_COUNT];
size_t szDeviceFound = nfc_list_devices (connstrings, MAX_DEVICE_COUNT);
// Little hack to allow using nfc-dep-initiator & nfc-dep-target from
// the same machine: if there is more than one readers connected
// nfc-dep-target will connect to the second reader
// 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)
if (szDeviceFound == 1) {
pnd = nfc_connect (connstrings[0]);
pnd = nfc_open (connstrings[0]);
} else if (szDeviceFound > 1) {
pnd = nfc_connect (connstrings[1]);
pnd = nfc_open (connstrings[1]);
} else {
printf("No device found.\n");
return EXIT_FAILURE;
@ -107,10 +107,10 @@ main (int argc, const char *argv[])
};
if (!pnd) {
printf("Unable to connect to NFC device.\n");
printf("Unable to open NFC device.\n");
return EXIT_FAILURE;
}
printf ("Connected to NFC device: %s\n", nfc_device_get_name (pnd));
printf ("NFC device: %s opened\n", nfc_device_get_name (pnd));
signal (SIGINT, stop_dep_communication);

View file

@ -182,14 +182,14 @@ main(int argc, char *argv[])
};
signal (SIGINT, stop_emulation);
pnd = nfc_connect (NULL);
pnd = nfc_open (NULL);
if (pnd == NULL) {
ERR("Unable to connect to NFC device");
ERR("Unable to open NFC device");
exit (EXIT_FAILURE);
}
printf ("Connected to NFC device: %s\n", nfc_device_get_name (pnd));
printf ("NFC device: %s opened\n", nfc_device_get_name (pnd));
printf ("Emulating NDEF tag now, please touch it with a second NFC device\n");
if (nfc_emulate_target (pnd, &emulator) < 0) {

View file

@ -180,18 +180,18 @@ main (int argc, char *argv[])
#endif
// Try to open the NFC reader
pnd = nfc_connect (NULL);
pnd = nfc_open (NULL);
// Display libnfc version
acLibnfcVersion = nfc_version ();
printf ("%s uses libnfc %s\n", argv[0], acLibnfcVersion);
if (pnd == NULL) {
ERR("Unable to connect to NFC device");
ERR("Unable to open NFC device");
exit (EXIT_FAILURE);
}
printf ("Connected to NFC device: %s\n", nfc_device_get_name (pnd));
printf ("NFC device: %s opened\n", nfc_device_get_name (pnd));
// Notes for ISO14443-A emulated tags:
// * Only short UIDs are supported

View file

@ -126,15 +126,15 @@ main (int argc, char *argv[])
#endif
// Try to open the NFC device
pnd = nfc_connect (NULL);
pnd = nfc_open (NULL);
if (pnd == NULL) {
printf ("Unable to connect to NFC device\n");
printf ("Unable to open NFC device\n");
exit(EXIT_FAILURE);
}
printf ("\n");
printf ("Connected to NFC device: %s\n", nfc_device_get_name (pnd));
printf ("NFC device: %s opened\n", nfc_device_get_name (pnd));
printf ("[+] Try to break out the auto-emulation, this requires a second NFC device!\n");
printf ("[+] To do this, please send any command after the anti-collision\n");
printf ("[+] For example, send a RATS command or use the \"nfc-anticol\" or \"nfc-list\" tool.\n");

View file

@ -103,10 +103,10 @@ main (int argc, const char *argv[])
nfc_target nt;
int res = 0;
pnd = nfc_connect (NULL);
pnd = nfc_open (NULL);
if (pnd == NULL) {
ERR ("%s", "Unable to connect to NFC device.");
ERR ("%s", "Unable to open NFC device.");
exit (EXIT_FAILURE);
}
@ -115,7 +115,7 @@ main (int argc, const char *argv[])
exit (EXIT_FAILURE);
}
printf ("Connected to NFC reader: %s\n", nfc_device_get_name (pnd));
printf ("NFC reader: %s opened\n", nfc_device_get_name (pnd));
printf ("NFC device will poll during %ld ms (%u pollings of %lu ms for %zd modulations)\n", (unsigned long) uiPollNr * szModulations * uiPeriod * 150, uiPollNr, (unsigned long) uiPeriod * 150, szModulations);
if ((res = nfc_initiator_poll_target (pnd, nmModulations, szModulations, uiPollNr, uiPeriod, &nt)) < 0) {
nfc_perror (pnd, "nfc_initiator_poll_target");

View file

@ -112,19 +112,19 @@ main (int argc, char *argv[])
size_t szFound = nfc_list_devices (connstrings, MAX_DEVICE_COUNT);
if (szFound < 2) {
ERR ("%zd device found but two connected devices are needed to relay NFC.", szFound);
ERR ("%zd device found but two opened devices are needed to relay NFC.", szFound);
return EXIT_FAILURE;
}
// Try to open the NFC emulator device
pndTag = nfc_connect (connstrings[0]);
pndTag = nfc_open (connstrings[0]);
if (pndTag == NULL) {
printf ("Error connecting NFC emulator device\n");
printf ("Error opening NFC emulator device\n");
return EXIT_FAILURE;
}
printf ("Hint: tag <---> initiator (relay) <---> target (relay) <---> original reader\n\n");
printf ("Connected to the NFC emulator device: %s\n", nfc_device_get_name (pndTag));
printf ("NFC emulator device: %s opened\n", nfc_device_get_name (pndTag));
printf ("[+] Try to break out the auto-emulation, this requires a second reader!\n");
printf ("[+] To do this, please send any command after the anti-collision\n");
printf ("[+] For example, send a RATS command or use the \"nfc-anticol\" tool\n");
@ -159,9 +159,9 @@ main (int argc, char *argv[])
printf ("%s", "Done, emulated tag is initialized");
// Try to open the NFC reader
pndReader = nfc_connect (connstrings[1]);
pndReader = nfc_open (connstrings[1]);
printf ("Connected to the NFC reader device: %s", nfc_device_get_name (pndReader));
printf ("NFC reader device: %s opened", nfc_device_get_name (pndReader));
printf ("%s", "Configuring NFC reader settings...");
if (nfc_initiator_init (pndReader) < 0) {

View file

@ -79,14 +79,14 @@ main (int argc, const char *argv[])
}
for (i = 0; i < szFound; i++) {
pnd = nfc_connect (connstrings[i]);
pnd = nfc_open (connstrings[i]);
if (pnd == NULL) {
ERR ("%s", "Unable to connect to NFC device.");
ERR ("%s", "Unable to open NFC device.");
return EXIT_FAILURE;
}
printf ("NFC device [%s] connected.\n", nfc_device_get_name (pnd));
printf ("NFC device [%s] opened.\n", nfc_device_get_name (pnd));
res = pn53x_transceive (pnd, pncmd_diagnose_communication_line_test, sizeof (pncmd_diagnose_communication_line_test), abtRx, szRx, 0);
if (res > 0) {

View file

@ -81,15 +81,15 @@ main (int argc, const char *argv[])
const char *acLibnfcVersion = nfc_version ();
printf ("%s uses libnfc %s\n", argv[0], acLibnfcVersion);
// Connect using the first available NFC device
pnd = nfc_connect (NULL);
// Open using the first available NFC device
pnd = nfc_open (NULL);
if (pnd == NULL) {
ERR ("%s", "Unable to connect to NFC device.");
ERR ("%s", "Unable to open NFC device.");
return EXIT_FAILURE;
}
printf ("Connected to NFC device: %s\n", nfc_device_get_name (pnd));
printf ("NFC device: %s opened\n", nfc_device_get_name (pnd));
// Print the example's menu
printf ("\nSelect the communication mode:\n");
@ -127,7 +127,7 @@ main (int argc, const char *argv[])
{
nfc_target nt;
// Set connected NFC device to initiator mode
// Set opened NFC device to initiator mode
if (nfc_initiator_init (pnd) < 0) {
nfc_perror (pnd, "nfc_initiator_init");
exit (EXIT_FAILURE);
@ -189,7 +189,7 @@ main (int argc, const char *argv[])
// Disconnect from the SAM
pn53x_SAMConfiguration (pnd, PSM_NORMAL, 0);
// Disconnect from NFC device
// Close NFC device
nfc_close (pnd);
exit (EXIT_SUCCESS);

View file

@ -87,14 +87,14 @@ int main(int argc, const char* argv[])
}
// Try to open the NFC reader
pnd = nfc_connect(NULL);
pnd = nfc_open(NULL);
if (pnd == NULL) {
ERR ("%s", "Unable to connect to NFC device.");
ERR ("%s", "Unable to open NFC device.");
return EXIT_FAILURE;
}
printf ("Connected to NFC reader: %s\n", nfc_device_get_name (pnd));
printf ("NFC reader: %s opened\n", nfc_device_get_name (pnd));
if (nfc_initiator_init (pnd) < 0) {
nfc_perror (pnd, "nfc_initiator_init");
exit (EXIT_FAILURE);