diff --git a/examples/doc/quick_start_example1.c b/examples/doc/quick_start_example1.c index 2273618..18b35e6 100644 --- a/examples/doc/quick_start_example1.c +++ b/examples/doc/quick_start_example1.c @@ -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; } diff --git a/examples/nfc-anticol.c b/examples/nfc-anticol.c index f211931..c48517c 100644 --- a/examples/nfc-anticol.c +++ b/examples/nfc-anticol.c @@ -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)) { diff --git a/examples/nfc-dep-initiator.c b/examples/nfc-dep-initiator.c index 7e4c4da..94adf8a 100644 --- a/examples/nfc-dep-initiator.c +++ b/examples/nfc-dep-initiator.c @@ -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); diff --git a/examples/nfc-dep-target.c b/examples/nfc-dep-target.c index ceff103..fa1203c 100644 --- a/examples/nfc-dep-target.c +++ b/examples/nfc-dep-target.c @@ -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); diff --git a/examples/nfc-emulate-forum-tag2.c b/examples/nfc-emulate-forum-tag2.c index feacba5..19fe7c7 100644 --- a/examples/nfc-emulate-forum-tag2.c +++ b/examples/nfc-emulate-forum-tag2.c @@ -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) { diff --git a/examples/nfc-emulate-tag.c b/examples/nfc-emulate-tag.c index 25bbb67..93dd0b6 100644 --- a/examples/nfc-emulate-tag.c +++ b/examples/nfc-emulate-tag.c @@ -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 diff --git a/examples/nfc-emulate-uid.c b/examples/nfc-emulate-uid.c index 5609fd0..d2854cb 100644 --- a/examples/nfc-emulate-uid.c +++ b/examples/nfc-emulate-uid.c @@ -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"); diff --git a/examples/nfc-poll.c b/examples/nfc-poll.c index 8ebe9c4..d800a14 100644 --- a/examples/nfc-poll.c +++ b/examples/nfc-poll.c @@ -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"); diff --git a/examples/nfc-relay.c b/examples/nfc-relay.c index 8be7b29..4fad476 100644 --- a/examples/nfc-relay.c +++ b/examples/nfc-relay.c @@ -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) { diff --git a/examples/pn53x-diagnose.c b/examples/pn53x-diagnose.c index 649f6e9..46f0532 100644 --- a/examples/pn53x-diagnose.c +++ b/examples/pn53x-diagnose.c @@ -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) { diff --git a/examples/pn53x-sam.c b/examples/pn53x-sam.c index 085b9ed..9745149 100644 --- a/examples/pn53x-sam.c +++ b/examples/pn53x-sam.c @@ -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); diff --git a/examples/pn53x-tamashell.c b/examples/pn53x-tamashell.c index 7f5937d..7d23100 100644 --- a/examples/pn53x-tamashell.c +++ b/examples/pn53x-tamashell.c @@ -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); diff --git a/include/nfc/nfc.h b/include/nfc/nfc.h index 762316b..cdbf404 100644 --- a/include/nfc/nfc.h +++ b/include/nfc/nfc.h @@ -64,7 +64,7 @@ extern "C" { /* NFC Device/Hardware manipulation */ NFC_EXPORT bool nfc_get_default_device (nfc_connstring *connstring); - NFC_EXPORT nfc_device *nfc_connect (const nfc_connstring connstring); + NFC_EXPORT nfc_device *nfc_open (const nfc_connstring connstring); NFC_EXPORT void nfc_close (nfc_device *pnd); NFC_EXPORT int nfc_abort_command (nfc_device *pnd); NFC_EXPORT size_t nfc_list_devices (nfc_connstring connstrings[], size_t connstrings_len); diff --git a/libnfc/drivers/acr122.c b/libnfc/drivers/acr122.c index 9dc688b..7be531a 100644 --- a/libnfc/drivers/acr122.c +++ b/libnfc/drivers/acr122.c @@ -124,7 +124,7 @@ acr122_free_scardcontext (void) #define PCSC_MAX_DEVICES 16 /** - * @brief List connected devices + * @brief List opened devices * * Probe PCSC to find NFC capable hardware. * @@ -241,7 +241,7 @@ acr122_connstring_decode (const nfc_connstring connstring, struct acr122_descrip } nfc_device * -acr122_connect (const nfc_connstring connstring) +acr122_open (const nfc_connstring connstring) { struct acr122_descriptor ndd; int connstring_decode_level = acr122_connstring_decode (connstring, &ndd); @@ -249,7 +249,7 @@ acr122_connect (const nfc_connstring connstring) if (connstring_decode_level < 2) { return NULL; } - // FIXME: acr122_connect() does not take care about bus index + // FIXME: acr122_open() does not take care about bus index char *pcFirmware; nfc_device *pnd = nfc_device_new (); @@ -260,7 +260,7 @@ acr122_connect (const nfc_connstring connstring) SCARDCONTEXT *pscc; - log_put (LOG_CATEGORY, NFC_PRIORITY_TRACE, "Attempt to connect to %s", ndd.pcsc_device_name); + log_put (LOG_CATEGORY, NFC_PRIORITY_TRACE, "Attempt to open %s", ndd.pcsc_device_name); // Test if context succeeded if (!(pscc = acr122_get_scardcontext ())) goto error; @@ -466,7 +466,7 @@ const struct pn53x_io acr122_io = { const struct nfc_driver acr122_driver = { .name = ACR122_DRIVER_NAME, .probe = acr122_probe, - .connect = acr122_connect, + .open = acr122_open, .close = acr122_close, .strerror = pn53x_strerror, diff --git a/libnfc/drivers/acr122.h b/libnfc/drivers/acr122.h index 98c2c1c..5c2ba98 100644 --- a/libnfc/drivers/acr122.h +++ b/libnfc/drivers/acr122.h @@ -29,7 +29,7 @@ bool acr122_probe (nfc_connstring connstrings[], size_t connstrings_len, size_t *pszDeviceFound); // Functions used by developer to handle connection to this device -nfc_device *acr122_connect (const nfc_connstring connstring); +nfc_device *acr122_open (const nfc_connstring connstring); int acr122_send (nfc_device *pnd, const uint8_t *pbtData, const size_t szData, int timeout); int acr122_receive (nfc_device *pnd, uint8_t *pbtData, const size_t szData, int timeout); void acr122_close (nfc_device *pnd); diff --git a/libnfc/drivers/arygon.c b/libnfc/drivers/arygon.c index c6694a6..0b64d2f 100644 --- a/libnfc/drivers/arygon.c +++ b/libnfc/drivers/arygon.c @@ -216,7 +216,7 @@ arygon_connstring_decode (const nfc_connstring connstring, struct arygon_descrip } nfc_device * -arygon_connect (const nfc_connstring connstring) +arygon_open (const nfc_connstring connstring) { struct arygon_descriptor ndd; int connstring_decode_level = arygon_connstring_decode (connstring, &ndd); @@ -230,7 +230,7 @@ arygon_connect (const nfc_connstring connstring) serial_port sp; nfc_device *pnd = NULL; - log_put (LOG_CATEGORY, NFC_PRIORITY_TRACE, "Attempt to connect to: %s at %d bauds.", ndd.port, ndd.speed); + log_put (LOG_CATEGORY, NFC_PRIORITY_TRACE, "Attempt to open: %s at %d bauds.", ndd.port, ndd.speed); sp = uart_open (ndd.port); if (sp == INVALID_SERIAL_PORT) @@ -254,7 +254,7 @@ arygon_connect (const nfc_connstring connstring) // Alloc and init chip's data pn53x_data_new (pnd, &arygon_tama_io); - // The PN53x chip connected to ARYGON MCU doesn't seems to be in LowVBat mode + // The PN53x chip opened to ARYGON MCU doesn't seems to be in LowVBat mode CHIP_DATA (pnd)->power_mode = NORMAL; // empirical tuning @@ -560,7 +560,7 @@ const struct pn53x_io arygon_tama_io = { const struct nfc_driver arygon_driver = { .name = ARYGON_DRIVER_NAME, .probe = arygon_probe, - .connect = arygon_connect, + .open = arygon_open, .close = arygon_close, .strerror = pn53x_strerror, diff --git a/libnfc/drivers/arygon.h b/libnfc/drivers/arygon.h index c324e93..711a9c1 100644 --- a/libnfc/drivers/arygon.h +++ b/libnfc/drivers/arygon.h @@ -32,7 +32,7 @@ bool arygon_probe (nfc_connstring connstrings[], size_t connstrings_len, size_t *pszDeviceFound); -nfc_device *arygon_connect (const nfc_connstring connstring); +nfc_device *arygon_open (const nfc_connstring connstring); void arygon_close (nfc_device *pnd); int arygon_tama_send (nfc_device *pnd, const uint8_t *pbtData, const size_t szData, int timeout); diff --git a/libnfc/drivers/pn532_uart.c b/libnfc/drivers/pn532_uart.c index 7c4cad9..251da1a 100644 --- a/libnfc/drivers/pn532_uart.c +++ b/libnfc/drivers/pn532_uart.c @@ -91,7 +91,7 @@ pn532_uart_probe (nfc_connstring connstrings[], size_t connstrings_len, size_t * if ((sp != INVALID_SERIAL_PORT) && (sp != CLAIMED_SERIAL_PORT)) { // We need to flush input to be sure first reply does not comes from older byte transceive uart_flush_input (sp); - // Serial port claimed but we need to check if a PN532_UART is connected. + // Serial port claimed but we need to check if a PN532_UART is opened. uart_set_speed (sp, PN532_UART_DEFAULT_SPEED); nfc_device *pnd = nfc_device_new (); @@ -194,7 +194,7 @@ pn532_connstring_decode (const nfc_connstring connstring, struct pn532_uart_desc } nfc_device * -pn532_uart_connect (const nfc_connstring connstring) +pn532_uart_open (const nfc_connstring connstring) { struct pn532_uart_descriptor ndd; int connstring_decode_level = pn532_connstring_decode (connstring, &ndd); @@ -208,7 +208,7 @@ pn532_uart_connect (const nfc_connstring connstring) serial_port sp; nfc_device *pnd = NULL; - log_put (LOG_CATEGORY, NFC_PRIORITY_TRACE, "Attempt to connect to: %s at %d bauds.", ndd.port, ndd.speed); + log_put (LOG_CATEGORY, NFC_PRIORITY_TRACE, "Attempt to open: %s at %d bauds.", ndd.port, ndd.speed); sp = uart_open (ndd.port); if (sp == INVALID_SERIAL_PORT) @@ -503,7 +503,7 @@ const struct pn53x_io pn532_uart_io = { const struct nfc_driver pn532_uart_driver = { .name = PN532_UART_DRIVER_NAME, .probe = pn532_uart_probe, - .connect = pn532_uart_connect, + .open = pn532_uart_open, .close = pn532_uart_close, .strerror = pn53x_strerror, diff --git a/libnfc/drivers/pn532_uart.h b/libnfc/drivers/pn532_uart.h index 9b55347..c066e75 100644 --- a/libnfc/drivers/pn532_uart.h +++ b/libnfc/drivers/pn532_uart.h @@ -31,7 +31,7 @@ bool pn532_uart_probe (nfc_connstring connstrings[], size_t connstrings_len, size_t *pszDeviceFound); -nfc_device *pn532_uart_connect (const nfc_connstring connstring); +nfc_device *pn532_uart_open (const nfc_connstring connstring); void pn532_uart_close (nfc_device *pnd); int pn532_uart_send (nfc_device *pnd, const uint8_t *pbtData, const size_t szData, int timeout); int pn532_uart_receive (nfc_device *pnd, uint8_t *pbtData, const size_t szData, int timeout); diff --git a/libnfc/drivers/pn53x_usb.c b/libnfc/drivers/pn53x_usb.c index d42849e..8bf97cd 100644 --- a/libnfc/drivers/pn53x_usb.c +++ b/libnfc/drivers/pn53x_usb.c @@ -366,7 +366,7 @@ pn53x_usb_get_usb_device_name (struct usb_device *dev, usb_dev_handle *udev, cha } nfc_device * -pn53x_usb_connect (const nfc_connstring connstring) +pn53x_usb_open (const nfc_connstring connstring) { struct pn53x_usb_descriptor desc; int connstring_decode_level = pn53x_usb_connstring_decode (connstring, &desc); @@ -793,7 +793,7 @@ const struct pn53x_io pn53x_usb_io = { const struct nfc_driver pn53x_usb_driver = { .name = PN53X_USB_DRIVER_NAME, .probe = pn53x_usb_probe, - .connect = pn53x_usb_connect, + .open = pn53x_usb_open, .close = pn53x_usb_close, .strerror = pn53x_strerror, diff --git a/libnfc/drivers/pn53x_usb.h b/libnfc/drivers/pn53x_usb.h index 0827016..ac27b9b 100644 --- a/libnfc/drivers/pn53x_usb.h +++ b/libnfc/drivers/pn53x_usb.h @@ -30,7 +30,7 @@ # include bool pn53x_usb_probe (nfc_connstring connstrings[], size_t connstrings_len, size_t *pszDeviceFound); -nfc_device *pn53x_usb_connect (const nfc_connstring connstring); +nfc_device *pn53x_usb_open (const nfc_connstring connstring); int pn53x_usb_send (nfc_device *pnd, const uint8_t *pbtData, const size_t szData, int timeout); int pn53x_usb_receive (nfc_device *pnd, uint8_t *pbtData, const size_t szData, int timeout); void pn53x_usb_close (nfc_device *pnd); diff --git a/libnfc/nfc-internal.h b/libnfc/nfc-internal.h index 76f2731..c9bdf1d 100644 --- a/libnfc/nfc-internal.h +++ b/libnfc/nfc-internal.h @@ -128,7 +128,7 @@ struct nfc_driver { const char *name; bool (*probe)(nfc_connstring connstrings[], size_t connstrings_len, size_t * pszDeviceFound); - struct nfc_device *(*connect) (const nfc_connstring connstring); + struct nfc_device *(*open) (const nfc_connstring connstring); void (*close) (struct nfc_device *pnd); const char *(*strerror) (const struct nfc_device *pnd); diff --git a/libnfc/nfc.c b/libnfc/nfc.c index d97a9e3..6abc614 100644 --- a/libnfc/nfc.c +++ b/libnfc/nfc.c @@ -95,7 +95,7 @@ nfc_get_default_device (nfc_connstring *connstring) } /** - * @brief Connect to a NFC device + * @brief Open a NFC device * @param connstring The device connection string if specific device is wanted, \c NULL otherwise * @return Returns pointer to a \a nfc_device struct if successfull; otherwise returns \c NULL value. * @@ -111,7 +111,7 @@ nfc_get_default_device (nfc_connstring *connstring) * optionally followed by manual tuning of the parameters if the default parameters are not suiting your goals. */ nfc_device * -nfc_connect (const nfc_connstring connstring) +nfc_open (const nfc_connstring connstring) { log_init (); nfc_device *pnd = NULL; @@ -136,10 +136,10 @@ nfc_connect (const nfc_connstring connstring) continue; } - pnd = ndr->connect (ncs); - // Test if the connection was successful + pnd = ndr->open (ncs); + // Test if the opening was successful if (pnd == NULL) { - log_put (LOG_CATEGORY, NFC_PRIORITY_TRACE, "Unable to connect to \"%s\".", ncs); + log_put (LOG_CATEGORY, NFC_PRIORITY_TRACE, "Unable to open \"%s\".", ncs); log_fini (); return pnd; } @@ -167,7 +167,7 @@ nfc_close (nfc_device *pnd) if (pnd) { // Go in idle mode nfc_idle (pnd); - // Disconnect, clean up and release the device + // Close, clean up and release the device pnd->driver->close (pnd); log_fini (); diff --git a/test/test_access_storm.c b/test/test_access_storm.c index b80b6d0..e934cee 100644 --- a/test/test_access_storm.c +++ b/test/test_access_storm.c @@ -31,8 +31,8 @@ test_access_storm (void) nfc_device *device; nfc_target ant[MAX_TARGET_COUNT]; - device = nfc_connect (connstrings[i]); - cut_assert_not_null (device, cut_message ("nfc_connect")); + device = nfc_open (connstrings[i]); + cut_assert_not_null (device, cut_message ("nfc_open")); res = nfc_initiator_init(device); cut_assert_equal_int (0, res, cut_message ("nfc_initiator_init")); diff --git a/test/test_dep_active.c b/test/test_dep_active.c index a419044..58dda2c 100644 --- a/test/test_dep_active.c +++ b/test/test_dep_active.c @@ -32,8 +32,8 @@ cut_setup (void) cut_omit ("At least two NFC devices must be plugged-in to run this test"); } - devices[TARGET] = nfc_connect (connstrings[TARGET]); - devices[INITIATOR] = nfc_connect (connstrings[INITIATOR]); + devices[TARGET] = nfc_open (connstrings[TARGET]); + devices[INITIATOR] = nfc_open (connstrings[INITIATOR]); signal (SIGINT, abort_test_by_keypress); } diff --git a/test/test_dep_passive.c b/test/test_dep_passive.c index 6e55200..fb8cae6 100644 --- a/test/test_dep_passive.c +++ b/test/test_dep_passive.c @@ -31,8 +31,8 @@ cut_setup (void) cut_omit ("At least two NFC devices must be plugged-in to run this test"); } - devices[TARGET] = nfc_connect (connstrings[TARGET]); - devices[INITIATOR] = nfc_connect (connstrings[INITIATOR]); + devices[TARGET] = nfc_open (connstrings[TARGET]); + devices[INITIATOR] = nfc_open (connstrings[INITIATOR]); signal (SIGINT, abort_test_by_keypress); } diff --git a/test/test_device_modes_as_dep.c b/test/test_device_modes_as_dep.c index 3f5a297..04e1c48 100644 --- a/test/test_device_modes_as_dep.c +++ b/test/test_device_modes_as_dep.c @@ -29,8 +29,8 @@ cut_setup (void) cut_omit ("At least two NFC devices must be plugged-in to run this test"); } - second_device = nfc_connect (connstrings[0]); - first_device = nfc_connect (connstrings[1]); + second_device = nfc_open (connstrings[0]); + first_device = nfc_open (connstrings[1]); signal (SIGINT, abort_test_by_keypress); } diff --git a/test/test_register_access.c b/test/test_register_access.c index aa37994..d073cf9 100644 --- a/test/test_register_access.c +++ b/test/test_register_access.c @@ -18,8 +18,8 @@ test_register_endianness (void) nfc_device *device; - device = nfc_connect (connstrings[0]); - cut_assert_not_null (device, cut_message ("nfc_connect")); + device = nfc_open (connstrings[0]); + cut_assert_not_null (device, cut_message ("nfc_open")); uint8_t value; diff --git a/test/test_register_endianness.c b/test/test_register_endianness.c index 6c7ce7e..ab3dd70 100644 --- a/test/test_register_endianness.c +++ b/test/test_register_endianness.c @@ -19,8 +19,8 @@ test_register_endianness (void) nfc_device *device; - device = nfc_connect (connstrings[0]); - cut_assert_not_null (device, cut_message ("nfc_connect")); + device = nfc_open (connstrings[0]); + cut_assert_not_null (device, cut_message ("nfc_open")); uint8_t value; diff --git a/utils/nfc-emulate-forum-tag4.c b/utils/nfc-emulate-forum-tag4.c index 321b601..403bbd1 100644 --- a/utils/nfc-emulate-forum-tag4.c +++ b/utils/nfc-emulate-forum-tag4.c @@ -347,16 +347,16 @@ main (int argc, char *argv[]) } // Try to open the NFC reader - 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); } signal (SIGINT, stop_emulation); - 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 (0 != nfc_emulate_target (pnd, &emulator)) { // contains already nfc_target_init() call diff --git a/utils/nfc-list.c b/utils/nfc-list.c index 48c2466..876c569 100644 --- a/utils/nfc-list.c +++ b/utils/nfc-list.c @@ -95,7 +95,7 @@ main (int argc, const char *argv[]) /* Lazy way to open an NFC device */ #if 0 - pnd = nfc_connect (NULL); + pnd = nfc_open (NULL); #endif /* If specific device is wanted, i.e. an ARYGON device on /dev/ttyUSB0 */ @@ -104,7 +104,7 @@ main (int argc, const char *argv[]) ndd.pcDriver = "ARYGON"; ndd.pcPort = "/dev/ttyUSB0"; ndd.uiSpeed = 115200; - pnd = nfc_connect (&ndd); + pnd = nfc_open (&ndd); #endif /* If specific device is wanted, i.e. a SCL3711 on USB */ @@ -112,7 +112,7 @@ main (int argc, const char *argv[]) nfc_device_desc_t ndd; ndd.pcDriver = "PN533_USB"; strcpy(ndd.acDevice, "SCM Micro / SCL3711-NFC&RW"); - pnd = nfc_connect (&ndd); + pnd = nfc_open (&ndd); #endif nfc_connstring connstrings[MAX_DEVICE_COUNT]; size_t szDeviceFound = nfc_list_devices (connstrings, MAX_DEVICE_COUNT); @@ -123,10 +123,10 @@ main (int argc, const char *argv[]) for (i = 0; i < szDeviceFound; i++) { nfc_target ant[MAX_TARGET_COUNT]; - 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; } if (nfc_initiator_init (pnd) < 0) { @@ -134,7 +134,7 @@ main (int argc, const char *argv[]) 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)); nfc_modulation nm; diff --git a/utils/nfc-mfclassic.c b/utils/nfc-mfclassic.c index 91efcd4..686cd30 100644 --- a/utils/nfc-mfclassic.c +++ b/utils/nfc-mfclassic.c @@ -538,9 +538,9 @@ main (int argc, const char *argv[]) // printf("Successfully opened required files\n"); // Try to open the NFC reader - pnd = nfc_connect (NULL); + pnd = nfc_open (NULL); if (pnd == NULL) { - printf ("Error connecting NFC reader\n"); + printf ("Error opening NFC reader\n"); exit (EXIT_FAILURE); } @@ -557,7 +557,7 @@ main (int argc, const char *argv[]) // Disable ISO14443-4 switching in order to read devices that emulate Mifare Classic with ISO14443-4 compliance. nfc_device_set_property_bool (pnd, NP_AUTO_ISO14443_4, false); - printf ("Connected to NFC reader: %s\n", nfc_device_get_name (pnd)); + printf ("NFC reader: %s opened\n", nfc_device_get_name (pnd)); // Try to find a MIFARE Classic tag if (nfc_initiator_select_passive_target (pnd, nmMifare, NULL, 0, &nt) < 0) { diff --git a/utils/nfc-mfsetuid.c b/utils/nfc-mfsetuid.c index 7304b27..470b821 100644 --- a/utils/nfc-mfsetuid.c +++ b/utils/nfc-mfsetuid.c @@ -178,10 +178,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); } @@ -207,7 +207,7 @@ main (int argc, 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)); // Send the 7 bits request command specified in ISO 14443A (0x26) if (!transmit_bits (abtReqa, 7)) { diff --git a/utils/nfc-mfultralight.c b/utils/nfc-mfultralight.c index e37646a..7959f31 100644 --- a/utils/nfc-mfultralight.c +++ b/utils/nfc-mfultralight.c @@ -205,9 +205,9 @@ main (int argc, const char *argv[]) DBG ("Successfully opened the dump file\n"); // Try to open the NFC device - pnd = nfc_connect (NULL); + pnd = nfc_open (NULL); if (pnd == NULL) { - ERR ("Error connecting NFC device\n"); + ERR ("Error opening NFC device\n"); return 1; } @@ -222,7 +222,7 @@ main (int argc, const char *argv[]) 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)); // Try to find a MIFARE Ultralight tag if (nfc_initiator_select_passive_target (pnd, nmMifare, NULL, 0, &nt) < 0) { diff --git a/utils/nfc-read-forum-tag3.c b/utils/nfc-read-forum-tag3.c index 6eda7da..8d42efe 100644 --- a/utils/nfc-read-forum-tag3.c +++ b/utils/nfc-read-forum-tag3.c @@ -195,14 +195,14 @@ main(int argc, char *argv[]) } } - 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); } - fprintf (message_stream, "Connected to NFC device: %s\n", nfc_device_get_name (pnd)); + fprintf (message_stream, "NFC device: %s opened\n", nfc_device_get_name (pnd)); nfc_modulation nm = { .nmt = NMT_FELICA, diff --git a/utils/nfc-relay-picc.c b/utils/nfc-relay-picc.c index 4dcf884..44b32e6 100644 --- a/utils/nfc-relay-picc.c +++ b/utils/nfc-relay-picc.c @@ -204,7 +204,7 @@ main (int argc, char *argv[]) } else { 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; } } @@ -213,20 +213,20 @@ main (int argc, char *argv[]) // Try to open the NFC reader used as initiator // Little hack to allow using initiator no matter if // there is already a target used locally or not on the same machine: - // if there is more than one readers connected we connect to the second reader + // if there is more than one readers opened we open the second reader // (we hope they're always detected in the same order) if (szFound == 1) { - pndInitiator = nfc_connect (connstrings[0]); + pndInitiator = nfc_open (connstrings[0]); } else { - pndInitiator = nfc_connect (connstrings[1]); + pndInitiator = nfc_open (connstrings[1]); } if (!pndInitiator) { - printf ("Error connecting NFC reader\n"); + printf ("Error opening NFC reader\n"); exit(EXIT_FAILURE); } - printf ("Connected to the NFC reader device: %s\n", nfc_device_get_name (pndInitiator)); + printf ("NFC reader device: %s opened\n", nfc_device_get_name (pndInitiator)); if (nfc_initiator_init (pndInitiator) < 0) { printf ("Error: fail initializing initiator\n"); @@ -342,16 +342,16 @@ main (int argc, char *argv[]) print_nfc_iso14443a_info (ntEmulatedTarget.nti.nai, false); // Try to open the NFC emulator device - pndTarget = nfc_connect (connstrings[0]); + pndTarget = nfc_open (connstrings[0]); if (pndTarget == NULL) { - printf ("Error connecting NFC emulator device\n"); + printf ("Error opening NFC emulator device\n"); if (!target_only_mode) { nfc_close (pndInitiator); } return EXIT_FAILURE; } - printf ("Connected to the NFC emulator device: %s\n", nfc_device_get_name (pndTarget)); + printf ("NFC emulator device: %s opened\n", nfc_device_get_name (pndTarget)); szCapduLen = sizeof (abtCapdu); if (nfc_target_init (pndTarget, &ntEmulatedTarget, abtCapdu, szCapduLen, 0) < 0) {