summaryrefslogtreecommitdiffstats
path: root/src/phFriNfc_TopazMap.c
diff options
context:
space:
mode:
authorMartijn Coenen <martijn.coenen@nxp.com>2010-12-16 23:24:55 +0100
committerNick Pelly <npelly@google.com>2010-12-16 16:49:43 -0800
commit80ee29b88ec489e2bbf6ae446692229d36755429 (patch)
tree9592b7c752c315b6474f72b76b9dc220991290cc /src/phFriNfc_TopazMap.c
parentd75796b759f9baac8facf22f1b6c6bcfbc51161e (diff)
downloadexternal_libnfc-nxp-80ee29b88ec489e2bbf6ae446692229d36755429.zip
external_libnfc-nxp-80ee29b88ec489e2bbf6ae446692229d36755429.tar.gz
external_libnfc-nxp-80ee29b88ec489e2bbf6ae446692229d36755429.tar.bz2
Add support for makeLowLevelReadonly() in libnfc.
Implemented for T1T and T2T. There's also added code for formatting Desfire EV1, but it will not be used by the current implementation (DesFIRE doesn't have NdefFormatable tech). Change-Id: Iec1b85b560fbf800291fd307b56ab84328737635
Diffstat (limited to 'src/phFriNfc_TopazMap.c')
-rw-r--r--src/phFriNfc_TopazMap.c55
1 files changed, 49 insertions, 6 deletions
diff --git a/src/phFriNfc_TopazMap.c b/src/phFriNfc_TopazMap.c
index 8901aa7..ff445cb 100644
--- a/src/phFriNfc_TopazMap.c
+++ b/src/phFriNfc_TopazMap.c
@@ -53,6 +53,14 @@
*/
/* #define TOPAZ_RF_ERROR_WORKAROUND */
+#ifdef FRINFC_READONLY_NDEF
+
+ #define CC_BLOCK_NUMBER (0x01U)
+ #define CC_RWA_BYTE_NUMBER (0x03U)
+ #define CC_READ_ONLY_VALUE (0x0FU)
+
+#endif /* #ifdef FRINFC_READONLY_NDEF */
+
#ifdef TOPAZ_RF_ERROR_WORKAROUND
/* Below MACROs are added for the error returned from HAL, if the
@@ -277,6 +285,25 @@ NFCSTATUS phFriNfc_TopazMap_ChkNdef( phFriNfc_NdefMap_t *NdefMap)
return Result;
}
+#ifdef FRINFC_READONLY_NDEF
+
+NFCSTATUS
+phFriNfc_TopazMap_ConvertToReadOnly (
+ phFriNfc_NdefMap_t *NdefMap)
+{
+ NFCSTATUS result = NFCSTATUS_SUCCESS;
+
+ result = phFriNfc_Tpz_H_WrAByte (NdefMap, CC_BLOCK_NUMBER,
+ CC_RWA_BYTE_NUMBER, CC_READ_ONLY_VALUE);
+
+ if (NFCSTATUS_PENDING == PHNFCSTATUS(result))
+ {
+ NdefMap->State = PH_FRINFC_TOPAZ_STATE_READ_ONLY;
+ }
+ return result;
+}
+
+#endif /* #ifdef FRINFC_READONLY_NDEF */
/*!
* \brief Initiates Reading of NDEF information from the Remote Device.
@@ -482,6 +509,22 @@ void phFriNfc_TopazMap_Process( void *Context,
{
switch (psNdefMap->State)
{
+#ifdef FRINFC_READONLY_NDEF
+ case PH_FRINFC_TOPAZ_STATE_READ_ONLY:
+ {
+ if((CC_READ_ONLY_VALUE == *psNdefMap->SendRecvBuf)
+ && (PH_FRINFC_TOPAZ_VAL1 == *psNdefMap->SendRecvLength))
+ {
+ /* Do nothing */
+ }
+ else
+ {
+ Status = PHNFCSTVAL(CID_FRI_NFC_NDEF_MAP,
+ NFCSTATUS_INVALID_RECEIVE_LENGTH);
+ }
+ break;
+ }
+#endif /* #ifdef FRINFC_READONLY_NDEF */
case PH_FRINFC_TOPAZ_STATE_WRITE:
{
Status = phFriNfc_Tpz_H_ProWrUsrData (psNdefMap);
@@ -821,9 +864,9 @@ static NFCSTATUS phFriNfc_Tpz_H_RdBytes(phFriNfc_NdefMap_t *NdefMap,
/*Copy UID of the tag to Send Buffer*/
(void)memcpy(&(NdefMap->SendRecvBuf[PH_FRINFC_TOPAZ_VAL3]),
&(NdefMap->psRemoteDevInfo->RemoteDevInfo.Jewel_Info.Uid),
- (NdefMap->psRemoteDevInfo->RemoteDevInfo.Jewel_Info.UidLength));
+ TOPAZ_UID_LENGTH_FOR_READ_WRITE);
- index = index + NdefMap->psRemoteDevInfo->RemoteDevInfo.Jewel_Info.UidLength;
+ index = (uint8_t)(index + TOPAZ_UID_LENGTH_FOR_READ_WRITE);
/* Update the length of the command buffer*/
NdefMap->SendLength = index;
@@ -866,8 +909,8 @@ static NFCSTATUS phFriNfc_Tpz_H_RdBytes(phFriNfc_NdefMap_t *NdefMap,
/*Copy UID of the tag to Send Buffer*/
(void)memcpy(&(NdefMap->SendRecvBuf[PH_FRINFC_TOPAZ_VAL3]),
&(NdefMap->psRemoteDevInfo->RemoteDevInfo.Jewel_Info.Uid),
- (NdefMap->psRemoteDevInfo->RemoteDevInfo.Jewel_Info.UidLength));
- index = index + NdefMap->psRemoteDevInfo->RemoteDevInfo.Jewel_Info.UidLength;
+ TOPAZ_UID_LENGTH_FOR_READ_WRITE);
+ index = (uint8_t)(index + TOPAZ_UID_LENGTH_FOR_READ_WRITE);
/* Update the length of the command buffer*/
NdefMap->SendLength = index;
@@ -968,8 +1011,8 @@ static NFCSTATUS phFriNfc_Tpz_H_WrAByte(phFriNfc_NdefMap_t *NdefMap,
/*Copy UID of the tag to Send Buffer*/
(void)memcpy(&(NdefMap->SendRecvBuf[PH_FRINFC_TOPAZ_VAL3]),
&(NdefMap->psRemoteDevInfo->RemoteDevInfo.Jewel_Info.Uid),
- (NdefMap->psRemoteDevInfo->RemoteDevInfo.Jewel_Info.UidLength));
- index = index + NdefMap->psRemoteDevInfo->RemoteDevInfo.Jewel_Info.UidLength;
+ TOPAZ_UID_LENGTH_FOR_READ_WRITE);
+ index = (uint8_t)(index + TOPAZ_UID_LENGTH_FOR_READ_WRITE);
/* Update the length of the command buffer*/
NdefMap->SendLength = index;