check result of nfc_initiator_init() function in examples/ and utils/
This commit is contained in:
parent
331234713d
commit
5a1f0c2115
11 changed files with 45 additions and 11 deletions
|
@ -26,7 +26,10 @@ main (int argc, const char *argv[])
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
// Set connected NFC device to initiator mode
|
// Set connected NFC device to initiator mode
|
||||||
nfc_initiator_init (pnd);
|
if (nfc_initiator_init (pnd) < 0) {
|
||||||
|
nfc_perror (pnd, "nfc_initiator_init");
|
||||||
|
exit (EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
printf ("Connected to NFC reader: %s\n", nfc_device_get_name (pnd));
|
printf ("Connected to NFC reader: %s\n", nfc_device_get_name (pnd));
|
||||||
|
|
||||||
|
|
|
@ -157,7 +157,10 @@ main (int argc, char *argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialise NFC device as "initiator"
|
// Initialise NFC device as "initiator"
|
||||||
nfc_initiator_init (pnd);
|
if (nfc_initiator_init (pnd) < 0) {
|
||||||
|
nfc_perror (pnd, "nfc_initiator_init");
|
||||||
|
exit (EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
// Configure the CRC
|
// Configure the CRC
|
||||||
if (nfc_device_set_property_bool (pnd, NP_HANDLE_CRC, false) < 0) {
|
if (nfc_device_set_property_bool (pnd, NP_HANDLE_CRC, false) < 0) {
|
||||||
|
|
|
@ -110,7 +110,10 @@ main (int argc, const char *argv[])
|
||||||
exit (EXIT_FAILURE);
|
exit (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
nfc_initiator_init (pnd);
|
if (nfc_initiator_init (pnd) < 0) {
|
||||||
|
nfc_perror (pnd, "nfc_initiator_init");
|
||||||
|
exit (EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
printf ("Connected to NFC reader: %s\n", nfc_device_get_name (pnd));
|
printf ("Connected to NFC reader: %s\n", nfc_device_get_name (pnd));
|
||||||
printf ("NFC device will poll during %ld ms (%u pollings of %lu ms for %zd modulations)\n", (unsigned long) uiPollNr * szModulations * uiPeriod * 150, uiPollNr, (unsigned long) uiPeriod * 150, szModulations);
|
printf ("NFC device will poll during %ld ms (%u pollings of %lu ms for %zd modulations)\n", (unsigned long) uiPollNr * szModulations * uiPeriod * 150, uiPollNr, (unsigned long) uiPeriod * 150, szModulations);
|
||||||
|
|
|
@ -164,7 +164,11 @@ main (int argc, char *argv[])
|
||||||
|
|
||||||
printf ("Connected to the NFC reader device: %s", nfc_device_get_name (pndReader));
|
printf ("Connected to the NFC reader device: %s", nfc_device_get_name (pndReader));
|
||||||
printf ("%s", "Configuring NFC reader settings...");
|
printf ("%s", "Configuring NFC reader settings...");
|
||||||
nfc_initiator_init (pndReader);
|
|
||||||
|
if (nfc_initiator_init (pndReader) < 0) {
|
||||||
|
nfc_perror (pndReader, "nfc_initiator_init");
|
||||||
|
exit (EXIT_FAILURE);
|
||||||
|
}
|
||||||
if ((nfc_device_set_property_bool (pndReader, NP_HANDLE_CRC, false) < 0) ||
|
if ((nfc_device_set_property_bool (pndReader, NP_HANDLE_CRC, false) < 0) ||
|
||||||
(nfc_device_set_property_bool (pndReader, NP_HANDLE_PARITY, false) < 0) ||
|
(nfc_device_set_property_bool (pndReader, NP_HANDLE_PARITY, false) < 0) ||
|
||||||
(nfc_device_set_property_bool (pndReader, NP_ACCEPT_INVALID_FRAMES, true)) < 0) {
|
(nfc_device_set_property_bool (pndReader, NP_ACCEPT_INVALID_FRAMES, true)) < 0) {
|
||||||
|
|
|
@ -128,7 +128,10 @@ main (int argc, const char *argv[])
|
||||||
nfc_target nt;
|
nfc_target nt;
|
||||||
|
|
||||||
// Set connected NFC device to initiator mode
|
// Set connected NFC device to initiator mode
|
||||||
nfc_initiator_init (pnd);
|
if (nfc_initiator_init (pnd) < 0) {
|
||||||
|
nfc_perror (pnd, "nfc_initiator_init");
|
||||||
|
exit (EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
// Let the reader only try once to find a tag
|
// Let the reader only try once to find a tag
|
||||||
if (nfc_device_set_property_bool (pnd, NP_INFINITE_SELECT, false) < 0) {
|
if (nfc_device_set_property_bool (pnd, NP_INFINITE_SELECT, false) < 0) {
|
||||||
|
|
|
@ -95,7 +95,10 @@ int main(int argc, const char* argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
printf ("Connected to NFC reader: %s\n", nfc_device_get_name (pnd));
|
printf ("Connected to NFC reader: %s\n", nfc_device_get_name (pnd));
|
||||||
nfc_initiator_init(pnd);
|
if (nfc_initiator_init (pnd) < 0) {
|
||||||
|
nfc_perror (pnd, "nfc_initiator_init");
|
||||||
|
exit (EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
char *cmd;
|
char *cmd;
|
||||||
char *prompt = "> ";
|
char *prompt = "> ";
|
||||||
|
|
|
@ -130,7 +130,10 @@ main (int argc, const char *argv[])
|
||||||
ERR ("%s", "Unable to connect to NFC device.");
|
ERR ("%s", "Unable to connect to NFC device.");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
nfc_initiator_init (pnd);
|
if (nfc_initiator_init (pnd) < 0) {
|
||||||
|
nfc_perror (pnd, "nfc_initiator_init");
|
||||||
|
exit (EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
printf ("Connected to NFC device: %s\n", nfc_device_get_name (pnd));
|
printf ("Connected to NFC device: %s\n", nfc_device_get_name (pnd));
|
||||||
|
|
||||||
|
|
|
@ -544,7 +544,10 @@ main (int argc, const char *argv[])
|
||||||
exit (EXIT_FAILURE);
|
exit (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
nfc_initiator_init (pnd);
|
if (nfc_initiator_init (pnd) < 0) {
|
||||||
|
nfc_perror (pnd, "nfc_initiator_init");
|
||||||
|
exit (EXIT_FAILURE);
|
||||||
|
};
|
||||||
|
|
||||||
// Let the reader only try once to find a tag
|
// Let the reader only try once to find a tag
|
||||||
if (nfc_device_set_property_bool (pnd, NP_INFINITE_SELECT, false) < 0) {
|
if (nfc_device_set_property_bool (pnd, NP_INFINITE_SELECT, false) < 0) {
|
||||||
|
|
|
@ -186,7 +186,10 @@ main (int argc, char *argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialise NFC device as "initiator"
|
// Initialise NFC device as "initiator"
|
||||||
nfc_initiator_init (pnd);
|
if (nfc_initiator_init (pnd) < 0) {
|
||||||
|
nfc_perror (pnd, "nfc_initiator_init");
|
||||||
|
exit (EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
// Configure the CRC
|
// Configure the CRC
|
||||||
if (nfc_device_set_property_bool (pnd, NP_HANDLE_CRC, false) < 0) {
|
if (nfc_device_set_property_bool (pnd, NP_HANDLE_CRC, false) < 0) {
|
||||||
|
|
|
@ -211,7 +211,10 @@ main (int argc, const char *argv[])
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
nfc_initiator_init (pnd);
|
if (nfc_initiator_init (pnd) < 0) {
|
||||||
|
nfc_perror (pnd, "nfc_initiator_init");
|
||||||
|
exit (EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
// Let the device only try once to find a tag
|
// Let the device only try once to find a tag
|
||||||
if (nfc_device_set_property_bool (pnd, NP_INFINITE_SELECT, false) < 0) {
|
if (nfc_device_set_property_bool (pnd, NP_INFINITE_SELECT, false) < 0) {
|
||||||
|
|
|
@ -213,7 +213,10 @@ main(int argc, char *argv[])
|
||||||
|
|
||||||
nfc_target nt;
|
nfc_target nt;
|
||||||
|
|
||||||
nfc_initiator_init(pnd);
|
if (nfc_initiator_init (pnd) < 0) {
|
||||||
|
nfc_perror (pnd, "nfc_initiator_init");
|
||||||
|
exit (EXIT_FAILURE);
|
||||||
|
}
|
||||||
fprintf (message_stream, "Place your NFC Forum Tag Type 3 in the field...\n");
|
fprintf (message_stream, "Place your NFC Forum Tag Type 3 in the field...\n");
|
||||||
|
|
||||||
int error = EXIT_SUCCESS;
|
int error = EXIT_SUCCESS;
|
||||||
|
|
Loading…
Reference in a new issue