nfc_initiator_transceive_bytes() now take a constant size for Rx buffer to have a cleaner API: no more in/out parameters
This commit is contained in:
parent
f0e85c027a
commit
2c9275adde
13 changed files with 67 additions and 68 deletions
|
|
@ -104,14 +104,15 @@ transmit_bytes (const uint8_t *pbtTx, const size_t szTx)
|
|||
printf ("Sent bits: ");
|
||||
print_hex (pbtTx, szTx);
|
||||
}
|
||||
int res;
|
||||
// Transmit the command bytes
|
||||
if (nfc_initiator_transceive_bytes (pnd, pbtTx, szTx, abtRx, &szRx, 0) < 0)
|
||||
if ((res = nfc_initiator_transceive_bytes (pnd, pbtTx, szTx, abtRx, sizeof(abtRx), 0)) < 0)
|
||||
return false;
|
||||
|
||||
// Show received answer
|
||||
if (!quiet_output) {
|
||||
printf ("Received bits: ");
|
||||
print_hex (abtRx, szRx);
|
||||
print_hex (abtRx, res);
|
||||
}
|
||||
// Succesful transfer
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -64,7 +64,6 @@ main (int argc, const char *argv[])
|
|||
{
|
||||
nfc_target nt;
|
||||
uint8_t abtRx[MAX_FRAME_LEN];
|
||||
size_t szRx = sizeof(abtRx);
|
||||
uint8_t abtTx[] = "Hello World!";
|
||||
|
||||
if (argc > 1) {
|
||||
|
|
@ -95,12 +94,13 @@ 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, 0) < 0) {
|
||||
int res;
|
||||
if ((res = nfc_initiator_transceive_bytes (pnd, abtTx, sizeof(abtTx), abtRx, sizeof(abtRx), 0)) < 0) {
|
||||
nfc_perror(pnd, "nfc_initiator_transceive_bytes");
|
||||
goto error;
|
||||
}
|
||||
|
||||
abtRx[szRx] = 0;
|
||||
abtRx[res] = 0;
|
||||
printf ("Received: %s\n", abtRx);
|
||||
|
||||
if (nfc_initiator_deselect_target (pnd) < 0) {
|
||||
|
|
|
|||
|
|
@ -58,7 +58,6 @@
|
|||
|
||||
static uint8_t abtRx[MAX_FRAME_LEN];
|
||||
static int szRxBits;
|
||||
static size_t szRx = sizeof(abtRx);
|
||||
static uint8_t abtRawUid[12];
|
||||
static uint8_t abtAtqa[2];
|
||||
static uint8_t abtSak;
|
||||
|
|
@ -117,14 +116,15 @@ transmit_bytes (const uint8_t *pbtTx, const size_t szTx)
|
|||
printf ("Sent bits: ");
|
||||
print_hex (pbtTx, szTx);
|
||||
}
|
||||
int res;
|
||||
// Transmit the command bytes
|
||||
if (nfc_initiator_transceive_bytes (pnd, pbtTx, szTx, abtRx, &szRx, 0) < 0)
|
||||
if ((res = nfc_initiator_transceive_bytes (pnd, pbtTx, szTx, abtRx, sizeof(abtRx), 0)) < 0)
|
||||
return false;
|
||||
|
||||
// Show received answer
|
||||
if (!quiet_output) {
|
||||
printf ("Received bits: ");
|
||||
print_hex (abtRx, szRx);
|
||||
print_hex (abtRx, res);
|
||||
}
|
||||
// Succesful transfer
|
||||
return true;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue