- Add timeout capablities to nfc_initiator_transceive_bytes(), nfc_target_send_bytes() and nfc_target_receive_bytes();
- Bump version to 1.5.1.
This commit is contained in:
parent
e94513fdb7
commit
481fb4943f
32 changed files with 210 additions and 162 deletions
|
|
@ -100,7 +100,7 @@ nfc_initiator_mifare_cmd (nfc_device_t * pnd, const mifare_cmd mc, const uint8_t
|
|||
return false;
|
||||
}
|
||||
// Fire the mifare command
|
||||
if (!nfc_initiator_transceive_bytes (pnd, abtCmd, 2 + szParamLen, abtRx, &szRx)) {
|
||||
if (!nfc_initiator_transceive_bytes (pnd, abtCmd, 2 + szParamLen, abtRx, &szRx, NULL)) {
|
||||
if (pnd->iLastError == EINVRXFRAM) {
|
||||
// "Invalid received frame" AKA EINVRXFRAM, usual means we are
|
||||
// authenticated on a sector but the requested MIFARE cmd (read, write)
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ transmit_bytes (const byte_t * pbtTx, const size_t szTx)
|
|||
print_hex (pbtTx, szTx);
|
||||
}
|
||||
// Transmit the command bytes
|
||||
if (!nfc_initiator_transceive_bytes (pnd, pbtTx, szTx, abtRx, &szRx))
|
||||
if (!nfc_initiator_transceive_bytes (pnd, pbtTx, szTx, abtRx, &szRx, NULL))
|
||||
return false;
|
||||
|
||||
// Show received answer
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ main (int argc, const char *argv[])
|
|||
print_nfc_target (nt, false);
|
||||
|
||||
printf ("Sending: %s\n", abtTx);
|
||||
if (!nfc_initiator_transceive_bytes (pnd, abtTx, sizeof(abtTx), abtRx, &szRx)) {
|
||||
if (!nfc_initiator_transceive_bytes (pnd, abtTx, sizeof(abtTx), abtRx, &szRx, NULL)) {
|
||||
nfc_perror(pnd, "nfc_initiator_transceive_bytes");
|
||||
goto error;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ main (int argc, const char *argv[])
|
|||
}
|
||||
|
||||
printf("Initiator request received. Waiting for data...\n");
|
||||
if (!nfc_target_receive_bytes (pnd, abtRx, &szRx)) {
|
||||
if (!nfc_target_receive_bytes (pnd, abtRx, &szRx, NULL)) {
|
||||
nfc_perror(pnd, "nfc_target_receive_bytes");
|
||||
goto error;
|
||||
}
|
||||
|
|
@ -133,7 +133,7 @@ main (int argc, const char *argv[])
|
|||
printf ("Received: %s\n", abtRx);
|
||||
|
||||
printf ("Sending: %s\n", abtTx);
|
||||
if (!nfc_target_send_bytes (pnd, abtTx, sizeof(abtTx))) {
|
||||
if (!nfc_target_send_bytes (pnd, abtTx, sizeof(abtTx), NULL)) {
|
||||
nfc_perror(pnd, "nfc_target_send_bytes");
|
||||
goto error;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -148,7 +148,7 @@ nfc_target_emulate_tag(nfc_device_t* pnd, nfc_target_t * pnt)
|
|||
while ( loop ) {
|
||||
loop = target_io( pnt, abtRx, szRx, abtTx, &szTx );
|
||||
if (szTx) {
|
||||
if (!nfc_target_send_bytes(pnd, abtTx, szTx)) {
|
||||
if (!nfc_target_send_bytes(pnd, abtTx, szTx, NULL)) {
|
||||
nfc_perror (pnd, "nfc_target_send_bytes");
|
||||
return false;
|
||||
}
|
||||
|
|
@ -158,7 +158,7 @@ nfc_target_emulate_tag(nfc_device_t* pnd, nfc_target_t * pnt)
|
|||
nfc_configure (pnd, NDO_HANDLE_CRC, false);
|
||||
init_mfc_auth = false;
|
||||
}
|
||||
if (!nfc_target_receive_bytes(pnd, abtRx, &szRx)) {
|
||||
if (!nfc_target_receive_bytes(pnd, abtRx, &szRx, NULL)) {
|
||||
nfc_perror (pnd, "nfc_target_receive_bytes");
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ transmit_bytes (const byte_t * pbtTx, const size_t szTx)
|
|||
printf ("Sent bits: ");
|
||||
print_hex (pbtTx, szTx);
|
||||
// Transmit the command bytes
|
||||
if (!nfc_initiator_transceive_bytes (pnd, pbtTx, szTx, abtRx, &szRx))
|
||||
if (!nfc_initiator_transceive_bytes (pnd, pbtTx, szTx, abtRx, &szRx, NULL))
|
||||
return false;
|
||||
|
||||
// Show received answer
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ transmit_bytes (const byte_t * pbtTx, const size_t szTx)
|
|||
print_hex (pbtTx, szTx);
|
||||
}
|
||||
// Transmit the command bytes
|
||||
if (!nfc_initiator_transceive_bytes (pnd, pbtTx, szTx, abtRx, &szRx))
|
||||
if (!nfc_initiator_transceive_bytes (pnd, pbtTx, szTx, abtRx, &szRx, NULL))
|
||||
return false;
|
||||
|
||||
// Show received answer
|
||||
|
|
|
|||
|
|
@ -375,7 +375,7 @@ main (int argc, char *argv[])
|
|||
bool ret;
|
||||
if (!initiator_only_mode) {
|
||||
// Receive external reader command through target
|
||||
if (!nfc_target_receive_bytes(pndTarget,abtCapdu,&szCapduLen)) {
|
||||
if (!nfc_target_receive_bytes(pndTarget,abtCapdu,&szCapduLen, NULL)) {
|
||||
nfc_perror (pndTarget, "nfc_target_receive_bytes");
|
||||
if (!target_only_mode) {
|
||||
nfc_disconnect (pndInitiator);
|
||||
|
|
@ -406,7 +406,7 @@ main (int argc, char *argv[])
|
|||
if (!target_only_mode) {
|
||||
// Forward the frame to the original tag
|
||||
ret = nfc_initiator_transceive_bytes
|
||||
(pndInitiator, abtCapdu, szCapduLen, abtRapdu, &szRapduLen);
|
||||
(pndInitiator, abtCapdu, szCapduLen, abtRapdu, &szRapduLen, NULL);
|
||||
} else {
|
||||
if (scan_hex_fd3(abtRapdu, &szRapduLen, "R-APDU") != EXIT_SUCCESS) {
|
||||
fprintf (stderr, "Error while scanning R-APDU from FD3\n");
|
||||
|
|
@ -430,7 +430,7 @@ main (int argc, char *argv[])
|
|||
}
|
||||
if (!initiator_only_mode) {
|
||||
// Transmit the response bytes
|
||||
if (!nfc_target_send_bytes(pndTarget, abtRapdu, szRapduLen)) {
|
||||
if (!nfc_target_send_bytes(pndTarget, abtRapdu, szRapduLen, NULL)) {
|
||||
nfc_perror (pndTarget, "nfc_target_send_bytes");
|
||||
if (!target_only_mode) {
|
||||
nfc_disconnect (pndInitiator);
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ main (int argc, const char *argv[])
|
|||
|
||||
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, NULL);
|
||||
if (result) {
|
||||
// Result of Diagnose ping for RC-S360 doesn't contain status byte so we've to handle both cases
|
||||
result = (memcmp (pncmd_diagnose_communication_line_test + 1, abtRx, sizeof (pncmd_diagnose_communication_line_test) - 1) == 0) ||
|
||||
|
|
@ -103,7 +103,7 @@ main (int argc, const char *argv[])
|
|||
}
|
||||
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, NULL);
|
||||
if (result) {
|
||||
result = ((szRx == 1) && (abtRx[0] == 0x00));
|
||||
} else {
|
||||
|
|
@ -111,7 +111,7 @@ main (int argc, const char *argv[])
|
|||
}
|
||||
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, NULL);
|
||||
if (result) {
|
||||
result = ((szRx == 1) && (abtRx[0] == 0x00));
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -179,7 +179,7 @@ int main(int argc, const char* argv[])
|
|||
print_hex((byte_t*)abtTx,szTx);
|
||||
|
||||
szRx = sizeof(abtRx);
|
||||
if (!pn53x_transceive (pnd, abtTx, szTx, abtRx, &szRx)) {
|
||||
if (!pn53x_transceive (pnd, abtTx, szTx, abtRx, &szRx, NULL)) {
|
||||
free(cmd);
|
||||
nfc_perror (pnd, "Rx");
|
||||
continue;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue