rename nfc_connect() function to nfc_open().
This commit is contained in:
parent
9eb37b3eee
commit
324af418db
36 changed files with 117 additions and 117 deletions
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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)) {
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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,
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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,
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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,
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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,
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
# include <nfc/nfc-types.h>
|
||||
|
||||
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);
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
12
libnfc/nfc.c
12
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 ();
|
||||
|
|
|
@ -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"));
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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)) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue