From 7f698431b7e9b43f1787206a6a298d299cf4dc4b Mon Sep 17 00:00:00 2001 From: Romain Tartiere Date: Tue, 24 Aug 2010 10:13:09 +0000 Subject: [PATCH] New internal API function: pn53x_target_send_dep_bytes(). --- libnfc/chips/pn53x.c | 21 +++++++++++++++++++++ libnfc/chips/pn53x.h | 1 + libnfc/nfc.c | 20 ++------------------ 3 files changed, 24 insertions(+), 18 deletions(-) diff --git a/libnfc/chips/pn53x.c b/libnfc/chips/pn53x.c index a303860..6fb9f8b 100644 --- a/libnfc/chips/pn53x.c +++ b/libnfc/chips/pn53x.c @@ -891,3 +891,24 @@ bool pn53x_target_receive_dep_bytes(nfc_device_t* pnd, byte_t* pbtRx, size_t* ps // Everyting seems ok, return true return true; } + +bool pn53x_target_send_dep_bytes(nfc_device_t* pnd, const byte_t* pbtTx, const size_t szTxLen) +{ + byte_t abtCmd[sizeof(pncmd_target_set_data)]; + + pnd->iLastError = 0; + + memcpy(abtCmd,pncmd_target_set_data,sizeof(pncmd_target_set_data)); + + // We can not just send bytes without parity if while the PN53X expects we handled them + if (!pnd->bPar) return false; + + // Copy the data into the command frame + memcpy(abtCmd+2,pbtTx,szTxLen); + + // Try to send the bits to the reader + if (!pn53x_transceive(pnd,abtCmd,szTxLen+2,NULL,NULL)) return false; + + // Everyting seems ok, return true + return true; +} diff --git a/libnfc/chips/pn53x.h b/libnfc/chips/pn53x.h index 22beeac..7382aea 100644 --- a/libnfc/chips/pn53x.h +++ b/libnfc/chips/pn53x.h @@ -102,6 +102,7 @@ bool pn53x_transceive_bits(nfc_device_t* pnd, const byte_t* pbtTx, const size_t bool pn53x_transceive_bytes(nfc_device_t* pnd, const byte_t* pbtTx, const size_t szTxLen, byte_t* pbtRx, size_t* pszRxLen); bool pn53x_target_receive_dep_bytes(nfc_device_t* pnd, byte_t* pbtRx, size_t* pszRxLen); +bool pn53x_target_send_dep_bytes(nfc_device_t* pnd, const byte_t* pbtTx, const size_t szTxLen); const char *pn53x_strerror (const nfc_device_t *pnd); diff --git a/libnfc/nfc.c b/libnfc/nfc.c index 8d6a1af..90ccc32 100644 --- a/libnfc/nfc.c +++ b/libnfc/nfc.c @@ -69,7 +69,7 @@ nfc_device_desc_t * nfc_pick_device (void); // // // Target // extern const byte_t pncmd_target_get_data [ 2]; -extern const byte_t pncmd_target_set_data [264]; +// extern const byte_t pncmd_target_set_data [264]; extern const byte_t pncmd_target_init [ 39]; // extern const byte_t pncmd_target_virtual_card [ 4]; extern const byte_t pncmd_target_receive [ 2]; @@ -740,23 +740,7 @@ bool nfc_target_send_bytes(nfc_device_t* pnd, const byte_t* pbtTx, const size_t */ bool nfc_target_send_dep_bytes(nfc_device_t* pnd, const byte_t* pbtTx, const size_t szTxLen) { - byte_t abtCmd[sizeof(pncmd_target_set_data)]; - - pnd->iLastError = 0; - - memcpy(abtCmd,pncmd_target_set_data,sizeof(pncmd_target_set_data)); - - // We can not just send bytes without parity if while the PN53X expects we handled them - if (!pnd->bPar) return false; - - // Copy the data into the command frame - memcpy(abtCmd+2,pbtTx,szTxLen); - - // Try to send the bits to the reader - if (!pn53x_transceive(pnd,abtCmd,szTxLen+2,NULL,NULL)) return false; - - // Everyting seems ok, return true - return true; + return pn53x_target_send_dep_bytes(pnd, pbtTx, szTxLen); } /**