diff --git a/libnfc/chips/pn53x.c b/libnfc/chips/pn53x.c index 0bc3b0f..696f9b1 100644 --- a/libnfc/chips/pn53x.c +++ b/libnfc/chips/pn53x.c @@ -699,6 +699,7 @@ pn53x_set_property_bool (struct nfc_device *pnd, const nfc_property property, co if (!pn53x_write_register (pnd, PN53X_REG_CIU_RxMode, SYMBOL_RX_CRC_ENABLE, btValue)) return NFC_ECHIP; pnd->bCrc = bEnable; + return NFC_SUCCESS; break; case NP_HANDLE_PARITY: @@ -710,15 +711,18 @@ pn53x_set_property_bool (struct nfc_device *pnd, const nfc_property property, co if (!pn53x_write_register (pnd, PN53X_REG_CIU_ManualRCV, SYMBOL_PARITY_DISABLE, btValue)) return NFC_ECHIP; pnd->bPar = bEnable; + return NFC_SUCCESS; break; case NP_EASY_FRAMING: pnd->bEasyFraming = bEnable; + return NFC_SUCCESS; break; case NP_ACTIVATE_FIELD: { - return pn53x_RFConfiguration__RF_field (pnd, bEnable); + if (pn53x_RFConfiguration__RF_field (pnd, bEnable)) + return NFC_SUCCESS; } break; @@ -726,6 +730,7 @@ pn53x_set_property_bool (struct nfc_device *pnd, const nfc_property property, co btValue = (bEnable) ? SYMBOL_MF_CRYPTO1_ON : 0x00; if (!pn53x_write_register (pnd, PN53X_REG_CIU_Status2, SYMBOL_MF_CRYPTO1_ON, btValue)) return NFC_ECHIP; + return NFC_SUCCESS; break; case NP_INFINITE_SELECT: @@ -733,11 +738,12 @@ pn53x_set_property_bool (struct nfc_device *pnd, const nfc_property property, co // TODO Made some research around this point: // timings could be tweak better than this, and maybe we can tweak timings // to "gain" a sort-of hardware polling (ie. like PN532 does) - return pn53x_RFConfiguration__MaxRetries (pnd, + if (pn53x_RFConfiguration__MaxRetries (pnd, (bEnable) ? 0xff : 0x00, // MxRtyATR, default: active = 0xff, passive = 0x02 (bEnable) ? 0xff : 0x00, // MxRtyPSL, default: 0x01 (bEnable) ? 0xff : 0x02 // MxRtyPassiveActivation, default: 0xff (0x00 leads to problems with PN531) - ); + )) + return NFC_SUCCESS; } break; @@ -745,6 +751,7 @@ pn53x_set_property_bool (struct nfc_device *pnd, const nfc_property property, co btValue = (bEnable) ? SYMBOL_RX_NO_ERROR : 0x00; if (!pn53x_write_register (pnd, PN53X_REG_CIU_RxMode, SYMBOL_RX_NO_ERROR, btValue)) return NFC_ECHIP; + return NFC_SUCCESS; break; case NP_ACCEPT_MULTIPLE_FRAMES: @@ -759,7 +766,8 @@ pn53x_set_property_bool (struct nfc_device *pnd, const nfc_property property, co // Nothing to do return NFC_SUCCESS; pnd->bAutoIso14443_4 = bEnable; - return pn53x_set_parameters (pnd, PARAM_AUTO_RATS, bEnable); + if (pn53x_set_parameters (pnd, PARAM_AUTO_RATS, bEnable)) + return NFC_SUCCESS; break; case NP_FORCE_ISO14443_A: diff --git a/test/test_dep_active.c b/test/test_dep_active.c index 18a0454..b9101e8 100644 --- a/test/test_dep_active.c +++ b/test/test_dep_active.c @@ -116,15 +116,15 @@ initiator_thread (void *arg) */ sleep (1); printf ("=========== INITIATOR %s =========\n", nfc_device_get_name (device)); - bool res = nfc_initiator_init (device); - cut_assert_equal_int (0, res, cut_message ("Can't initialize NFC device as initiator: %s", nfc_strerror (device))); - if (!res) { thread_res = -1; return (void*) thread_res; } + int ires = nfc_initiator_init (device); + cut_assert_equal_int (0, ires, cut_message ("Can't initialize NFC device as initiator: %s", nfc_strerror (device))); + if (ires < 0) { thread_res = -1; return (void*) thread_res; } nfc_target nt; // Active mode printf ("=========== INITIATOR %s (Active mode / %s Kbps) =========\n", nfc_device_get_name (device), str_nfc_baud_rate(nbr)); - res = nfc_initiator_select_dep_target (device, NDM_ACTIVE, nbr, NULL, &nt, 1000); + bool res = nfc_initiator_select_dep_target (device, NDM_ACTIVE, nbr, NULL, &nt, 1000); cut_assert_true (res, cut_message ("Can't select any DEP target: %s", nfc_strerror (device))); cut_assert_equal_int (NMT_DEP, nt.nm.nmt, cut_message ("Invalid target modulation")); cut_assert_equal_int (nbr, nt.nm.nbr, cut_message ("Invalid target baud rate")); diff --git a/test/test_dep_passive.c b/test/test_dep_passive.c index 162d582..a071517 100644 --- a/test/test_dep_passive.c +++ b/test/test_dep_passive.c @@ -149,15 +149,16 @@ initiator_thread (void *arg) sleep (1); printf ("=========== INITIATOR %s =========\n", nfc_device_get_name (device)); - bool res = nfc_initiator_init (device); - cut_assert_equal_int (0, res, cut_message ("Can't initialize NFC device as initiator: %s", nfc_strerror (device))); - if (!res) { thread_res = -1; return (void*) thread_res; } + int ires = nfc_initiator_init (device); + printf ("IRES: %d\n", ires); + cut_assert_equal_int (0, ires, cut_message ("Can't initialize NFC device as initiator: %s", nfc_strerror (device))); + if (ires < 0) { thread_res = -1; return (void*) thread_res; } nfc_target nt; // Passive mode / 106Kbps printf ("=========== INITIATOR %s (Passive mode / 106Kbps) =========\n", nfc_device_get_name (device)); - res = nfc_initiator_select_dep_target (device, NDM_PASSIVE, NBR_106, NULL, &nt, 5000); + bool res = nfc_initiator_select_dep_target (device, NDM_PASSIVE, NBR_106, NULL, &nt, 5000); cut_assert_true (res, cut_message ("Can't select any DEP target: %s", nfc_strerror (device))); cut_assert_equal_int (NMT_DEP, nt.nm.nmt, cut_message ("Invalid target modulation")); cut_assert_equal_int (NBR_106, nt.nm.nbr, cut_message ("Invalid target baud rate"));