astyle --formatted --mode=c --indent=spaces=2 --indent-switches --indent-preprocessor --keep-one-line-blocks --max-instatement-indent=60 --brackets=linux --pad-oper --unpad-paren --pad-header
This commit is contained in:
parent
562205cc14
commit
01303fab0d
59 changed files with 3178 additions and 3178 deletions
|
|
@ -14,52 +14,52 @@
|
|||
#include "libnfc/chips/pn53x.h"
|
||||
|
||||
int
|
||||
main (int argc, const char *argv[])
|
||||
main(int argc, const char *argv[])
|
||||
{
|
||||
nfc_device *pnd;
|
||||
nfc_target nt;
|
||||
|
||||
nfc_init (NULL);
|
||||
nfc_init(NULL);
|
||||
|
||||
// Display libnfc version
|
||||
const char *acLibnfcVersion = nfc_version ();
|
||||
printf ("%s uses libnfc %s\n", argv[0], acLibnfcVersion);
|
||||
const char *acLibnfcVersion = nfc_version();
|
||||
printf("%s uses libnfc %s\n", argv[0], acLibnfcVersion);
|
||||
|
||||
// Open, using the first available NFC device
|
||||
pnd = nfc_open (NULL, NULL);
|
||||
pnd = nfc_open(NULL, NULL);
|
||||
|
||||
if (pnd == NULL) {
|
||||
ERR ("%s", "Unable to open NFC device.");
|
||||
ERR("%s", "Unable to open NFC device.");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
// Set opened NFC device to initiator mode
|
||||
if (nfc_initiator_init (pnd) < 0) {
|
||||
nfc_perror (pnd, "nfc_initiator_init");
|
||||
exit (EXIT_FAILURE);
|
||||
if (nfc_initiator_init(pnd) < 0) {
|
||||
nfc_perror(pnd, "nfc_initiator_init");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
printf ("NFC reader: %s opened\n", nfc_device_get_name (pnd));
|
||||
printf("NFC reader: %s opened\n", nfc_device_get_name(pnd));
|
||||
|
||||
// Poll for a ISO14443A (MIFARE) tag
|
||||
const nfc_modulation nmMifare = {
|
||||
.nmt = NMT_ISO14443A,
|
||||
.nbr = NBR_106,
|
||||
};
|
||||
if (nfc_initiator_select_passive_target (pnd, nmMifare, NULL, 0, &nt) > 0) {
|
||||
printf ("The following (NFC) ISO14443A tag was found:\n");
|
||||
printf (" ATQA (SENS_RES): ");
|
||||
print_hex (nt.nti.nai.abtAtqa, 2);
|
||||
printf (" UID (NFCID%c): ", (nt.nti.nai.abtUid[0] == 0x08 ? '3' : '1'));
|
||||
print_hex (nt.nti.nai.abtUid, nt.nti.nai.szUidLen);
|
||||
printf (" SAK (SEL_RES): ");
|
||||
print_hex (&nt.nti.nai.btSak, 1);
|
||||
if (nfc_initiator_select_passive_target(pnd, nmMifare, NULL, 0, &nt) > 0) {
|
||||
printf("The following (NFC) ISO14443A tag was found:\n");
|
||||
printf(" ATQA (SENS_RES): ");
|
||||
print_hex(nt.nti.nai.abtAtqa, 2);
|
||||
printf(" UID (NFCID%c): ", (nt.nti.nai.abtUid[0] == 0x08 ? '3' : '1'));
|
||||
print_hex(nt.nti.nai.abtUid, nt.nti.nai.szUidLen);
|
||||
printf(" SAK (SEL_RES): ");
|
||||
print_hex(&nt.nti.nai.btSak, 1);
|
||||
if (nt.nti.nai.szAtsLen) {
|
||||
printf (" ATS (ATR): ");
|
||||
print_hex (nt.nti.nai.abtAts, nt.nti.nai.szAtsLen);
|
||||
printf(" ATS (ATR): ");
|
||||
print_hex(nt.nti.nai.abtAts, nt.nti.nai.szAtsLen);
|
||||
}
|
||||
}
|
||||
// Close NFC device
|
||||
nfc_close (pnd);
|
||||
nfc_exit (NULL);
|
||||
nfc_close(pnd);
|
||||
nfc_exit(NULL);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue