add context to nfc_init(), nfc_exit(), nfc_open() and nfc_list_devices() functions.

This commit is contained in:
Audrey Diacre 2012-01-18 16:22:06 +00:00
parent 86c8ce536b
commit 4c011279ff
29 changed files with 142 additions and 138 deletions

View file

@ -66,16 +66,16 @@ main (int argc, const char *argv[])
uint8_t abtTx[] = "Hello Mars!";
#define MAX_DEVICE_COUNT 2
nfc_connstring connstrings[MAX_DEVICE_COUNT];
size_t szDeviceFound = nfc_list_devices (connstrings, MAX_DEVICE_COUNT);
size_t szDeviceFound = nfc_list_devices (NULL, 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 opened
// nfc-dep-target will open the second reader
// (we hope they're always detected in the same order)
nfc_init ();
nfc_init (NULL);
if (szDeviceFound == 1) {
pnd = nfc_open (connstrings[0]);
pnd = nfc_open (NULL, connstrings[0]);
} else if (szDeviceFound > 1) {
pnd = nfc_open (connstrings[1]);
pnd = nfc_open (NULL, connstrings[1]);
} else {
printf("No device found.\n");
return EXIT_FAILURE;
@ -141,6 +141,6 @@ main (int argc, const char *argv[])
error:
nfc_close (pnd);
nfc_exit ();
nfc_exit (NULL);
return EXIT_SUCCESS;
}