From ff066e394ddcaca6766a6e9d0fbfa23fe95ee5dc Mon Sep 17 00:00:00 2001 From: Audrey Diacre Date: Wed, 21 Dec 2011 09:53:16 +0000 Subject: [PATCH] nfc_initiator_deselect__target() function returns now libnf error code. --- include/nfc/nfc.h | 2 +- libnfc/chips/pn53x.c | 4 ++-- libnfc/chips/pn53x.h | 2 +- libnfc/nfc-internal.h | 2 +- libnfc/nfc.c | 4 ++-- test/test_dep_active.c | 6 +++--- test/test_dep_passive.c | 24 ++++++++++++------------ 7 files changed, 22 insertions(+), 22 deletions(-) diff --git a/include/nfc/nfc.h b/include/nfc/nfc.h index a0d75db..579a98f 100644 --- a/include/nfc/nfc.h +++ b/include/nfc/nfc.h @@ -76,7 +76,7 @@ extern "C" { NFC_EXPORT int nfc_initiator_list_passive_targets (nfc_device *pnd, const nfc_modulation nm, nfc_target ant[], const size_t szTargets); NFC_EXPORT int nfc_initiator_poll_target (nfc_device *pnd, const nfc_modulation *pnmTargetTypes, const size_t szTargetTypes, const uint8_t uiPollNr, const uint8_t uiPeriod, nfc_target *pnt); NFC_EXPORT int nfc_initiator_select_dep_target (nfc_device *pnd, const nfc_dep_mode ndm, const nfc_baud_rate nbr, const nfc_dep_info *pndiInitiator, nfc_target *pnt, const int timeout); - NFC_EXPORT bool nfc_initiator_deselect_target (nfc_device *pnd); + NFC_EXPORT int nfc_initiator_deselect_target (nfc_device *pnd); NFC_EXPORT int nfc_initiator_transceive_bytes (nfc_device *pnd, const uint8_t *pbtTx, const size_t szTx, uint8_t *pbtRx, size_t *pszRx, int timeout); NFC_EXPORT bool nfc_initiator_transceive_bits (nfc_device *pnd, const uint8_t *pbtTx, const size_t szTxBits, const uint8_t *pbtTxPar, uint8_t *pbtRx, size_t *pszRxBits, uint8_t *pbtRxPar); NFC_EXPORT bool nfc_initiator_transceive_bytes_timed (nfc_device *pnd, const uint8_t *pbtTx, const size_t szTx, uint8_t *pbtRx, size_t *pszRx, uint32_t *cycles); diff --git a/libnfc/chips/pn53x.c b/libnfc/chips/pn53x.c index e623b09..694b798 100644 --- a/libnfc/chips/pn53x.c +++ b/libnfc/chips/pn53x.c @@ -1518,10 +1518,10 @@ pn53x_initiator_transceive_bytes_timed (struct nfc_device *pnd, const uint8_t *p return true; } -bool +int pn53x_initiator_deselect_target (struct nfc_device *pnd) { - return ((pn53x_InDeselect (pnd, 0) < 0 ) ? 0 : 1 ); // 0 mean deselect all selected targets + return pn53x_InDeselect (pnd, 0); // 0 mean deselect all selected targets } #define SAK_ISO14443_4_COMPLIANT 0x20 diff --git a/libnfc/chips/pn53x.h b/libnfc/chips/pn53x.h index 33ee19b..f18192a 100644 --- a/libnfc/chips/pn53x.h +++ b/libnfc/chips/pn53x.h @@ -309,7 +309,7 @@ bool pn53x_initiator_transceive_bits_timed (struct nfc_device *pnd, const uin uint8_t *pbtRxPar, uint32_t *cycles); bool pn53x_initiator_transceive_bytes_timed (struct nfc_device *pnd, const uint8_t *pbtTx, const size_t szTx, uint8_t *pbtRx, size_t *pszRx, uint32_t *cycles); -bool pn53x_initiator_deselect_target (struct nfc_device *pnd); +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); diff --git a/libnfc/nfc-internal.h b/libnfc/nfc-internal.h index 6ebe21c..808d861 100644 --- a/libnfc/nfc-internal.h +++ b/libnfc/nfc-internal.h @@ -136,7 +136,7 @@ struct nfc_driver_t { int (*initiator_select_passive_target) (struct nfc_device *pnd, const nfc_modulation nm, const uint8_t * pbtInitData, const size_t szInitData, nfc_target * pnt); int (*initiator_poll_target) (struct nfc_device *pnd, const nfc_modulation * pnmModulations, const size_t szModulations, const uint8_t uiPollNr, const uint8_t btPeriod, nfc_target * pnt); int (*initiator_select_dep_target) (struct nfc_device *pnd, const nfc_dep_mode ndm, const nfc_baud_rate nbr, const nfc_dep_info * pndiInitiator, nfc_target * pnt, const int timeout); - bool (*initiator_deselect_target) (struct nfc_device *pnd); + int (*initiator_deselect_target) (struct nfc_device *pnd); int (*initiator_transceive_bytes) (struct nfc_device *pnd, const uint8_t * pbtTx, const size_t szTx, uint8_t * pbtRx, size_t * pszRx, int timeout); bool (*initiator_transceive_bits) (struct nfc_device *pnd, const uint8_t * pbtTx, const size_t szTxBits, const uint8_t * pbtTxPar, uint8_t * pbtRx, size_t * pszRxBits, uint8_t * pbtRxPar); bool (*initiator_transceive_bytes_timed) (struct nfc_device *pnd, const uint8_t * pbtTx, const size_t szTx, uint8_t * pbtRx, size_t * pszRx, uint32_t * cycles); diff --git a/libnfc/nfc.c b/libnfc/nfc.c index 46ad4ed..74e8a92 100644 --- a/libnfc/nfc.c +++ b/libnfc/nfc.c @@ -456,7 +456,7 @@ nfc_initiator_select_dep_target (nfc_device *pnd, /** * @brief Deselect a selected passive or emulated tag - * @return Returns \c true if action was successfully performed; otherwise returns \c false. + * @return Returns 0 on success, otherwise returns libnfc's error code (negative value). * @param pnd \a nfc_device struct pointer that represents currently used device * * After selecting and communicating with a passive tag, this function could be @@ -466,7 +466,7 @@ nfc_initiator_select_dep_target (nfc_device *pnd, * tag, test it for the available features and support, deselect it and skip to * the next tag until the correct tag is found. */ -bool +int nfc_initiator_deselect_target (nfc_device *pnd) { HAL (initiator_deselect_target, pnd); diff --git a/test/test_dep_active.c b/test/test_dep_active.c index 852939e..146efe6 100644 --- a/test/test_dep_active.c +++ b/test/test_dep_active.c @@ -142,9 +142,9 @@ initiator_thread (void *arg) const uint8_t abtAttRx[] = "Hello DEP initiator!"; cut_assert_equal_memory (abtAttRx, sizeof (abtAttRx), abtRx, szRx, cut_message ("Invalid received data")); if (res < 0) { thread_res = -1; return (void*) thread_res; } - bool bres = nfc_initiator_deselect_target (device); - cut_assert_true (bres, cut_message ("Can't deselect target: %s", nfc_strerror (device))); - if (!bres) { thread_res = -1; return (void*) thread_res; } + res = nfc_initiator_deselect_target (device); + cut_assert_equal_int (0, res, cut_message ("Can't deselect target: %s", nfc_strerror (device))); + if (res < 0) { thread_res = -1; return (void*) thread_res; } return (void *) thread_res; } diff --git a/test/test_dep_passive.c b/test/test_dep_passive.c index 3bf13e5..ce755c7 100644 --- a/test/test_dep_passive.c +++ b/test/test_dep_passive.c @@ -176,9 +176,9 @@ initiator_thread (void *arg) cut_assert_equal_memory (abtAttRx, sizeof (abtAttRx), abtRx, szRx, cut_message ("Invalid received data")); if (res < 0) { thread_res = -1; return (void*) thread_res; } - bool bres = nfc_initiator_deselect_target (device); - cut_assert_true (bres, cut_message ("Can't deselect target: %s", nfc_strerror (device))); - if (!bres) { thread_res = -1; return (void*) thread_res; } + res = nfc_initiator_deselect_target (device); + cut_assert_equal_int (0, res, cut_message ("Can't deselect target: %s", nfc_strerror (device))); + if (res < 0) { thread_res = -1; return (void*) thread_res; } // Passive mode / 212Kbps (second pass) printf ("=========== INITIATOR %s (Passive mode / 212Kbps) =========\n", nfc_device_get_name (device)); @@ -198,9 +198,9 @@ initiator_thread (void *arg) cut_assert_equal_memory (abtAttRx, sizeof (abtAttRx), abtRx, szRx, cut_message ("Invalid received data")); if (res < 0) { thread_res = -1; return (void*) thread_res; } - bres = nfc_initiator_deselect_target (device); - cut_assert_true (bres, cut_message ("Can't deselect target: %s", nfc_strerror (device))); - if (!bres) { thread_res = -1; return (void*) thread_res; } + res = nfc_initiator_deselect_target (device); + cut_assert_equal_int (0, res, cut_message ("Can't deselect target: %s", nfc_strerror (device))); + if (res < 0) { thread_res = -1; return (void*) thread_res; } // Passive mode / 212Kbps printf ("=========== INITIATOR %s (Passive mode / 212Kbps, second pass) =========\n", nfc_device_get_name (device)); @@ -220,9 +220,9 @@ initiator_thread (void *arg) cut_assert_equal_memory (abtAttRx, sizeof (abtAttRx), abtRx, szRx, cut_message ("Invalid received data")); if (res < 0) { thread_res = -1; return (void*) thread_res; } - bres = nfc_initiator_deselect_target (device); - cut_assert_true (bres, cut_message ("Can't deselect target: %s", nfc_strerror (device))); - if (!bres) { thread_res = -1; return (void*) thread_res; } + res = nfc_initiator_deselect_target (device); + cut_assert_equal_int (0, res, cut_message ("Can't deselect target: %s", nfc_strerror (device))); + if (res < 0) { thread_res = -1; return (void*) thread_res; } // Passive mode / 424Kbps printf ("=========== INITIATOR %s (Passive mode / 424Kbps) =========\n", nfc_device_get_name (device)); @@ -242,9 +242,9 @@ initiator_thread (void *arg) cut_assert_equal_memory (abtAttRx, sizeof (abtAttRx), abtRx, szRx, cut_message ("Invalid received data")); if (res < 0) { thread_res = -1; return (void*) thread_res; } - bres = nfc_initiator_deselect_target (device); - cut_assert_true (bres, cut_message ("Can't deselect target: %s", nfc_strerror (device))); - if (!bres) { thread_res = -1; return (void*) thread_res; } + res = nfc_initiator_deselect_target (device); + cut_assert_equal_int (0, res, cut_message ("Can't deselect target: %s", nfc_strerror (device))); + if (res < 0) { thread_res = -1; return (void*) thread_res; } return (void *) thread_res; }