examples: silent some compilation warnings.
This commit is contained in:
parent
dbe59f83d9
commit
4384d27f3e
11 changed files with 98 additions and 56 deletions
|
@ -76,17 +76,23 @@ main (int argc, const char *argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
nfc_target_t nt = {
|
nfc_target_t nt = {
|
||||||
.nm.nmt = NMT_DEP,
|
.nm = {
|
||||||
.nm.nbr = NBR_UNDEFINED, // Will be updated by nfc_target_init
|
.nmt = NMT_DEP,
|
||||||
.nti.ndi.abtNFCID3 = { 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xff, 0x00, 0x00 },
|
.nbr = NBR_UNDEFINED
|
||||||
.nti.ndi.szGB = 4,
|
},
|
||||||
.nti.ndi.abtGB = { 0x12, 0x34, 0x56, 0x78 },
|
.nti = {
|
||||||
/* These bytes are not used by nfc_target_init: the chip will provide them automatically to the initiator */
|
.ndi = {
|
||||||
.nti.ndi.btDID = 0x00,
|
.abtNFCID3 = { 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xff, 0x00, 0x00 },
|
||||||
.nti.ndi.btBS = 0x00,
|
.szGB = 4,
|
||||||
.nti.ndi.btBR = 0x00,
|
.abtGB = { 0x12, 0x34, 0x56, 0x78 },
|
||||||
.nti.ndi.btTO = 0x00,
|
/* These bytes are not used by nfc_target_init: the chip will provide them automatically to the initiator */
|
||||||
.nti.ndi.btPP = 0x01,
|
.btDID = 0x00,
|
||||||
|
.btBS = 0x00,
|
||||||
|
.btBR = 0x00,
|
||||||
|
.btTO = 0x00,
|
||||||
|
.btPP = 0x01,
|
||||||
|
},
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!pnd) {
|
if (!pnd) {
|
||||||
|
|
|
@ -108,7 +108,7 @@ bool receive_bytes (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main (int argc, char *argv[])
|
main (void)
|
||||||
{
|
{
|
||||||
// Try to open the NFC reader
|
// Try to open the NFC reader
|
||||||
pnd = nfc_connect (NULL);
|
pnd = nfc_connect (NULL);
|
||||||
|
@ -122,13 +122,19 @@ main (int argc, char *argv[])
|
||||||
printf ("Emulating NDEF tag now, please touch it with a second NFC device\n");
|
printf ("Emulating NDEF tag now, please touch it with a second NFC device\n");
|
||||||
|
|
||||||
nfc_target_t nt = {
|
nfc_target_t nt = {
|
||||||
.nm.nmt = NMT_ISO14443A,
|
.nm = {
|
||||||
.nm.nbr = NBR_UNDEFINED, // Will be updated by nfc_target_init()
|
.nmt = NMT_ISO14443A,
|
||||||
.nti.nai.abtAtqa = { 0x00, 0x04 },
|
.nbr = NBR_UNDEFINED, // Will be updated by nfc_target_init()
|
||||||
.nti.nai.abtUid = { 0x08, 0x00, 0xb0, 0x0b },
|
},
|
||||||
.nti.nai.btSak = 0x20,
|
.nti = {
|
||||||
.nti.nai.szUidLen = 4,
|
.nai = {
|
||||||
.nti.nai.szAtsLen = 0,
|
.abtAtqa = { 0x00, 0x04 },
|
||||||
|
.abtUid = { 0x08, 0x00, 0xb0, 0x0b },
|
||||||
|
.btSak = 0x20,
|
||||||
|
.szUidLen = 4,
|
||||||
|
.szAtsLen = 0,
|
||||||
|
},
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!nfc_target_init (pnd, &nt, abtRx, &szRx)) {
|
if (!nfc_target_init (pnd, &nt, abtRx, &szRx)) {
|
||||||
|
|
|
@ -171,6 +171,7 @@ nfc_target_emulate_tag(nfc_device_t* pnd, nfc_target_t * pnt)
|
||||||
int
|
int
|
||||||
main (int argc, char *argv[])
|
main (int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
(void) argc;
|
||||||
const char *acLibnfcVersion;
|
const char *acLibnfcVersion;
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
|
@ -204,13 +205,19 @@ main (int argc, char *argv[])
|
||||||
// Example of a Mifare Classic Mini
|
// Example of a Mifare Classic Mini
|
||||||
// Note that crypto1 is not implemented in this example
|
// Note that crypto1 is not implemented in this example
|
||||||
nfc_target_t nt = {
|
nfc_target_t nt = {
|
||||||
.nm.nmt = NMT_ISO14443A,
|
.nm = {
|
||||||
.nm.nbr = NBR_UNDEFINED,
|
.nmt = NMT_ISO14443A,
|
||||||
.nti.nai.abtAtqa = { 0x00, 0x04 },
|
.nbr = NBR_UNDEFINED,
|
||||||
.nti.nai.abtUid = { 0x08, 0xab, 0xcd, 0xef },
|
},
|
||||||
.nti.nai.btSak = 0x09,
|
.nti = {
|
||||||
.nti.nai.szUidLen = 4,
|
.nai = {
|
||||||
.nti.nai.szAtsLen = 0,
|
.abtAtqa = { 0x00, 0x04 },
|
||||||
|
.abtUid = { 0x08, 0xab, 0xcd, 0xef },
|
||||||
|
.btSak = 0x09,
|
||||||
|
.szUidLen = 4,
|
||||||
|
.szAtsLen = 0,
|
||||||
|
},
|
||||||
|
},
|
||||||
};
|
};
|
||||||
/*
|
/*
|
||||||
// Example of a FeliCa
|
// Example of a FeliCa
|
||||||
|
|
|
@ -143,13 +143,19 @@ main (int argc, char *argv[])
|
||||||
|
|
||||||
// Note: We have to build a "fake" nfc_target_t in order to do exactly the same that was done before the new nfc_target_init() was introduced.
|
// Note: We have to build a "fake" nfc_target_t in order to do exactly the same that was done before the new nfc_target_init() was introduced.
|
||||||
nfc_target_t nt = {
|
nfc_target_t nt = {
|
||||||
.nm.nmt = NMT_ISO14443A,
|
.nm = {
|
||||||
.nm.nbr = NBR_UNDEFINED,
|
.nmt = NMT_ISO14443A,
|
||||||
.nti.nai.abtAtqa = { 0x04, 0x00 },
|
.nbr = NBR_UNDEFINED,
|
||||||
.nti.nai.abtUid = { 0x08, 0xad, 0xbe, 0xef },
|
},
|
||||||
.nti.nai.btSak = 0x20,
|
.nti = {
|
||||||
.nti.nai.szUidLen = 4,
|
.nai = {
|
||||||
.nti.nai.szAtsLen = 0,
|
.abtAtqa = { 0x04, 0x00 },
|
||||||
|
.abtUid = { 0x08, 0xad, 0xbe, 0xef },
|
||||||
|
.btSak = 0x20,
|
||||||
|
.szUidLen = 4,
|
||||||
|
.szAtsLen = 0,
|
||||||
|
},
|
||||||
|
},
|
||||||
};
|
};
|
||||||
if (!nfc_target_init (pnd, &nt, abtRecv, &szRecvBits)) {
|
if (!nfc_target_init (pnd, &nt, abtRecv, &szRecvBits)) {
|
||||||
nfc_perror (pnd, "nfc_target_init");
|
nfc_perror (pnd, "nfc_target_init");
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @file nfc-mfultool.c
|
* @file nfc-mfultralight.c
|
||||||
* @brief MIFARE Ultralight dump/restore tool
|
* @brief MIFARE Ultralight dump/restore tool
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
@ -292,8 +292,10 @@ main (int argc, char *argv[])
|
||||||
}
|
}
|
||||||
if (!initiator_only_mode) {
|
if (!initiator_only_mode) {
|
||||||
nfc_target_t ntEmulatedTarget = {
|
nfc_target_t ntEmulatedTarget = {
|
||||||
.nm.nmt = NMT_ISO14443A,
|
.nm = {
|
||||||
.nm.nbr = NBR_106,
|
.nmt = NMT_ISO14443A,
|
||||||
|
.nbr = NBR_106,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
if (target_only_mode) {
|
if (target_only_mode) {
|
||||||
size_t foo;
|
size_t foo;
|
||||||
|
|
|
@ -137,13 +137,19 @@ main (int argc, char *argv[])
|
||||||
printf ("[+] For example, send a RATS command or use the \"nfc-anticol\" tool\n");
|
printf ("[+] For example, send a RATS command or use the \"nfc-anticol\" tool\n");
|
||||||
|
|
||||||
nfc_target_t nt = {
|
nfc_target_t nt = {
|
||||||
.nm.nmt = NMT_ISO14443A,
|
.nm = {
|
||||||
.nm.nbr = NBR_UNDEFINED,
|
.nmt = NMT_ISO14443A,
|
||||||
.nti.nai.abtAtqa = { 0x04, 0x00 },
|
.nbr = NBR_UNDEFINED,
|
||||||
.nti.nai.abtUid = { 0xde, 0xad, 0xbe, 0xef },
|
},
|
||||||
.nti.nai.btSak = 0x20,
|
.nti = {
|
||||||
.nti.nai.szUidLen = 4,
|
.nai = {
|
||||||
.nti.nai.szAtsLen = 0,
|
.abtAtqa = { 0x04, 0x00 },
|
||||||
|
.abtUid = { 0xde, 0xad, 0xbe, 0xef },
|
||||||
|
.btSak = 0x20,
|
||||||
|
.szUidLen = 4,
|
||||||
|
.szAtsLen = 0,
|
||||||
|
},
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!nfc_target_init (pndTag, &nt, abtReaderRx, &szReaderRxBits)) {
|
if (!nfc_target_init (pndTag, &nt, abtReaderRx, &szReaderRxBits)) {
|
||||||
|
|
|
@ -532,6 +532,7 @@ print_nfc_iso14443a_info (const nfc_iso14443a_info_t nai, bool verbose)
|
||||||
void
|
void
|
||||||
print_nfc_felica_info (const nfc_felica_info_t nfi, bool verbose)
|
print_nfc_felica_info (const nfc_felica_info_t nfi, bool verbose)
|
||||||
{
|
{
|
||||||
|
(void) verbose;
|
||||||
printf (" ID (NFCID2): ");
|
printf (" ID (NFCID2): ");
|
||||||
print_hex (nfi.abtId, 8);
|
print_hex (nfi.abtId, 8);
|
||||||
printf (" Parameter (PAD): ");
|
printf (" Parameter (PAD): ");
|
||||||
|
@ -541,6 +542,7 @@ print_nfc_felica_info (const nfc_felica_info_t nfi, bool verbose)
|
||||||
void
|
void
|
||||||
print_nfc_jewel_info (const nfc_jewel_info_t nji, bool verbose)
|
print_nfc_jewel_info (const nfc_jewel_info_t nji, bool verbose)
|
||||||
{
|
{
|
||||||
|
(void) verbose;
|
||||||
printf (" ATQA (SENS_RES): ");
|
printf (" ATQA (SENS_RES): ");
|
||||||
print_hex (nji.btSensRes, 2);
|
print_hex (nji.btSensRes, 2);
|
||||||
printf (" 4-LSB JEWELID: ");
|
printf (" 4-LSB JEWELID: ");
|
||||||
|
@ -608,6 +610,7 @@ print_nfc_iso14443b_info (const nfc_iso14443b_info_t nbi, bool verbose)
|
||||||
void
|
void
|
||||||
print_nfc_dep_info (const nfc_dep_info_t ndi, bool verbose)
|
print_nfc_dep_info (const nfc_dep_info_t ndi, bool verbose)
|
||||||
{
|
{
|
||||||
|
(void) verbose;
|
||||||
printf (" NFCID3: ");
|
printf (" NFCID3: ");
|
||||||
print_hex (ndi.abtNFCID3, 10);
|
print_hex (ndi.abtNFCID3, 10);
|
||||||
printf (" BS: %02x\n", ndi.btBS);
|
printf (" BS: %02x\n", ndi.btBS);
|
||||||
|
|
|
@ -88,19 +88,19 @@ main (int argc, const char *argv[])
|
||||||
|
|
||||||
printf ("NFC device [%s] connected.\n", pnd->acName);
|
printf ("NFC device [%s] connected.\n", pnd->acName);
|
||||||
|
|
||||||
result = pn53x_transceive (pnd, pncmd_diagnose_communication_line_test, sizeof (pncmd_diagnose_communication_line_test), abtRx, &szRx);
|
result = pn53x_transceive (pnd, pncmd_diagnose_communication_line_test, sizeof (pncmd_diagnose_communication_line_test), abtRx, &szRx, false);
|
||||||
if (result) {
|
if (result) {
|
||||||
result = (memcmp (pncmd_diagnose_communication_line_test + 2, abtRx, sizeof (pncmd_diagnose_communication_line_test) - 2) == 0);
|
result = (memcmp (pncmd_diagnose_communication_line_test + 2, abtRx, sizeof (pncmd_diagnose_communication_line_test) - 2) == 0);
|
||||||
}
|
}
|
||||||
printf (" Communication line test: %s\n", result ? "OK" : "Failed");
|
printf (" Communication line test: %s\n", result ? "OK" : "Failed");
|
||||||
|
|
||||||
result = pn53x_transceive (pnd, pncmd_diagnose_rom_test, sizeof (pncmd_diagnose_rom_test), abtRx, &szRx);
|
result = pn53x_transceive (pnd, pncmd_diagnose_rom_test, sizeof (pncmd_diagnose_rom_test), abtRx, &szRx, false);
|
||||||
if (result) {
|
if (result) {
|
||||||
result = ((szRx == 1) && (abtRx[0] == 0x00));
|
result = ((szRx == 1) && (abtRx[0] == 0x00));
|
||||||
}
|
}
|
||||||
printf (" ROM test: %s\n", result ? "OK" : "Failed");
|
printf (" ROM test: %s\n", result ? "OK" : "Failed");
|
||||||
|
|
||||||
result = pn53x_transceive (pnd, pncmd_diagnose_ram_test, sizeof (pncmd_diagnose_ram_test), abtRx, &szRx);
|
result = pn53x_transceive (pnd, pncmd_diagnose_ram_test, sizeof (pncmd_diagnose_ram_test), abtRx, &szRx, false);
|
||||||
if (result) {
|
if (result) {
|
||||||
result = ((szRx == 1) && (abtRx[0] == 0x00));
|
result = ((szRx == 1) && (abtRx[0] == 0x00));
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,7 +93,7 @@ sam_connection (nfc_device_t * pnd, int mode)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!pn53x_transceive (pnd, pncmd_sam_config, szCmd, abtRx, &szRx)) {
|
if (!pn53x_transceive (pnd, pncmd_sam_config, szCmd, abtRx, &szRx, false)) {
|
||||||
nfc_perror(pnd, "pn53x_transceive");
|
nfc_perror(pnd, "pn53x_transceive");
|
||||||
ERR ("%s %d", "Unable to execute SAMConfiguration command with mode byte:", mode);
|
ERR ("%s %d", "Unable to execute SAMConfiguration command with mode byte:", mode);
|
||||||
return false;
|
return false;
|
||||||
|
@ -213,13 +213,19 @@ main (int argc, const char *argv[])
|
||||||
size_t szRx;
|
size_t szRx;
|
||||||
|
|
||||||
nfc_target_t nt = {
|
nfc_target_t nt = {
|
||||||
.nm.nmt = NMT_ISO14443A,
|
.nm = {
|
||||||
.nm.nbr = NBR_UNDEFINED,
|
.nmt = NMT_ISO14443A,
|
||||||
.nti.nai.abtAtqa = { 0x04, 0x00 },
|
.nbr = NBR_UNDEFINED,
|
||||||
.nti.nai.abtUid = { 0x08, 0xad, 0xbe, 0xef },
|
},
|
||||||
.nti.nai.btSak = 0x20,
|
.nti = {
|
||||||
.nti.nai.szUidLen = 4,
|
.nai = {
|
||||||
.nti.nai.szAtsLen = 0,
|
.abtAtqa = { 0x04, 0x00 },
|
||||||
|
.abtUid = { 0x08, 0xad, 0xbe, 0xef },
|
||||||
|
.btSak = 0x20,
|
||||||
|
.szUidLen = 4,
|
||||||
|
.szAtsLen = 0,
|
||||||
|
},
|
||||||
|
},
|
||||||
};
|
};
|
||||||
printf ("Now both, NFC device (configured as target) and SAM are readables from an external NFC initiator.\n");
|
printf ("Now both, NFC device (configured as target) and SAM are readables from an external NFC initiator.\n");
|
||||||
printf ("Please note that NFC device (configured as target) stay in target mode until it receive RATS, ATR_REQ or proprietary command.\n");
|
printf ("Please note that NFC device (configured as target) stay in target mode until it receive RATS, ATR_REQ or proprietary command.\n");
|
||||||
|
|
|
@ -132,7 +132,7 @@ int main(int argc, const char* argv[])
|
||||||
while (isspace(cmd[offset])) {
|
while (isspace(cmd[offset])) {
|
||||||
offset++;
|
offset++;
|
||||||
}
|
}
|
||||||
sscanf(cmd+offset, "%u", &s);
|
sscanf(cmd+offset, "%d", &s);
|
||||||
printf("Pause for %i secs\n", s);
|
printf("Pause for %i secs\n", s);
|
||||||
if (s>0) {
|
if (s>0) {
|
||||||
sleep(s);
|
sleep(s);
|
||||||
|
@ -167,7 +167,7 @@ int main(int argc, const char* argv[])
|
||||||
printf("Tx: ");
|
printf("Tx: ");
|
||||||
print_hex((byte_t*)abtTx+1,szTx-1);
|
print_hex((byte_t*)abtTx+1,szTx-1);
|
||||||
|
|
||||||
if (!pn53x_transceive (pnd, abtTx, szTx, abtRx, &szRx)) {
|
if (!pn53x_transceive (pnd, abtTx, szTx, abtRx, &szRx, false)) {
|
||||||
free(cmd);
|
free(cmd);
|
||||||
nfc_perror (pnd, "Rx");
|
nfc_perror (pnd, "Rx");
|
||||||
continue;
|
continue;
|
||||||
|
|
Loading…
Reference in a new issue