diff --git a/examples/nfc-emulate-uid.c b/examples/nfc-emulate-uid.c index ffd7bc2..b8f0a39 100644 --- a/examples/nfc-emulate-uid.c +++ b/examples/nfc-emulate-uid.c @@ -172,7 +172,7 @@ main (int argc, char *argv[]) while (true) { // Test if we received a frame - if (nfc_target_receive_bits (pnd, abtRecv, &szRecvBits, NULL) > 0) { + if ((szRecvBits = nfc_target_receive_bits (pnd, abtRecv, NULL)) > 0) { // Prepare the command to send back for the anti-collision request switch (szRecvBits) { case 7: // Request or Wakeup diff --git a/examples/nfc-relay.c b/examples/nfc-relay.c index 992f698..c984765 100644 --- a/examples/nfc-relay.c +++ b/examples/nfc-relay.c @@ -179,7 +179,7 @@ main (int argc, char *argv[]) while (!quitting) { // Test if we received a frame from the reader - if (nfc_target_receive_bits (pndTag, abtReaderRx, &szReaderRxBits, abtReaderRxPar) > 0) { + if ((szReaderRxBits = nfc_target_receive_bits (pndTag, abtReaderRx, abtReaderRxPar)) > 0) { // Drop down the field before sending a REQA command and start a new session if (szReaderRxBits == 7 && abtReaderRx[0] == 0x26) { // Drop down field for a very short time (original tag will reboot) diff --git a/include/nfc/nfc.h b/include/nfc/nfc.h index 9bcff7d..51d2b7b 100644 --- a/include/nfc/nfc.h +++ b/include/nfc/nfc.h @@ -87,7 +87,7 @@ extern "C" { NFC_EXPORT int nfc_target_send_bytes (nfc_device *pnd, const uint8_t *pbtTx, const size_t szTx, int timeout); NFC_EXPORT int nfc_target_receive_bytes (nfc_device *pnd, uint8_t *pbtRx, size_t *pszRx, int timeout); NFC_EXPORT int nfc_target_send_bits (nfc_device *pnd, const uint8_t *pbtTx, const size_t szTxBits, const uint8_t *pbtTxPar); - NFC_EXPORT int nfc_target_receive_bits (nfc_device *pnd, uint8_t *pbtRx, size_t *pszRxBits, uint8_t *pbtRxPar); + NFC_EXPORT int nfc_target_receive_bits (nfc_device *pnd, uint8_t *pbtRx, uint8_t *pbtRxPar); /* Error reporting */ NFC_EXPORT const char *nfc_strerror (const nfc_device *pnd); diff --git a/libnfc/chips/pn53x.c b/libnfc/chips/pn53x.c index 8d02d33..dfbc6be 100644 --- a/libnfc/chips/pn53x.c +++ b/libnfc/chips/pn53x.c @@ -1811,8 +1811,9 @@ pn53x_target_init (struct nfc_device *pnd, nfc_target *pnt, uint8_t *pbtRx, size } int -pn53x_target_receive_bits (struct nfc_device *pnd, uint8_t *pbtRx, size_t *pszRxBits, uint8_t *pbtRxPar) +pn53x_target_receive_bits (struct nfc_device *pnd, uint8_t *pbtRx, uint8_t *pbtRxPar) { + size_t szRxBits = 0; uint8_t abtCmd[] = { TgGetInitiatorCommand }; uint8_t abtRx[PN53x_EXTENDED_FRAME__DATA_MAX_LEN]; @@ -1838,15 +1839,15 @@ pn53x_target_receive_bits (struct nfc_device *pnd, uint8_t *pbtRx, size_t *pszRx // Unwrap the response frame if ((res = pn53x_unwrap_frame (abtRx + 1, szFrameBits, pbtRx, pbtRxPar)) < 0) return res; - *pszRxBits = res; + szRxBits = res; } else { // Save the received bits - *pszRxBits = szFrameBits; + szRxBits = szFrameBits; // Copy the received bytes memcpy (pbtRx, abtRx + 1, szRx - 1); } // Everyting seems ok, return received bits count - return *pszRxBits; + return szRxBits; } int diff --git a/libnfc/chips/pn53x.h b/libnfc/chips/pn53x.h index 0e6af42..7ea7731 100644 --- a/libnfc/chips/pn53x.h +++ b/libnfc/chips/pn53x.h @@ -309,7 +309,7 @@ int pn53x_initiator_deselect_target (struct nfc_device *pnd); // NFC device as Target functions int pn53x_target_init (struct nfc_device *pnd, nfc_target *pnt, uint8_t *pbtRx, size_t *pszRx, int timeout); -int pn53x_target_receive_bits (struct nfc_device *pnd, uint8_t *pbtRx, size_t *pszRxBits, uint8_t *pbtRxPar); +int pn53x_target_receive_bits (struct nfc_device *pnd, uint8_t *pbtRx, uint8_t *pbtRxPar); int pn53x_target_receive_bytes (struct nfc_device *pnd, uint8_t *pbtRx, size_t *pszRx, int timeout); int pn53x_target_send_bits (struct nfc_device *pnd, const uint8_t *pbtTx, const size_t szTxBits, const uint8_t *pbtTxPar); int pn53x_target_send_bytes (struct nfc_device *pnd, const uint8_t *pbtTx, const size_t szTx, int timeout); diff --git a/libnfc/nfc-internal.h b/libnfc/nfc-internal.h index cab8581..91646ce 100644 --- a/libnfc/nfc-internal.h +++ b/libnfc/nfc-internal.h @@ -146,7 +146,7 @@ struct nfc_driver_t { int (*target_send_bytes) (struct nfc_device *pnd, const uint8_t * pbtTx, const size_t szTx, int timeout); int (*target_receive_bytes) (struct nfc_device *pnd, uint8_t * pbtRx, size_t * pszRx, int timeout); int (*target_send_bits) (struct nfc_device *pnd, const uint8_t * pbtTx, const size_t szTxBits, const uint8_t * pbtTxPar); - int (*target_receive_bits) (struct nfc_device *pnd, uint8_t * pbtRx, size_t * pszRxBits, uint8_t * pbtRxPar); + int (*target_receive_bits) (struct nfc_device *pnd, uint8_t * pbtRx, uint8_t * pbtRxPar); int (*device_set_property_bool) (struct nfc_device *pnd, const nfc_property property, const bool bEnable); int (*device_set_property_int) (struct nfc_device *pnd, const nfc_property property, const int value); diff --git a/libnfc/nfc.c b/libnfc/nfc.c index da683c5..d482715 100644 --- a/libnfc/nfc.c +++ b/libnfc/nfc.c @@ -758,9 +758,9 @@ nfc_target_send_bits (nfc_device *pnd, const uint8_t *pbtTx, const size_t szTxBi * frames. */ int -nfc_target_receive_bits (nfc_device *pnd, uint8_t *pbtRx, size_t *pszRxBits, uint8_t *pbtRxPar) +nfc_target_receive_bits (nfc_device *pnd, uint8_t *pbtRx, uint8_t *pbtRxPar) { - HAL (target_receive_bits, pnd, pbtRx, pszRxBits, pbtRxPar); + HAL (target_receive_bits, pnd, pbtRx, pbtRxPar); } /**