diff options
-rw-r--r-- | src/phLibNfc.h | 17 | ||||
-rw-r--r-- | src/phLibNfc_ndef_raw.c | 35 |
2 files changed, 52 insertions, 0 deletions
diff --git a/src/phLibNfc.h b/src/phLibNfc.h index 0f16aee..60ccff2 100644 --- a/src/phLibNfc.h +++ b/src/phLibNfc.h @@ -327,6 +327,22 @@ typedef struct phLibNfc_Ndef_Info } phLibNfc_Ndef_Info_t; +/* As per NFC forum specification, the card can be in either of the below mentioned states + INVALID - means card is NOT NFC forum specified tag. NDEF FORMAT can only be performed for + the factory cards, other cards may or may not be formatted for NDEF FORMAT function. + INITIALISED - means card is NFC forum specified tag. But, in this state + the user has to first call NDEF WRITE, because in INITIALISED state, there + wont be any data i.e.,ACTUAL NDEF FILE SIZE is 0. After the first + NDEF WRITE, NDEF READ and WRITE functions can be called any number of times. + READ WRITE - means card is NFC forum specified tag. User can use both + NDEF READ and WRITE functions + READ ONLY - means card is NFC forum specified tag. User can only use + NDEF READ. NDEF WRITE function will not work. + */ +#define PHLIBNFC_NDEF_CARD_INVALID 0x00U +#define PHLIBNFC_NDEF_CARD_INITIALISED 0x01U +#define PHLIBNFC_NDEF_CARD_READ_WRITE 0x02U +#define PHLIBNFC_NDEF_CARD_READ_ONLY 0x03U /** * \ingroup grp_lib_nfc @@ -335,6 +351,7 @@ typedef struct phLibNfc_Ndef_Info */ typedef struct phLibNfc_ChkNdef_Info { + uint8_t NdefCardState; /**< Card state information */ uint32_t ActualNdefMsgLength; /**< Indicates Actual length of NDEF Message in Tag */ uint32_t MaxNdefMsgLength; /**< Indicates Maximum Ndef Message length that Tag can hold*/ } phLibNfc_ChkNdef_Info_t; diff --git a/src/phLibNfc_ndef_raw.c b/src/phLibNfc_ndef_raw.c index ac29d70..4c3d647 100644 --- a/src/phLibNfc_ndef_raw.c +++ b/src/phLibNfc_ndef_raw.c @@ -856,6 +856,7 @@ void phLibNfc_Ndef_CheckNdef_Cb(void *pContext,NFCSTATUS status) Ndef_Info.ActualNdefMsgLength = 0; Ndef_Info.MaxNdefMsgLength = 0; + Ndef_Info.NdefCardState = PHLIBNFC_NDEF_CARD_INVALID; if(pLibNfc_Ctxt != gpphLibContext) { /*wrong context returned from below layer*/ phOsalNfc_RaiseException(phOsalNfc_e_InternalErr,1); @@ -989,6 +990,39 @@ void phLibNfc_Ndef_CheckNdef_Cb(void *pContext,NFCSTATUS status) gpphLibContext->CBInfo.pClientCkNdefCntx = NULL; if(NULL != pClientCb) { + if (!RetStatus) + { + switch (pLibNfc_Ctxt->ndef_cntx.psNdefMap->CardState) + { + case PH_NDEFMAP_CARD_STATE_INITIALIZED: + { + Ndef_Info.NdefCardState = + PHLIBNFC_NDEF_CARD_INITIALISED; + break; + } + + case PH_NDEFMAP_CARD_STATE_READ_ONLY: + { + Ndef_Info.NdefCardState = + PHLIBNFC_NDEF_CARD_READ_ONLY; + break; + } + + case PH_NDEFMAP_CARD_STATE_READ_WRITE: + { + Ndef_Info.NdefCardState = + PHLIBNFC_NDEF_CARD_READ_WRITE; + break; + } + + default: + { + Ndef_Info.NdefCardState = + PHLIBNFC_NDEF_CARD_INVALID; + break; + } + } + } /* call the upper check ndef callback */ pClientCb(pUpperLayerContext,Ndef_Info,RetStatus); } @@ -1068,6 +1102,7 @@ STATIC void phLibNfc_Ndef_ChkNdef_Pchk_Cb(void *pContext, gpphLibContext->CBInfo.pClientCkNdefCntx = NULL; if(NULL != pClientCb) { + Ndef_Info.NdefCardState = PHLIBNFC_NDEF_CARD_INVALID; /* call the upper check ndef callback */ pClientCb(pUpperLayerContext,Ndef_Info,RetStatus); } |