nfc_initiator_deselect__target() function returns now libnf error code.

This commit is contained in:
Audrey Diacre 2011-12-21 09:53:16 +00:00
parent c41d7de8ca
commit ff066e394d
7 changed files with 22 additions and 22 deletions

View file

@ -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_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_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 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 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_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); 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);

View file

@ -1518,10 +1518,10 @@ pn53x_initiator_transceive_bytes_timed (struct nfc_device *pnd, const uint8_t *p
return true; return true;
} }
bool int
pn53x_initiator_deselect_target (struct nfc_device *pnd) 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 #define SAK_ISO14443_4_COMPLIANT 0x20

View file

@ -309,7 +309,7 @@ bool pn53x_initiator_transceive_bits_timed (struct nfc_device *pnd, const uin
uint8_t *pbtRxPar, uint32_t *cycles); uint8_t *pbtRxPar, uint32_t *cycles);
bool pn53x_initiator_transceive_bytes_timed (struct nfc_device *pnd, const uint8_t *pbtTx, const size_t szTx, 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); 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 // NFC device as Target functions
int pn53x_target_init (struct nfc_device *pnd, nfc_target *pnt, uint8_t *pbtRx, size_t *pszRx); int pn53x_target_init (struct nfc_device *pnd, nfc_target *pnt, uint8_t *pbtRx, size_t *pszRx);

View file

@ -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_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_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); 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); 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_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); 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);

View file

@ -456,7 +456,7 @@ nfc_initiator_select_dep_target (nfc_device *pnd,
/** /**
* @brief Deselect a selected passive or emulated tag * @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 * @param pnd \a nfc_device struct pointer that represents currently used device
* *
* After selecting and communicating with a passive tag, this function could be * 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 * tag, test it for the available features and support, deselect it and skip to
* the next tag until the correct tag is found. * the next tag until the correct tag is found.
*/ */
bool int
nfc_initiator_deselect_target (nfc_device *pnd) nfc_initiator_deselect_target (nfc_device *pnd)
{ {
HAL (initiator_deselect_target, pnd); HAL (initiator_deselect_target, pnd);

View file

@ -142,9 +142,9 @@ initiator_thread (void *arg)
const uint8_t abtAttRx[] = "Hello DEP initiator!"; const uint8_t abtAttRx[] = "Hello DEP initiator!";
cut_assert_equal_memory (abtAttRx, sizeof (abtAttRx), abtRx, szRx, cut_message ("Invalid received data")); cut_assert_equal_memory (abtAttRx, sizeof (abtAttRx), abtRx, szRx, cut_message ("Invalid received data"));
if (res < 0) { thread_res = -1; return (void*) thread_res; } if (res < 0) { thread_res = -1; return (void*) thread_res; }
bool bres = nfc_initiator_deselect_target (device); res = nfc_initiator_deselect_target (device);
cut_assert_true (bres, cut_message ("Can't deselect target: %s", nfc_strerror (device))); cut_assert_equal_int (0, res, cut_message ("Can't deselect target: %s", nfc_strerror (device)));
if (!bres) { thread_res = -1; return (void*) thread_res; } if (res < 0) { thread_res = -1; return (void*) thread_res; }
return (void *) thread_res; return (void *) thread_res;
} }

View file

@ -176,9 +176,9 @@ initiator_thread (void *arg)
cut_assert_equal_memory (abtAttRx, sizeof (abtAttRx), abtRx, szRx, cut_message ("Invalid received data")); cut_assert_equal_memory (abtAttRx, sizeof (abtAttRx), abtRx, szRx, cut_message ("Invalid received data"));
if (res < 0) { thread_res = -1; return (void*) thread_res; } if (res < 0) { thread_res = -1; return (void*) thread_res; }
bool bres = nfc_initiator_deselect_target (device); res = nfc_initiator_deselect_target (device);
cut_assert_true (bres, cut_message ("Can't deselect target: %s", nfc_strerror (device))); cut_assert_equal_int (0, res, cut_message ("Can't deselect target: %s", nfc_strerror (device)));
if (!bres) { thread_res = -1; return (void*) thread_res; } if (res < 0) { thread_res = -1; return (void*) thread_res; }
// Passive mode / 212Kbps (second pass) // Passive mode / 212Kbps (second pass)
printf ("=========== INITIATOR %s (Passive mode / 212Kbps) =========\n", nfc_device_get_name (device)); 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")); cut_assert_equal_memory (abtAttRx, sizeof (abtAttRx), abtRx, szRx, cut_message ("Invalid received data"));
if (res < 0) { thread_res = -1; return (void*) thread_res; } if (res < 0) { thread_res = -1; return (void*) thread_res; }
bres = nfc_initiator_deselect_target (device); res = nfc_initiator_deselect_target (device);
cut_assert_true (bres, cut_message ("Can't deselect target: %s", nfc_strerror (device))); cut_assert_equal_int (0, res, cut_message ("Can't deselect target: %s", nfc_strerror (device)));
if (!bres) { thread_res = -1; return (void*) thread_res; } if (res < 0) { thread_res = -1; return (void*) thread_res; }
// Passive mode / 212Kbps // Passive mode / 212Kbps
printf ("=========== INITIATOR %s (Passive mode / 212Kbps, second pass) =========\n", nfc_device_get_name (device)); 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")); cut_assert_equal_memory (abtAttRx, sizeof (abtAttRx), abtRx, szRx, cut_message ("Invalid received data"));
if (res < 0) { thread_res = -1; return (void*) thread_res; } if (res < 0) { thread_res = -1; return (void*) thread_res; }
bres = nfc_initiator_deselect_target (device); res = nfc_initiator_deselect_target (device);
cut_assert_true (bres, cut_message ("Can't deselect target: %s", nfc_strerror (device))); cut_assert_equal_int (0, res, cut_message ("Can't deselect target: %s", nfc_strerror (device)));
if (!bres) { thread_res = -1; return (void*) thread_res; } if (res < 0) { thread_res = -1; return (void*) thread_res; }
// Passive mode / 424Kbps // Passive mode / 424Kbps
printf ("=========== INITIATOR %s (Passive mode / 424Kbps) =========\n", nfc_device_get_name (device)); 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")); cut_assert_equal_memory (abtAttRx, sizeof (abtAttRx), abtRx, szRx, cut_message ("Invalid received data"));
if (res < 0) { thread_res = -1; return (void*) thread_res; } if (res < 0) { thread_res = -1; return (void*) thread_res; }
bres = nfc_initiator_deselect_target (device); res = nfc_initiator_deselect_target (device);
cut_assert_true (bres, cut_message ("Can't deselect target: %s", nfc_strerror (device))); cut_assert_equal_int (0, res, cut_message ("Can't deselect target: %s", nfc_strerror (device)));
if (!bres) { thread_res = -1; return (void*) thread_res; } if (res < 0) { thread_res = -1; return (void*) thread_res; }
return (void *) thread_res; return (void *) thread_res;
} }