Cleanup of initializations
This commit is contained in:
parent
5f890fedcc
commit
4124dc662d
11 changed files with 85 additions and 159 deletions
|
|
@ -27,9 +27,6 @@ main (int argc, const char *argv[])
|
|||
// Set connected NFC device to initiator mode
|
||||
nfc_initiator_init (pnd);
|
||||
|
||||
// Enable field so more power consuming cards can power themselves up
|
||||
nfc_configure (pnd, NDO_ACTIVATE_FIELD, true);
|
||||
|
||||
printf ("Connected to NFC reader: %s\n", pnd->acName);
|
||||
|
||||
// Poll for a ISO14443A (MIFARE) tag
|
||||
|
|
|
|||
|
|
@ -152,22 +152,11 @@ main (int argc, char *argv[])
|
|||
// Initialise NFC device as "initiator"
|
||||
nfc_initiator_init (pnd);
|
||||
|
||||
// Drop the field for a while
|
||||
if (!nfc_configure (pnd, NDO_ACTIVATE_FIELD, false)) {
|
||||
nfc_perror (pnd, "nfc_configure");
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
// Configure the CRC
|
||||
if (!nfc_configure (pnd, NDO_HANDLE_CRC, false)) {
|
||||
nfc_perror (pnd, "nfc_configure");
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
// Configure parity settings
|
||||
if (!nfc_configure (pnd, NDO_HANDLE_PARITY, true)) {
|
||||
nfc_perror (pnd, "nfc_configure");
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
// Use raw send/receive methods
|
||||
if (!nfc_configure (pnd, NDO_EASY_FRAMING, false)) {
|
||||
nfc_perror (pnd, "nfc_configure");
|
||||
|
|
@ -178,17 +167,6 @@ main (int argc, char *argv[])
|
|||
nfc_perror (pnd, "nfc_configure");
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
// Force 14443-A mode
|
||||
if (!nfc_configure (pnd, NDO_FORCE_ISO14443_A, true)) {
|
||||
nfc_perror (pnd, "nfc_configure");
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
// Enable field so more power consuming cards can power themselves up
|
||||
if (!nfc_configure (pnd, NDO_ACTIVATE_FIELD, true)) {
|
||||
nfc_perror (pnd, "nfc_configure");
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
printf ("Connected to NFC reader: %s\n\n", pnd->acName);
|
||||
|
||||
|
|
|
|||
|
|
@ -352,7 +352,7 @@ main (int argc, char *argv[])
|
|||
printf ("Connected to NFC device: %s\n", pnd->acName);
|
||||
printf ("Emulating NDEF tag now, please touch it with a second NFC device\n");
|
||||
|
||||
nfc_emulate_target (pnd, &emulator);
|
||||
nfc_emulate_target (pnd, &emulator); // contains already nfc_target_init() call
|
||||
|
||||
nfc_disconnect(pnd);
|
||||
|
||||
|
|
|
|||
|
|
@ -436,29 +436,11 @@ main (int argc, const char *argv[])
|
|||
|
||||
nfc_initiator_init (pnd);
|
||||
|
||||
// Drop the field for a while
|
||||
if (!nfc_configure (pnd, NDO_ACTIVATE_FIELD, false)) {
|
||||
nfc_perror (pnd, "nfc_configure");
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
// Let the reader only try once to find a tag
|
||||
if (!nfc_configure (pnd, NDO_INFINITE_SELECT, false)) {
|
||||
nfc_perror (pnd, "nfc_configure");
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
if (!nfc_configure (pnd, NDO_HANDLE_CRC, true)) {
|
||||
nfc_perror (pnd, "nfc_configure");
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
if (!nfc_configure (pnd, NDO_HANDLE_PARITY, true)) {
|
||||
nfc_perror (pnd, "nfc_configure");
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
// Enable field so more power consuming cards can power themselves up
|
||||
if (!nfc_configure (pnd, NDO_ACTIVATE_FIELD, true)) {
|
||||
nfc_perror (pnd, "nfc_configure");
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
// Disable ISO14443-4 switching in order to read devices that emulate Mifare Classic with ISO14443-4 compliance.
|
||||
nfc_configure (pnd, NDO_AUTO_ISO14443_4, false);
|
||||
|
||||
|
|
|
|||
|
|
@ -213,29 +213,11 @@ main (int argc, const char *argv[])
|
|||
|
||||
nfc_initiator_init (pnd);
|
||||
|
||||
// Drop the field for a while
|
||||
if (!nfc_configure (pnd, NDO_ACTIVATE_FIELD, false)) {
|
||||
nfc_perror (pnd, "nfc_configure");
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
// Let the device only try once to find a tag
|
||||
if (!nfc_configure (pnd, NDO_INFINITE_SELECT, false)) {
|
||||
nfc_perror (pnd, "nfc_configure");
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
if (!nfc_configure (pnd, NDO_HANDLE_CRC, true)) {
|
||||
nfc_perror (pnd, "nfc_configure");
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
if (!nfc_configure (pnd, NDO_HANDLE_PARITY, true)) {
|
||||
nfc_perror (pnd, "nfc_configure");
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
// Enable field so more power consuming cards can power themselves up
|
||||
if (!nfc_configure (pnd, NDO_ACTIVATE_FIELD, true)) {
|
||||
nfc_perror (pnd, "nfc_configure");
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
printf ("Connected to NFC device: %s\n", pnd->acName);
|
||||
|
||||
|
|
|
|||
|
|
@ -121,21 +121,11 @@ main (int argc, const char *argv[])
|
|||
}
|
||||
nfc_initiator_init (pnd);
|
||||
|
||||
// Drop the field for a while
|
||||
if (!nfc_configure (pnd, NDO_ACTIVATE_FIELD, false)) {
|
||||
nfc_perror (pnd, "nfc_configure");
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
// Let the reader only try once to find a tag
|
||||
if (!nfc_configure (pnd, NDO_INFINITE_SELECT, false)) {
|
||||
nfc_perror (pnd, "nfc_configure");
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
// Enable field so more power consuming cards can power themselves up
|
||||
if (!nfc_configure (pnd, NDO_ACTIVATE_FIELD, true)) {
|
||||
nfc_perror (pnd, "nfc_configure");
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
printf ("Connected to NFC reader: %s\n", pnd->acName);
|
||||
|
||||
|
|
|
|||
|
|
@ -245,6 +245,12 @@ main (int argc, char *argv[])
|
|||
|
||||
printf ("Connected to the NFC reader device: %s\n", pndInitiator->acName);
|
||||
|
||||
if (!nfc_initiator_init (pndInitiator) {
|
||||
printf ("Error: fail initializing initiator\n");
|
||||
nfc_disconnect (pndInitiator);
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
// Try to find a ISO 14443-4A tag
|
||||
nfc_modulation_t nm = {
|
||||
.nmt = NMT_ISO14443A,
|
||||
|
|
@ -253,7 +259,7 @@ main (int argc, char *argv[])
|
|||
if (!nfc_initiator_select_passive_target (pndInitiator, nm, NULL, 0, &ntRealTarget)) {
|
||||
printf ("Error: no tag was found\n");
|
||||
nfc_disconnect (pndInitiator);
|
||||
exit (EXIT_FAILURE);
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
printf("Found tag:\n");
|
||||
|
|
|
|||
|
|
@ -174,21 +174,11 @@ main (int argc, const char *argv[])
|
|||
// Set connected NFC device to initiator mode
|
||||
nfc_initiator_init (pnd);
|
||||
|
||||
// Drop the field for a while
|
||||
if (!nfc_configure (pnd, NDO_ACTIVATE_FIELD, false)) {
|
||||
nfc_perror (pnd, "nfc_configure");
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
// Let the reader only try once to find a tag
|
||||
if (!nfc_configure (pnd, NDO_INFINITE_SELECT, false)) {
|
||||
nfc_perror (pnd, "nfc_configure");
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
// Enable field so more power consuming cards can power themselves up
|
||||
if (!nfc_configure (pnd, NDO_ACTIVATE_FIELD, true)) {
|
||||
nfc_perror (pnd, "nfc_configure");
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
// Read the SAM's info
|
||||
const nfc_modulation_t nmSAM = {
|
||||
.nmt = NMT_ISO14443A,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue