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
|
|
@ -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 ();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue