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:
parent
dc842a844c
commit
55daa29a7c
20 changed files with 559 additions and 380 deletions
|
|
@ -670,51 +670,6 @@ print_nfc_dep_info (const nfc_dep_info_t ndi, bool verbose)
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Tries to parse arguments to find device descriptions.
|
||||
* @return Returns the list of found device descriptions.
|
||||
*/
|
||||
nfc_device_desc_t *
|
||||
parse_args (int argc, const char *argv[], size_t * szFound, bool * verbose)
|
||||
{
|
||||
nfc_device_desc_t *pndd = 0;
|
||||
int arg;
|
||||
*szFound = 0;
|
||||
|
||||
// Get commandline options
|
||||
for (arg = 1; arg < argc; arg++) {
|
||||
|
||||
if (0 == strcmp (argv[arg], "--device")) {
|
||||
// FIXME: this device selection by command line options is terrible & does not support USB/PCSC drivers
|
||||
if (argc > arg + 1) {
|
||||
char buffer[256];
|
||||
|
||||
pndd = malloc (sizeof (nfc_device_desc_t));
|
||||
|
||||
strncpy (buffer, argv[++arg], 256);
|
||||
|
||||
// Driver.
|
||||
pndd->pcDriver = (char *) malloc (256);
|
||||
strcpy (pndd->pcDriver, strtok (buffer, ":"));
|
||||
|
||||
// Port.
|
||||
strcpy (pndd->acPort, strtok (NULL, ":"));
|
||||
|
||||
// Speed.
|
||||
sscanf (strtok (NULL, ":"), "%u", &pndd->uiSpeed);
|
||||
|
||||
*szFound = 1;
|
||||
} else {
|
||||
errx (1, "usage: %s [--device driver:port:speed]", argv[0]);
|
||||
}
|
||||
}
|
||||
if ((0 == strcmp (argv[arg], "-v")) || (0 == strcmp (argv[arg], "--verbose"))) {
|
||||
*verbose = true;
|
||||
}
|
||||
}
|
||||
return pndd;
|
||||
}
|
||||
|
||||
const char *
|
||||
str_nfc_baud_rate (const nfc_baud_rate_t nbr)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue