Allow to connect to a device using a connection string:

- Provide a nfc_get_default_device() that allow to grab the connstring stored
   in LIBNFC_DEFAULT_DEVICE environnement variable or returns the first
   available device if not set;
 - nfc_connect(NULL) now takes the default device (see
   nfc_get_default_device());
 - Removes nfc_driver_desc_t from public types
 - Defines nfc_connstring as char[1024]
 - examples/*: use nfc_connstring
 - examples/nfc-poll: now uses only the default device (instead of all devices
   availables)
 - Removes parse_args() from nfc-utils.[hc]
This commit is contained in:
Romuald Conty 2011-10-17 13:03:56 +00:00
parent dc842a844c
commit 55daa29a7c
20 changed files with 559 additions and 380 deletions

View file

@ -71,24 +71,7 @@ typedef struct {
int iLastError;
} nfc_device_t;
/**
* @struct nfc_device_desc_t
* @brief NFC device description
*
* This struct is used to try to connect to a specified nfc device when nfc_connect(...)
*/
typedef struct {
/** Device name (e.g. "ACS ACR 38U-CCID 00 00") */
char acDevice[DEVICE_NAME_LENGTH];
/** Driver name (e.g. "PN532_UART")*/
char *pcDriver;
/** Port (e.g. "/dev/ttyUSB0") */
char acPort[DEVICE_PORT_LENGTH];
/** Port speed (e.g. "115200") */
uint32_t uiSpeed;
/** Device index for backward compatibility (used to choose one specific device in USB or PSCS devices list) */
uint32_t uiBusIndex;
} nfc_device_desc_t;
typedef char nfc_connstring[1024];
// Compiler directive, set struct alignment to 1 byte_t for compatibility
# pragma pack(1)

View file

@ -63,10 +63,11 @@ extern "C" {
# endif // __cplusplus
/* NFC Device/Hardware manipulation */
NFC_EXPORT nfc_device_t *nfc_connect (nfc_device_desc_t * pndd);
NFC_EXPORT bool nfc_get_default_device (nfc_connstring *connstring);
NFC_EXPORT nfc_device_t *nfc_connect (const nfc_connstring connstring);
NFC_EXPORT void nfc_disconnect (nfc_device_t * pnd);
NFC_EXPORT bool nfc_abort_command (nfc_device_t * pnd);
NFC_EXPORT void nfc_list_devices (nfc_device_desc_t pnddDevices[], size_t szDevices, size_t * pszDeviceFound);
NFC_EXPORT void nfc_list_devices (nfc_connstring connstrings[], size_t connstrings_len, size_t * pszDeviceFound);
NFC_EXPORT bool nfc_configure (nfc_device_t * pnd, const nfc_device_option_t ndo, const bool bEnable);
NFC_EXPORT bool nfc_idle (nfc_device_t * pnd);