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
|
|
@ -66,16 +66,16 @@ main (int argc, const char *argv[])
|
|||
size_t szDeviceFound;
|
||||
byte_t abtTx[] = "Hello Mars!";
|
||||
#define MAX_DEVICE_COUNT 2
|
||||
nfc_device_desc_t pnddDevices[MAX_DEVICE_COUNT];
|
||||
nfc_list_devices (pnddDevices, MAX_DEVICE_COUNT, &szDeviceFound);
|
||||
nfc_connstring connstrings[MAX_DEVICE_COUNT];
|
||||
nfc_list_devices (connstrings, MAX_DEVICE_COUNT, &szDeviceFound);
|
||||
// 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
|
||||
// (we hope they're always detected in the same order)
|
||||
if (szDeviceFound == 1) {
|
||||
pnd = nfc_connect (&(pnddDevices[0]));
|
||||
pnd = nfc_connect (connstrings[0]);
|
||||
} else if (szDeviceFound > 1) {
|
||||
pnd = nfc_connect (&(pnddDevices[1]));
|
||||
pnd = nfc_connect (connstrings[1]);
|
||||
} else {
|
||||
printf("No device found.");
|
||||
return EXIT_FAILURE;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue