nfc-emulate-tag: add DESELECT command, enhance debug
This commit is contained in:
parent
e800765ffc
commit
98d0f2522f
1 changed files with 13 additions and 4 deletions
|
@ -65,6 +65,12 @@ target_io( const nfc_target_t nt, const byte_t * pbtInput, const size_t szInput,
|
||||||
memcpy(pbtOutput+1, nt.nti.nai.abtAts, nt.nti.nai.szAtsLen);
|
memcpy(pbtOutput+1, nt.nti.nai.abtAts, nt.nti.nai.szAtsLen);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case 0xc2: // S-block DESELECT
|
||||||
|
if (!quiet_output) {
|
||||||
|
printf("Target released me. Bye!\n");
|
||||||
|
}
|
||||||
|
loop = false;
|
||||||
|
break;
|
||||||
default: // Unknown
|
default: // Unknown
|
||||||
if (!quiet_output) {
|
if (!quiet_output) {
|
||||||
printf("Unknown frame, emulated target abort.\n");
|
printf("Unknown frame, emulated target abort.\n");
|
||||||
|
@ -73,7 +79,7 @@ target_io( const nfc_target_t nt, const byte_t * pbtInput, const size_t szInput,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Show transmitted command
|
// Show transmitted command
|
||||||
if (!quiet_output) {
|
if ((!quiet_output) && *pszOutput) {
|
||||||
printf (" Out: ");
|
printf (" Out: ");
|
||||||
print_hex (pbtOutput, *pszOutput);
|
print_hex (pbtOutput, *pszOutput);
|
||||||
}
|
}
|
||||||
|
@ -88,6 +94,7 @@ nfc_target_emulate_tag(nfc_device_t* pnd, const nfc_target_t nt)
|
||||||
bool loop = true;
|
bool loop = true;
|
||||||
|
|
||||||
if (!nfc_target_init (pnd, NTM_PASSIVE, nt, abtRx, &szRxLen)) {
|
if (!nfc_target_init (pnd, NTM_PASSIVE, nt, abtRx, &szRxLen)) {
|
||||||
|
nfc_perror (pnd, "nfc_target_init");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,11 +102,13 @@ nfc_target_emulate_tag(nfc_device_t* pnd, const nfc_target_t nt)
|
||||||
loop = target_io( nt, abtRx, szRxLen, abtTx, &szTx );
|
loop = target_io( nt, abtRx, szRxLen, abtTx, &szTx );
|
||||||
if (szTx) {
|
if (szTx) {
|
||||||
if (!nfc_target_send_bytes(pnd, abtTx, szTx)) {
|
if (!nfc_target_send_bytes(pnd, abtTx, szTx)) {
|
||||||
|
nfc_perror (pnd, "nfc_target_send_bytes");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( loop ) {
|
if ( loop ) {
|
||||||
if (!nfc_target_receive_bytes(pnd, abtRx, &szRxLen)) {
|
if (!nfc_target_receive_bytes(pnd, abtRx, &szRxLen)) {
|
||||||
|
nfc_perror (pnd, "nfc_target_receive_bytes");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue