summaryrefslogtreecommitdiffstats
path: root/src/phLibNfc_initiator.c
diff options
context:
space:
mode:
authorMartijn Coenen <martijn.coenen@nxp.com>2011-02-03 17:07:12 +0100
committerNick Pelly <npelly@google.com>2011-02-18 01:50:36 -0800
commita61bf7e2cb6cf80f1deea680613423a477ac4fb8 (patch)
treec1e8a7bff48acc4957fdbf20f074a8d2fd038c3b /src/phLibNfc_initiator.c
parent18516f4e58aad80815fb6efea22d217d39b90c10 (diff)
downloadexternal_libnfc-nxp-a61bf7e2cb6cf80f1deea680613423a477ac4fb8.zip
external_libnfc-nxp-a61bf7e2cb6cf80f1deea680613423a477ac4fb8.tar.gz
external_libnfc-nxp-a61bf7e2cb6cf80f1deea680613423a477ac4fb8.tar.bz2
Narrow down NFCSTATUS_TARGET_LOST responses from libNFC.
During extensive testing we found that some ISO15693 tags do not react to some commands. However, they do send an error code to the PN544 indicating they do not support the command. The PN544 in turn sends one specific error code over the HCI interface. However, libNFC maps that error code always to NFCSTATUS_TARGET_LOST, which in the end maps to the application API reporting a TargetLostException. This fix maps only the timeout return values from the PN544 to NFCSTATUS_TARGET_LOST; all other values are mapped to NFCSTATUS_FAILED, which in turn maps to an IOException at API level. In effect, a timeout is still not the same as a target lost; libNFC does not do any additional internal presence check to make sure the tag is really gone, although it usually is. I'll submit a separate fix on packages/apps/Nfc to take care of this. Change-Id: If64857658d683aff29134f74b42efd99b695e634
Diffstat (limited to 'src/phLibNfc_initiator.c')
-rw-r--r--src/phLibNfc_initiator.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/phLibNfc_initiator.c b/src/phLibNfc_initiator.c
index d93d5f6..340af78 100644
--- a/src/phLibNfc_initiator.c
+++ b/src/phLibNfc_initiator.c
@@ -55,7 +55,7 @@
*************************** Global Variables **********************************
*/
-
+#define PN544_IO_TIMEOUT_RESPONSE 0x89
/*
*************************** Static Function Declaration ***********************
@@ -1154,10 +1154,17 @@ void phLibNfc_RemoteDev_Transceive_Cb(void *context,
phLibNfc_Reconnect_Mifare_Cb,
(void *)gpphLibContext);
}
- else
+ else if ((PHNFCSTATUS(status) == PN544_IO_TIMEOUT_RESPONSE) ||
+ (PHNFCSTATUS(status) == NFCSTATUS_RF_TIMEOUT))
{
+ // 0x89, 0x09 HCI response values from PN544 indicate timeout
trans_status = NFCSTATUS_TARGET_LOST;
}
+ else
+ {
+ // PN544 did get some reply from tag, just not valid
+ trans_status = NFCSTATUS_FAILED;
+ }
/*Update the state machine */
phLibNfc_UpdateCurState(status,gpphLibContext);
gpphLibContext->LibNfcState.next_state = eLibNfcHalStateConnect;