Lines Matching refs:NdefMap
69 static NFCSTATUS phFriNfc_Desfire_SelectSmartTag( phFriNfc_NdefMap_t *NdefMap);
75 static NFCSTATUS phFriNfc_Desfire_SelectFile ( phFriNfc_NdefMap_t *NdefMap);
81 static NFCSTATUS phFriNfc_Desfire_ReadBinary( phFriNfc_NdefMap_t *NdefMap);
87 static NFCSTATUS phFriNfc_Desfire_UpdateBinary( phFriNfc_NdefMap_t *NdefMap);
93 static NFCSTATUS phFriNfc_Desfire_Update_SmartTagCapContainer( phFriNfc_NdefMap_t *NdefMap);
97 static void phFriNfc_Desfire_HCrHandler( phFriNfc_NdefMap_t *NdefMap,
101 static uint32_t phFriNfc_Desfire_HGetLeBytes( phFriNfc_NdefMap_t *NdefMap);
103 static NFCSTATUS phFriNfc_Desf_HChkAndParseTLV( phFriNfc_NdefMap_t *NdefMap,
106 static NFCSTATUS phFriNfc_Desfire_HSetGet_NLEN( phFriNfc_NdefMap_t *NdefMap);
108 static void phFriNfc_Desfire_HProcReadData( phFriNfc_NdefMap_t *NdefMap);
110 static void phFriNfc_Desfire_HChkNDEFFileAccessRights( phFriNfc_NdefMap_t *NdefMap);
111 static NFCSTATUS phFriNfc_Desfire_HSendTransCmd(phFriNfc_NdefMap_t *NdefMap,uint8_t SendRecvLen);
118 static NFCSTATUS phFriNfc_Desfire_HGetHWVersion(phFriNfc_NdefMap_t *NdefMap);
119 static NFCSTATUS phFriNfc_Desfire_HGetSWVersion(phFriNfc_NdefMap_t *NdefMap);
120 static NFCSTATUS phFriNfc_Desfire_HGetUIDDetails(phFriNfc_NdefMap_t *NdefMap);
121 static NFCSTATUS phFriNfc_Desfire_HUpdateVersionDetails(const phFriNfc_NdefMap_t *NdefMap);
129 static NFCSTATUS phFriNfc_Desfire_HGetHWVersion(phFriNfc_NdefMap_t *NdefMap) in phFriNfc_Desfire_HGetHWVersion() argument
135 NdefMap->State = PH_FRINFC_DESF_STATE_GET_HW_VERSION; in phFriNfc_Desfire_HGetHWVersion()
139 status = phFriNfc_Desfire_HSendTransCmd(NdefMap,PH_FRINFC_NDEFMAP_MAX_SEND_RECV_BUF_SIZE); in phFriNfc_Desfire_HGetHWVersion()
144 static NFCSTATUS phFriNfc_Desfire_HGetSWVersion(phFriNfc_NdefMap_t *NdefMap) in phFriNfc_Desfire_HGetSWVersion() argument
148 … if( ( NdefMap->SendRecvBuf[*(NdefMap->SendRecvLength)- 1] == PH_FRINFC_DESF_NATIVE_GETVER_RESP) ) in phFriNfc_Desfire_HGetSWVersion()
151 NdefMap->State = PH_FRINFC_DESF_STATE_GET_SW_VERSION; in phFriNfc_Desfire_HGetSWVersion()
155 status = phFriNfc_Desfire_HSendTransCmd(NdefMap,PH_FRINFC_NDEFMAP_MAX_SEND_RECV_BUF_SIZE); in phFriNfc_Desfire_HGetSWVersion()
167 static NFCSTATUS phFriNfc_Desfire_HGetUIDDetails(phFriNfc_NdefMap_t *NdefMap) in phFriNfc_Desfire_HGetUIDDetails() argument
172 … if( ( NdefMap->SendRecvBuf[*(NdefMap->SendRecvLength)- 1] == PH_FRINFC_DESF_NATIVE_GETVER_RESP) ) in phFriNfc_Desfire_HGetUIDDetails()
175 NdefMap->State = PH_FRINFC_DESF_STATE_GET_UID; in phFriNfc_Desfire_HGetUIDDetails()
180 status = phFriNfc_Desfire_HSendTransCmd(NdefMap,PH_FRINFC_NDEFMAP_MAX_SEND_RECV_BUF_SIZE); in phFriNfc_Desfire_HGetUIDDetails()
193 static NFCSTATUS phFriNfc_Desfire_HUpdateVersionDetails(const phFriNfc_NdefMap_t *NdefMap) in phFriNfc_Desfire_HUpdateVersionDetails() argument
198 if( ( NdefMap->SendRecvBuf[*(NdefMap->SendRecvLength)- 1] == 0xAF) ) in phFriNfc_Desfire_HUpdateVersionDetails()
205 NdefMap->AddInfo.Type4Info.MajorVersion = NdefSmtCrdFmt->SendRecvBuf[3]; in phFriNfc_Desfire_HUpdateVersionDetails()
206 NdefMap->AddInfo.Type4Info.MinorVersion = NdefSmtCrdFmt->SendRecvBuf[4]; in phFriNfc_Desfire_HUpdateVersionDetails()
207 if ( ( NdefMap->AddInfo.Type4Info.MajorVersion == 0x00 )&& in phFriNfc_Desfire_HUpdateVersionDetails()
208 ( NdefMap->AddInfo.Type4Info.MinorVersion == 0x06 )) in phFriNfc_Desfire_HUpdateVersionDetails()
236 NFCSTATUS phFriNfc_Desfire_RdNdef( phFriNfc_NdefMap_t *NdefMap, in phFriNfc_Desfire_RdNdef() argument
243 NdefMap->ApduBufferSize = *PacketDataLength; in phFriNfc_Desfire_RdNdef()
245 NdefMap->NumOfBytesRead = PacketDataLength ; in phFriNfc_Desfire_RdNdef()
246 *NdefMap->NumOfBytesRead = 0; in phFriNfc_Desfire_RdNdef()
249 NdefMap->Offset = Offset; in phFriNfc_Desfire_RdNdef()
252 (*NdefMap->DataCount == NdefMap->DesfireCapContainer.NdefDataLen)) in phFriNfc_Desfire_RdNdef()
264 NdefMap->DesfireCapContainer.IsNlenPresentFlag = 0; in phFriNfc_Desfire_RdNdef()
265 NdefMap->DesfireCapContainer.SkipNlenBytesFlag = 0; in phFriNfc_Desfire_RdNdef()
268 NdefMap->DespOpFlag = PH_FRINFC_NDEFMAP_DESF_READ_OP; in phFriNfc_Desfire_RdNdef()
271 NdefMap->ApduBuffer = PacketData; in phFriNfc_Desfire_RdNdef()
273 NdefMap->PrevOperation = PH_FRINFC_NDEFMAP_READ_OPE; in phFriNfc_Desfire_RdNdef()
277 if (PH_FRINFC_NDEFMAP_ISO14443_4A_CARD_EV1 == NdefMap->CardType) in phFriNfc_Desfire_RdNdef()
279 status = phFriNfc_Desfire_SelectFile(NdefMap); in phFriNfc_Desfire_RdNdef()
284 status = phFriNfc_Desfire_SelectSmartTag(NdefMap); in phFriNfc_Desfire_RdNdef()
300 NFCSTATUS phFriNfc_Desfire_WrNdef( phFriNfc_NdefMap_t *NdefMap, in phFriNfc_Desfire_WrNdef() argument
307 NdefMap->ApduBufferSize = *PacketDataLength; in phFriNfc_Desfire_WrNdef()
308 NdefMap->WrNdefPacketLength = PacketDataLength; in phFriNfc_Desfire_WrNdef()
314 *NdefMap->WrNdefPacketLength = 0; in phFriNfc_Desfire_WrNdef()
317 if( *NdefMap->DataCount >= PH_NFCFRI_NDEFMAP_DESF_NDEF_FILE_SIZE) in phFriNfc_Desfire_WrNdef()
330 NdefMap->DespOpFlag = PH_FRINFC_NDEFMAP_DESF_WRITE_OP; in phFriNfc_Desfire_WrNdef()
331 NdefMap->PrevOperation = PH_FRINFC_NDEFMAP_WRITE_OPE; in phFriNfc_Desfire_WrNdef()
332 NdefMap->Offset = Offset; in phFriNfc_Desfire_WrNdef()
335 NdefMap->ApduBuffer = PacketData; in phFriNfc_Desfire_WrNdef()
338 if (PH_FRINFC_NDEFMAP_ISO14443_4A_CARD_EV1 == NdefMap->CardType) in phFriNfc_Desfire_WrNdef()
340 status = phFriNfc_Desfire_SelectFile(NdefMap); in phFriNfc_Desfire_WrNdef()
346 status = phFriNfc_Desfire_SelectSmartTag (NdefMap); in phFriNfc_Desfire_WrNdef()
359 NFCSTATUS phFriNfc_Desfire_ChkNdef( phFriNfc_NdefMap_t *NdefMap) in phFriNfc_Desfire_ChkNdef() argument
367 NdefMap->CardType = 0; in phFriNfc_Desfire_ChkNdef()
370 NdefMap->DespOpFlag = PH_FRINFC_NDEFMAP_DESF_NDEF_CHK_OP; in phFriNfc_Desfire_ChkNdef()
373 status = phFriNfc_Desfire_SelectSmartTag(NdefMap); in phFriNfc_Desfire_ChkNdef()
377 status = phFriNfc_Desfire_HGetHWVersion(NdefMap); in phFriNfc_Desfire_ChkNdef()
383 static NFCSTATUS phFriNfc_Desf_HChkAndParseTLV(phFriNfc_NdefMap_t *NdefMap, uint8_t BuffIndex) in phFriNfc_Desf_HChkAndParseTLV() argument
387 if((NdefMap->SendRecvBuf[BuffIndex] <= 0x03) || in phFriNfc_Desf_HChkAndParseTLV()
388 (NdefMap->SendRecvBuf[BuffIndex] >= 0x06) ) in phFriNfc_Desf_HChkAndParseTLV()
396 NdefMap->TLVFoundFlag = in phFriNfc_Desf_HChkAndParseTLV()
397 ((NdefMap->SendRecvBuf[BuffIndex] == 0x04)? in phFriNfc_Desf_HChkAndParseTLV()
407 static NFCSTATUS phFriNfc_Desfire_HSetGet_NLEN(phFriNfc_NdefMap_t *NdefMap) in phFriNfc_Desfire_HSetGet_NLEN() argument
412 if ( PH_FRINFC_NDEFMAP_DESF_GET_LEN_OP == NdefMap->DespOpFlag) in phFriNfc_Desfire_HSetGet_NLEN()
416 status = phFriNfc_Desfire_SelectSmartTag(NdefMap); in phFriNfc_Desfire_HSetGet_NLEN()
425 NdefMap->SendRecvBuf[0] = 0x00; in phFriNfc_Desfire_HSetGet_NLEN()
426 NdefMap->SendRecvBuf[1] = 0xD6; in phFriNfc_Desfire_HSetGet_NLEN()
430 NdefMap->SendRecvBuf[2] = 0x00; /* p1 */ in phFriNfc_Desfire_HSetGet_NLEN()
431 NdefMap->SendRecvBuf[3] = 0x00; /* p2 */ in phFriNfc_Desfire_HSetGet_NLEN()
434 NdefMap->SendRecvBuf[4] = 0x02; in phFriNfc_Desfire_HSetGet_NLEN()
437 NdefMap->SendRecvBuf[5] = (uint8_t)(*NdefMap->DataCount >> PH_FRINFC_NDEFMAP_DESF_SHL8); in phFriNfc_Desfire_HSetGet_NLEN()
438 NdefMap->SendRecvBuf[6] = (uint8_t)(*NdefMap->DataCount & (0x00ff)); in phFriNfc_Desfire_HSetGet_NLEN()
440 NdefMap->SendLength = 0x07 ; in phFriNfc_Desfire_HSetGet_NLEN()
443 NdefMap->State = PH_FRINFC_NDEFMAP_DESF_STATE_UPDATE_BIN_END; in phFriNfc_Desfire_HSetGet_NLEN()
445 status = phFriNfc_Desfire_HSendTransCmd(NdefMap,PH_FRINFC_NDEFMAP_DESF_RESP_OFFSET); in phFriNfc_Desfire_HSetGet_NLEN()
450 static void phFriNfc_Desfire_HProcReadData(phFriNfc_NdefMap_t *NdefMap) in phFriNfc_Desfire_HProcReadData() argument
468 if ( NdefMap->Offset == PH_FRINFC_NDEFMAP_SEEK_BEGIN ) in phFriNfc_Desfire_HProcReadData()
470 BufIndex = (uint8_t)(( NdefMap->DesfireCapContainer.IsNlenPresentFlag == 1 )? in phFriNfc_Desfire_HProcReadData()
474 NdefMap->DesfireCapContainer.NdefDataLen = ((*NdefMap->DataCount == 0)? in phFriNfc_Desfire_HProcReadData()
475 ( (((uint16_t)NdefMap->SendRecvBuf[ in phFriNfc_Desfire_HProcReadData()
477 NdefMap->SendRecvBuf[PH_FRINFC_NDEFMAP_DESF_CCLEN_BYTE_SECOND_INDEX]): in phFriNfc_Desfire_HProcReadData()
478 NdefMap->DesfireCapContainer.NdefDataLen); in phFriNfc_Desfire_HProcReadData()
482 if ( (NdefMap->DesfireCapContainer.NdefDataLen) <= (*NdefMap->SendRecvLength - \ in phFriNfc_Desfire_HProcReadData()
485 SizeToCpy = NdefMap->DesfireCapContainer.NdefDataLen; in phFriNfc_Desfire_HProcReadData()
490 SizeToCpy = ((*NdefMap->SendRecvLength)-(PH_FRINFC_NDEFMAP_DESF_RESP_OFFSET+BufIndex)); in phFriNfc_Desfire_HProcReadData()
495 if ( NdefMap->DesfireCapContainer.NdefDataLen == 0x00 ) in phFriNfc_Desfire_HProcReadData()
497 NdefMap->CardState = PH_NDEFMAP_CARD_STATE_INITIALIZED; in phFriNfc_Desfire_HProcReadData()
501 NdefMap->PrevOperation = 0; in phFriNfc_Desfire_HProcReadData()
503 phFriNfc_Desfire_HCrHandler(NdefMap,Result); in phFriNfc_Desfire_HProcReadData()
507 (void)memcpy( (&(NdefMap->ApduBuffer[ in phFriNfc_Desfire_HProcReadData()
508 NdefMap->ApduBuffIndex])), in phFriNfc_Desfire_HProcReadData()
509 (&(NdefMap->SendRecvBuf[BufIndex])), in phFriNfc_Desfire_HProcReadData()
513 *NdefMap->NumOfBytesRead = (uint32_t)(*NdefMap->NumOfBytesRead + SizeToCpy); in phFriNfc_Desfire_HProcReadData()
516 *NdefMap->DataCount = (uint16_t)(*NdefMap->DataCount + SizeToCpy); in phFriNfc_Desfire_HProcReadData()
519 NdefMap->ApduBuffIndex = (uint16_t)(NdefMap->ApduBuffIndex + SizeToCpy); in phFriNfc_Desfire_HProcReadData()
524 (void)memcpy( (&(NdefMap->ApduBuffer[ in phFriNfc_Desfire_HProcReadData()
525 NdefMap->ApduBuffIndex])), in phFriNfc_Desfire_HProcReadData()
526 (NdefMap->SendRecvBuf),/* to avoid the length of the NDEF File*/ in phFriNfc_Desfire_HProcReadData()
527 (*(NdefMap->SendRecvLength)-(PH_FRINFC_NDEFMAP_DESF_RESP_OFFSET))); in phFriNfc_Desfire_HProcReadData()
530 *NdefMap->NumOfBytesRead +=( *NdefMap->SendRecvLength - \ in phFriNfc_Desfire_HProcReadData()
534 *NdefMap->DataCount += \ in phFriNfc_Desfire_HProcReadData()
535 (*NdefMap->SendRecvLength - (PH_FRINFC_NDEFMAP_DESF_RESP_OFFSET)); in phFriNfc_Desfire_HProcReadData()
538 NdefMap->ApduBuffIndex += \ in phFriNfc_Desfire_HProcReadData()
539 *NdefMap->SendRecvLength - (PH_FRINFC_NDEFMAP_DESF_RESP_OFFSET ); in phFriNfc_Desfire_HProcReadData()
543 if (*NdefMap->DataCount < NdefMap->DesfireCapContainer.NdefDataLen ) in phFriNfc_Desfire_HProcReadData()
548 BufferSize = NdefMap->ApduBufferSize - NdefMap->ApduBuffIndex; in phFriNfc_Desfire_HProcReadData()
555 NdefMap->DesfireCapContainer.IsNlenPresentFlag = 1; in phFriNfc_Desfire_HProcReadData()
557 Result = phFriNfc_Desfire_ReadBinary( NdefMap ); in phFriNfc_Desfire_HProcReadData()
562 phFriNfc_Desfire_HCrHandler(NdefMap,Result); in phFriNfc_Desfire_HProcReadData()
570 NdefMap->ApduBuffIndex =0; in phFriNfc_Desfire_HProcReadData()
572 phFriNfc_Desfire_HCrHandler(NdefMap,Result); in phFriNfc_Desfire_HProcReadData()
577 if (*NdefMap->DataCount == NdefMap->DesfireCapContainer.NdefDataLen ) in phFriNfc_Desfire_HProcReadData()
584 NdefMap->PrevOperation = 0; in phFriNfc_Desfire_HProcReadData()
591 NdefMap->PrevOperation = 0; in phFriNfc_Desfire_HProcReadData()
602 NdefMap->ApduBuffIndex = 0; in phFriNfc_Desfire_HProcReadData()
605 phFriNfc_Desfire_HCrHandler(NdefMap,Result); in phFriNfc_Desfire_HProcReadData()
623 phFriNfc_NdefMap_t *NdefMap = (phFriNfc_NdefMap_t *)Context; in phFriNfc_Desfire_Process() local
633 switch (NdefMap->State) in phFriNfc_Desfire_Process()
643 Status = phFriNfc_Desfire_HGetSWVersion(NdefMap); in phFriNfc_Desfire_Process()
649 phFriNfc_Desfire_HCrHandler(NdefMap,Status); in phFriNfc_Desfire_Process()
659 Status = phFriNfc_Desfire_HUpdateVersionDetails(NdefMap); in phFriNfc_Desfire_Process()
662 Status = phFriNfc_Desfire_HGetUIDDetails(NdefMap); in phFriNfc_Desfire_Process()
667 phFriNfc_Desfire_HCrHandler(NdefMap,Status); in phFriNfc_Desfire_Process()
676 NdefMap->DespOpFlag = PH_FRINFC_NDEFMAP_DESF_NDEF_CHK_OP; in phFriNfc_Desfire_Process()
679 Status = phFriNfc_Desfire_SelectSmartTag(NdefMap); in phFriNfc_Desfire_Process()
687 if(( NdefMap->SendRecvBuf[(*(NdefMap->SendRecvLength) - 2)] == in phFriNfc_Desfire_Process()
689 (NdefMap->SendRecvBuf[(*(NdefMap->SendRecvLength) - 1)] == in phFriNfc_Desfire_Process()
692 NdefMap->CardType = PH_FRINFC_NDEFMAP_ISO14443_4A_CARD_EV1; in phFriNfc_Desfire_Process()
694 Status = phFriNfc_Desfire_SelectFile(NdefMap); in phFriNfc_Desfire_Process()
700 phFriNfc_Desfire_HCrHandler(NdefMap,Status); in phFriNfc_Desfire_Process()
705 NdefMap->CardType = PH_FRINFC_NDEFMAP_ISO14443_4A_CARD; in phFriNfc_Desfire_Process()
708 Status = phFriNfc_Desfire_SelectSmartTag(NdefMap); in phFriNfc_Desfire_Process()
718 if(( NdefMap->SendRecvBuf[(*(NdefMap->SendRecvLength) - 2)] == in phFriNfc_Desfire_Process()
720 (NdefMap->SendRecvBuf[(*(NdefMap->SendRecvLength) - 1)] == in phFriNfc_Desfire_Process()
723 if(( NdefMap->SendRecvBuf[PH_FRINFC_NDEFMAP_DESF_SW1_INDEX] == in phFriNfc_Desfire_Process()
725 (NdefMap->SendRecvBuf[PH_FRINFC_NDEFMAP_DESF_SW2_INDEX] == in phFriNfc_Desfire_Process()
729 Status = phFriNfc_Desfire_SelectFile(NdefMap); in phFriNfc_Desfire_Process()
735 phFriNfc_Desfire_HCrHandler(NdefMap,Status); in phFriNfc_Desfire_Process()
744 NdefMap->CardType = 0; in phFriNfc_Desfire_Process()
748 phFriNfc_Desfire_HCrHandler(NdefMap,Status); in phFriNfc_Desfire_Process()
756 …if(( NdefMap->SendRecvBuf[PH_FRINFC_NDEFMAP_DESF_SW1_INDEX] == PH_FRINFC_NDEFMAP_DESF_RAPDU_SW1_BY… in phFriNfc_Desfire_Process()
757 … (NdefMap->SendRecvBuf[PH_FRINFC_NDEFMAP_DESF_SW2_INDEX] == PH_FRINFC_NDEFMAP_DESF_RAPDU_SW2_BYTE)) in phFriNfc_Desfire_Process()
760 if( (NdefMap->DespOpFlag == PH_FRINFC_NDEFMAP_DESF_READ_OP) || in phFriNfc_Desfire_Process()
761 (NdefMap->DespOpFlag == PH_FRINFC_NDEFMAP_DESF_NDEF_CHK_OP) || in phFriNfc_Desfire_Process()
762 (NdefMap->DespOpFlag == PH_FRINFC_NDEFMAP_DESF_GET_LEN_OP )) in phFriNfc_Desfire_Process()
765 Status = phFriNfc_Desfire_ReadBinary(NdefMap); in phFriNfc_Desfire_Process()
771 phFriNfc_Desfire_HCrHandler(NdefMap,Status); in phFriNfc_Desfire_Process()
775 else if(NdefMap->DespOpFlag == PH_FRINFC_NDEFMAP_DESF_WRITE_OP ) in phFriNfc_Desfire_Process()
777 Status = phFriNfc_Desfire_UpdateBinary (NdefMap); in phFriNfc_Desfire_Process()
782 phFriNfc_Desfire_HCrHandler(NdefMap,Status); in phFriNfc_Desfire_Process()
792 phFriNfc_Desfire_HCrHandler(NdefMap,Status); in phFriNfc_Desfire_Process()
802 phFriNfc_Desfire_HCrHandler(NdefMap,Status); in phFriNfc_Desfire_Process()
807 …if( (NdefMap->SendRecvBuf[(*(NdefMap->SendRecvLength)-2)] == PH_FRINFC_NDEFMAP_DESF_RAPDU_SW1_BYTE… in phFriNfc_Desfire_Process()
808 … (NdefMap->SendRecvBuf[(*(NdefMap->SendRecvLength)-1)] == PH_FRINFC_NDEFMAP_DESF_RAPDU_SW2_BYTE)) in phFriNfc_Desfire_Process()
812 Status = phFriNfc_Desfire_Update_SmartTagCapContainer(NdefMap); in phFriNfc_Desfire_Process()
816 NdefMap->DespOpFlag = PH_FRINFC_NDEFMAP_DESF_GET_LEN_OP; in phFriNfc_Desfire_Process()
818 if (PH_FRINFC_NDEFMAP_ISO14443_4A_CARD_EV1 == NdefMap->CardType) in phFriNfc_Desfire_Process()
820 Status = phFriNfc_Desfire_SelectFile(NdefMap); in phFriNfc_Desfire_Process()
825 Status = phFriNfc_Desfire_HSetGet_NLEN(NdefMap); in phFriNfc_Desfire_Process()
831 phFriNfc_Desfire_HCrHandler(NdefMap,Status); in phFriNfc_Desfire_Process()
837 phFriNfc_Desfire_HCrHandler(NdefMap,Status); in phFriNfc_Desfire_Process()
848 phFriNfc_Desfire_HCrHandler(NdefMap,Status); in phFriNfc_Desfire_Process()
855 BytesRead = phFriNfc_Desfire_HGetLeBytes(NdefMap); in phFriNfc_Desfire_Process()
858 SendRecLen = *NdefMap->SendRecvLength - (PH_FRINFC_NDEFMAP_DESF_RESP_OFFSET ); in phFriNfc_Desfire_Process()
859 …if ( (NdefMap->DesfireCapContainer.SkipNlenBytesFlag == 1) && ((BytesRead == 1) || (BytesRead == … in phFriNfc_Desfire_Process()
871 … ((NdefMap->SendRecvBuf[(*NdefMap->SendRecvLength-2)] == PH_FRINFC_NDEFMAP_DESF_RAPDU_SW1_BYTE) && in phFriNfc_Desfire_Process()
872 … (NdefMap->SendRecvBuf[(*NdefMap->SendRecvLength-1)] == PH_FRINFC_NDEFMAP_DESF_RAPDU_SW2_BYTE))) in phFriNfc_Desfire_Process()
876 if ( NdefMap->DespOpFlag == PH_FRINFC_NDEFMAP_DESF_GET_LEN_OP ) in phFriNfc_Desfire_Process()
879 … NLength = ( (((uint16_t)NdefMap->SendRecvBuf[0])<<PH_FRINFC_NDEFMAP_DESF_SHL8)+ \ in phFriNfc_Desfire_Process()
880 NdefMap->SendRecvBuf[1]); in phFriNfc_Desfire_Process()
891 NdefMap->DesfireCapContainer.NdefDataLen = NLength; in phFriNfc_Desfire_Process()
893 Status = phFriNfc_MapTool_SetCardState( NdefMap, in phFriNfc_Desfire_Process()
899 NdefMap->CardType = PH_FRINFC_NDEFMAP_ISO14443_4A_CARD; in phFriNfc_Desfire_Process()
902 NdefMap->State = PH_FRINFC_NDEFMAP_DESF_STATE_CHK_NDEF; in phFriNfc_Desfire_Process()
905 *NdefMap->DataCount = 0; in phFriNfc_Desfire_Process()
907 NdefMap->ApduBuffIndex = 0; in phFriNfc_Desfire_Process()
909 NdefMap->DespOpFlag = PH_FRINFC_NDEFMAP_DESF_NDEF_CHK_OP; in phFriNfc_Desfire_Process()
913 phFriNfc_Desfire_HCrHandler(NdefMap,Status); in phFriNfc_Desfire_Process()
916 else if ( NdefMap->DespOpFlag == PH_FRINFC_NDEFMAP_DESF_READ_OP ) in phFriNfc_Desfire_Process()
918 phFriNfc_Desfire_HProcReadData(NdefMap); in phFriNfc_Desfire_Process()
925 phFriNfc_Desfire_HCrHandler(NdefMap,Status); in phFriNfc_Desfire_Process()
938 *NdefMap->DataCount = 0; in phFriNfc_Desfire_Process()
941 NdefMap->ApduBuffIndex = 0; in phFriNfc_Desfire_Process()
944 phFriNfc_Desfire_HCrHandler(NdefMap,Status); in phFriNfc_Desfire_Process()
950 …if( (NdefMap->SendRecvBuf[PH_FRINFC_NDEFMAP_DESF_SW1_INDEX] == PH_FRINFC_NDEFMAP_DESF_RAPDU_SW1_BY… in phFriNfc_Desfire_Process()
951 … (NdefMap->SendRecvBuf[PH_FRINFC_NDEFMAP_DESF_SW2_INDEX] == PH_FRINFC_NDEFMAP_DESF_RAPDU_SW2_BYTE)) in phFriNfc_Desfire_Process()
956 *NdefMap->DataCount = (uint16_t)(*NdefMap->DataCount + in phFriNfc_Desfire_Process()
957 NdefMap->NumOfBytesWritten); in phFriNfc_Desfire_Process()
958 NdefMap->ApduBuffIndex = (uint16_t)(NdefMap->ApduBuffIndex + in phFriNfc_Desfire_Process()
959 NdefMap->NumOfBytesWritten); in phFriNfc_Desfire_Process()
962 *NdefMap->WrNdefPacketLength += NdefMap->NumOfBytesWritten; in phFriNfc_Desfire_Process()
965 Status = phFriNfc_Desfire_UpdateBinary( NdefMap ); in phFriNfc_Desfire_Process()
974 NdefMap->ApduBuffIndex = 0; in phFriNfc_Desfire_Process()
977 phFriNfc_Desfire_HCrHandler(NdefMap,Status); in phFriNfc_Desfire_Process()
981 …if((NdefMap->SendRecvBuf[PH_FRINFC_NDEFMAP_DESF_SW1_INDEX] == PH_FRINFC_NDEFMAP_DESF_RAPDU_SW1_BYT… in phFriNfc_Desfire_Process()
982 … (NdefMap->SendRecvBuf[PH_FRINFC_NDEFMAP_DESF_SW2_INDEX] == PH_FRINFC_NDEFMAP_DESF_RAPDU_SW2_BYTE)) in phFriNfc_Desfire_Process()
991 NdefMap->CardState = (uint8_t)((NdefMap->CardState == in phFriNfc_Desfire_Process()
994 NdefMap->CardState); in phFriNfc_Desfire_Process()
996 NdefMap->DesfireCapContainer.NdefDataLen = (uint16_t)(*NdefMap->WrNdefPacketLength); in phFriNfc_Desfire_Process()
1000 NdefMap->PrevOperation = 0; in phFriNfc_Desfire_Process()
1006 NdefMap->PrevOperation = 0; in phFriNfc_Desfire_Process()
1013 NdefMap->ApduBuffIndex = 0; in phFriNfc_Desfire_Process()
1016 phFriNfc_Desfire_HCrHandler(NdefMap,Status); in phFriNfc_Desfire_Process()
1023 phFriNfc_Desfire_HCrHandler(NdefMap,Status); in phFriNfc_Desfire_Process()
1030 phFriNfc_Desfire_HCrHandler(NdefMap,Status); in phFriNfc_Desfire_Process()
1044 NFCSTATUS phFriNfc_Desfire_SelectSmartTag(phFriNfc_NdefMap_t *NdefMap) in phFriNfc_Desfire_SelectSmartTag() argument
1053 NdefMap->SendRecvBuf[0] = 0x00; /* cls */ in phFriNfc_Desfire_SelectSmartTag()
1054 NdefMap->SendRecvBuf[1] = 0xa4; /* ins */ in phFriNfc_Desfire_SelectSmartTag()
1055 NdefMap->SendRecvBuf[2] = 0x04; /* p1 */ in phFriNfc_Desfire_SelectSmartTag()
1056 NdefMap->SendRecvBuf[3] = 0x00; /* p2 */ in phFriNfc_Desfire_SelectSmartTag()
1057 NdefMap->SendRecvBuf[4] = 0x07; /* lc */ in phFriNfc_Desfire_SelectSmartTag()
1060 NdefMap->SendRecvBuf[5] = 0xd2; in phFriNfc_Desfire_SelectSmartTag()
1061 NdefMap->SendRecvBuf[6] = 0x76; in phFriNfc_Desfire_SelectSmartTag()
1062 NdefMap->SendRecvBuf[7] = 0x00; in phFriNfc_Desfire_SelectSmartTag()
1063 NdefMap->SendRecvBuf[8] = 0x00; in phFriNfc_Desfire_SelectSmartTag()
1064 NdefMap->SendRecvBuf[9] = 0x85; in phFriNfc_Desfire_SelectSmartTag()
1065 NdefMap->SendRecvBuf[10] = 0x01; in phFriNfc_Desfire_SelectSmartTag()
1069 switch (NdefMap->DespOpFlag) in phFriNfc_Desfire_SelectSmartTag()
1076 if (0 == NdefMap->CardType) in phFriNfc_Desfire_SelectSmartTag()
1080 NdefMap->SendRecvBuf[11] = 0x01; in phFriNfc_Desfire_SelectSmartTag()
1082 NdefMap->SendRecvBuf[12] = 0x00; in phFriNfc_Desfire_SelectSmartTag()
1083 NdefMap->State = PH_FRINFC_NDEFMAP_DESF_STATE_SELECT_SMART_TAG_EV1; in phFriNfc_Desfire_SelectSmartTag()
1088 NdefMap->SendRecvBuf[3] = 0x00; /* p2 */ in phFriNfc_Desfire_SelectSmartTag()
1089 NdefMap->SendRecvBuf[11] = 0x00; in phFriNfc_Desfire_SelectSmartTag()
1090 NdefMap->State = PH_FRINFC_NDEFMAP_DESF_STATE_SELECT_SMART_TAG; in phFriNfc_Desfire_SelectSmartTag()
1099 if (PH_FRINFC_NDEFMAP_ISO14443_4A_CARD_EV1 == NdefMap->CardType) in phFriNfc_Desfire_SelectSmartTag()
1101 NdefMap->SendRecvBuf[11] = 0x01; in phFriNfc_Desfire_SelectSmartTag()
1102 NdefMap->SendRecvBuf[12] = 0x00; in phFriNfc_Desfire_SelectSmartTag()
1103 NdefMap->State = (uint8_t)PH_FRINFC_NDEFMAP_DESF_STATE_SELECT_SMART_TAG_EV1; in phFriNfc_Desfire_SelectSmartTag()
1108 NdefMap->SendRecvBuf[11] = 0x00; in phFriNfc_Desfire_SelectSmartTag()
1109 NdefMap->State = (uint8_t)PH_FRINFC_NDEFMAP_DESF_STATE_SELECT_SMART_TAG; in phFriNfc_Desfire_SelectSmartTag()
1118 NdefMap->SendRecvBuf[11] = 0x00; in phFriNfc_Desfire_SelectSmartTag()
1123 NdefMap->SendLength = PH_FRINFC_NDEFMAP_DESF_CAPDU_SMARTTAG_PKT_SIZE; in phFriNfc_Desfire_SelectSmartTag()
1129 NdefMap->SendLength = (uint16_t)(NdefMap->SendLength + 1); in phFriNfc_Desfire_SelectSmartTag()
1134 NdefMap->State = PH_FRINFC_NDEFMAP_DESF_STATE_SELECT_SMART_TAG; in phFriNfc_Desfire_SelectSmartTag()
1137 status = phFriNfc_Desfire_HSendTransCmd(NdefMap,PH_FRINFC_NDEFMAP_DESF_RESP_OFFSET); in phFriNfc_Desfire_SelectSmartTag()
1151 NFCSTATUS phFriNfc_Desfire_SelectFile (phFriNfc_NdefMap_t *NdefMap) in phFriNfc_Desfire_SelectFile() argument
1157 if ((NdefMap->DespOpFlag != PH_FRINFC_NDEFMAP_DESF_NDEF_CHK_OP)&& \ in phFriNfc_Desfire_SelectFile()
1158 (NdefMap->DespOpFlag != PH_FRINFC_NDEFMAP_DESF_READ_OP)&&\ in phFriNfc_Desfire_SelectFile()
1159 ( NdefMap->DespOpFlag != PH_FRINFC_NDEFMAP_DESF_WRITE_OP) && in phFriNfc_Desfire_SelectFile()
1160 ( NdefMap->DespOpFlag != PH_FRINFC_NDEFMAP_DESF_GET_LEN_OP)) in phFriNfc_Desfire_SelectFile()
1172 NdefMap->SendRecvBuf[0] = 0x00; /* cls */ in phFriNfc_Desfire_SelectFile()
1173 NdefMap->SendRecvBuf[1] = 0xa4; /* ins */ in phFriNfc_Desfire_SelectFile()
1174 NdefMap->SendRecvBuf[2] = 0x00; /* p1 */ in phFriNfc_Desfire_SelectFile()
1175 NdefMap->SendRecvBuf[3] = 0x00; /* p2 */ in phFriNfc_Desfire_SelectFile()
1176 NdefMap->SendRecvBuf[4] = 0x02; /* lc */ in phFriNfc_Desfire_SelectFile()
1179 if (PH_FRINFC_NDEFMAP_ISO14443_4A_CARD_EV1 == NdefMap->CardType) in phFriNfc_Desfire_SelectFile()
1181 NdefMap->SendRecvBuf[3] = DESFIRE_EV1_P2_OFFSET_VALUE; /* p2 */ in phFriNfc_Desfire_SelectFile()
1185 if ( (NdefMap->DespOpFlag == PH_FRINFC_NDEFMAP_DESF_NDEF_CHK_OP)) in phFriNfc_Desfire_SelectFile()
1189 NdefMap->SendRecvBuf[5] = 0xe1; in phFriNfc_Desfire_SelectFile()
1190 NdefMap->SendRecvBuf[6] = 0x03; in phFriNfc_Desfire_SelectFile()
1195 …NdefMap->SendRecvBuf[5] = (uint8_t)((NdefMap->DesfireCapContainer.NdefMsgFid) >> PH_FRINFC_NDEFMAP… in phFriNfc_Desfire_SelectFile()
1196 … NdefMap->SendRecvBuf[6] = (uint8_t)((NdefMap->DesfireCapContainer.NdefMsgFid) & (0x00ff)); in phFriNfc_Desfire_SelectFile()
1199 NdefMap->SendLength = PH_FRINFC_NDEFMAP_DESF_CAPDU_SELECT_FILE_PKT_SIZE; in phFriNfc_Desfire_SelectFile()
1202 NdefMap->State = PH_FRINFC_NDEFMAP_DESF_STATE_SELECT_FILE; in phFriNfc_Desfire_SelectFile()
1204 status = phFriNfc_Desfire_HSendTransCmd(NdefMap,PH_FRINFC_NDEFMAP_DESF_RESP_OFFSET); in phFriNfc_Desfire_SelectFile()
1222 NFCSTATUS phFriNfc_Desfire_ReadBinary(phFriNfc_NdefMap_t *NdefMap) in phFriNfc_Desfire_ReadBinary() argument
1230 if (NdefMap->DespOpFlag == PH_FRINFC_NDEFMAP_DESF_NDEF_CHK_OP ) in phFriNfc_Desfire_ReadBinary()
1233 NdefMap->SendRecvBuf[0] = 0x00; in phFriNfc_Desfire_ReadBinary()
1234 NdefMap->SendRecvBuf[1] = 0xb0; in phFriNfc_Desfire_ReadBinary()
1235 NdefMap->SendRecvBuf[2] = 0x00; /* p1 */ in phFriNfc_Desfire_ReadBinary()
1236 NdefMap->SendRecvBuf[3] = 0x00; /* p2 */ in phFriNfc_Desfire_ReadBinary()
1237 NdefMap->SendRecvBuf[4] = 0x0F; /* le */ in phFriNfc_Desfire_ReadBinary()
1239 NdefMap->SendLength = PH_FRINFC_NDEFMAP_DESF_CAPDU_READ_BIN_PKT_SIZE; in phFriNfc_Desfire_ReadBinary()
1242 NdefMap->State = PH_FRINFC_NDEFMAP_DESF_STATE_READ_CAP_CONT; in phFriNfc_Desfire_ReadBinary()
1250 NdefMap->SendRecvBuf[0] = 0x00; in phFriNfc_Desfire_ReadBinary()
1251 NdefMap->SendRecvBuf[1] = 0xb0; in phFriNfc_Desfire_ReadBinary()
1254 if( *NdefMap->DataCount == 0 ) in phFriNfc_Desfire_ReadBinary()
1258 NdefMap->SendRecvBuf[2] = 0; in phFriNfc_Desfire_ReadBinary()
1259 NdefMap->SendRecvBuf[3] = 0; in phFriNfc_Desfire_ReadBinary()
1265 DataCnt = *NdefMap->DataCount; in phFriNfc_Desfire_ReadBinary()
1267 NdefMap->SendRecvBuf[2] = (uint8_t)((DataCnt)>> PH_FRINFC_NDEFMAP_DESF_SHL8); in phFriNfc_Desfire_ReadBinary()
1268 NdefMap->SendRecvBuf[3] = (uint8_t)((DataCnt)& (0x00ff)); in phFriNfc_Desfire_ReadBinary()
1271 BytesToRead = phFriNfc_Desfire_HGetLeBytes(NdefMap); in phFriNfc_Desfire_ReadBinary()
1273 if ( NdefMap->Offset == PH_FRINFC_NDEFMAP_SEEK_BEGIN ) in phFriNfc_Desfire_ReadBinary()
1278 BufIndex = (uint8_t)(( NdefMap->DesfireCapContainer.SkipNlenBytesFlag == 1 ) ? in phFriNfc_Desfire_ReadBinary()
1281 …if( ((BytesToRead == 1) || (BytesToRead == 2)) && (NdefMap->DesfireCapContainer.SkipNlenBytesFlag … in phFriNfc_Desfire_ReadBinary()
1289 NdefMap->SendRecvBuf[4]=(uint8_t) BytesToRead ; in phFriNfc_Desfire_ReadBinary()
1292 NdefMap->State = PH_FRINFC_NDEFMAP_DESF_STATE_READ_BIN; in phFriNfc_Desfire_ReadBinary()
1295 NdefMap->SendLength = PH_FRINFC_NDEFMAP_DESF_CAPDU_READ_BIN_PKT_SIZE; in phFriNfc_Desfire_ReadBinary()
1301 status = phFriNfc_Desfire_HSendTransCmd(NdefMap,PH_FRINFC_NDEFMAP_MAX_SEND_RECV_BUF_SIZE); in phFriNfc_Desfire_ReadBinary()
1305 …status = phFriNfc_Desfire_HSendTransCmd(NdefMap,(uint8_t)(BytesToRead +PH_FRINFC_NDEFMAP_DESF_RESP… in phFriNfc_Desfire_ReadBinary()
1321 NFCSTATUS phFriNfc_Desfire_UpdateBinary(phFriNfc_NdefMap_t *NdefMap) in phFriNfc_Desfire_UpdateBinary() argument
1329 if ( (*NdefMap->DataCount < PH_NFCFRI_NDEFMAP_DESF_NDEF_FILE_SIZE) && in phFriNfc_Desfire_UpdateBinary()
1330 (NdefMap->ApduBuffIndex < NdefMap->ApduBufferSize)) in phFriNfc_Desfire_UpdateBinary()
1335 if( (uint16_t)(NdefMap->ApduBufferSize - NdefMap->ApduBuffIndex) >\ in phFriNfc_Desfire_UpdateBinary()
1336 (uint16_t)(PH_NFCFRI_NDEFMAP_DESF_NDEF_FILE_SIZE - *NdefMap->DataCount)) in phFriNfc_Desfire_UpdateBinary()
1338 …NdefMap->ApduBufferSize =( (PH_NFCFRI_NDEFMAP_DESF_NDEF_FILE_SIZE) - (*NdefMap->DataCount + NdefMa… in phFriNfc_Desfire_UpdateBinary()
1343 NdefMap->SendRecvBuf[0] = 0x00; in phFriNfc_Desfire_UpdateBinary()
1344 NdefMap->SendRecvBuf[1] = 0xD6; in phFriNfc_Desfire_UpdateBinary()
1346 if( *NdefMap->DataCount == 0) in phFriNfc_Desfire_UpdateBinary()
1349 NdefMap->SendRecvBuf[2] = 0x00; /* p1 */ in phFriNfc_Desfire_UpdateBinary()
1350 NdefMap->SendRecvBuf[3] = 0x00; /* p2 */ in phFriNfc_Desfire_UpdateBinary()
1351 NdefMap->DesfireCapContainer.SkipNlenBytesFlag = 0; in phFriNfc_Desfire_UpdateBinary()
1361 DataCnt = *NdefMap->DataCount; in phFriNfc_Desfire_UpdateBinary()
1363 NdefMap->SendRecvBuf[2] = (uint8_t)((DataCnt)>> PH_FRINFC_NDEFMAP_DESF_SHL8); in phFriNfc_Desfire_UpdateBinary()
1364 NdefMap->SendRecvBuf[3] = (uint8_t)((DataCnt)& (0x00ff)); in phFriNfc_Desfire_UpdateBinary()
1367 NdefMap->DesfireCapContainer.SkipNlenBytesFlag = 1; in phFriNfc_Desfire_UpdateBinary()
1372 …if( (NdefMap->ApduBufferSize - NdefMap->ApduBuffIndex) >= (uint32_t)( NdefMap->DesfireCapContainer… in phFriNfc_Desfire_UpdateBinary()
1375 noOfBytesToWrite = ( ( NdefMap->DesfireCapContainer.SkipNlenBytesFlag == 1) ? in phFriNfc_Desfire_UpdateBinary()
1376 NdefMap->DesfireCapContainer.MaxCmdSize : in phFriNfc_Desfire_UpdateBinary()
1377 (NdefMap->DesfireCapContainer.MaxCmdSize - PH_FRINFC_NDEFMAP_DESF_NLEN_SIZE_IN_BYTES)); in phFriNfc_Desfire_UpdateBinary()
1382 noOfBytesToWrite = (uint16_t)(NdefMap->ApduBufferSize - NdefMap->ApduBuffIndex); in phFriNfc_Desfire_UpdateBinary()
1385 if ( NdefMap->Offset == PH_FRINFC_NDEFMAP_SEEK_BEGIN ) in phFriNfc_Desfire_UpdateBinary()
1387 if ( NdefMap->DesfireCapContainer.SkipNlenBytesFlag == 1 ) in phFriNfc_Desfire_UpdateBinary()
1391 NdefMap->SendRecvBuf[4] = (uint8_t)noOfBytesToWrite; in phFriNfc_Desfire_UpdateBinary()
1396 NdefMap->SendRecvBuf[5] = 0x00; in phFriNfc_Desfire_UpdateBinary()
1397 NdefMap->SendRecvBuf[6] = 0x00; in phFriNfc_Desfire_UpdateBinary()
1400 … NdefMap->SendRecvBuf[4] = (uint8_t)noOfBytesToWrite + PH_FRINFC_NDEFMAP_DESF_NLEN_SIZE_IN_BYTES; in phFriNfc_Desfire_UpdateBinary()
1404 (void)memcpy( &NdefMap->SendRecvBuf[index], in phFriNfc_Desfire_UpdateBinary()
1405 &NdefMap->ApduBuffer[NdefMap->ApduBuffIndex], in phFriNfc_Desfire_UpdateBinary()
1407 NdefMap->SendLength = (noOfBytesToWrite + index); in phFriNfc_Desfire_UpdateBinary()
1411 NdefMap->SendRecvBuf[4] = (uint8_t)noOfBytesToWrite; in phFriNfc_Desfire_UpdateBinary()
1414 (void)memcpy( &NdefMap->SendRecvBuf[5], in phFriNfc_Desfire_UpdateBinary()
1415 &NdefMap->ApduBuffer[NdefMap->ApduBuffIndex], in phFriNfc_Desfire_UpdateBinary()
1417 NdefMap->SendLength = (noOfBytesToWrite + 5); in phFriNfc_Desfire_UpdateBinary()
1422 NdefMap->NumOfBytesWritten = noOfBytesToWrite; in phFriNfc_Desfire_UpdateBinary()
1425 NdefMap->State = PH_FRINFC_NDEFMAP_DESF_STATE_UPDATE_BIN_BEGIN; in phFriNfc_Desfire_UpdateBinary()
1427 status = phFriNfc_Desfire_HSendTransCmd(NdefMap,PH_FRINFC_NDEFMAP_DESF_RESP_OFFSET); in phFriNfc_Desfire_UpdateBinary()
1432 if ( (*NdefMap->DataCount == PH_NFCFRI_NDEFMAP_DESF_NDEF_FILE_SIZE) || in phFriNfc_Desfire_UpdateBinary()
1433 (NdefMap->ApduBuffIndex == NdefMap->ApduBufferSize)) in phFriNfc_Desfire_UpdateBinary()
1442 NdefMap->DespOpFlag = PH_FRINFC_NDEFMAP_DESF_SET_LEN_OP; in phFriNfc_Desfire_UpdateBinary()
1444 status = phFriNfc_Desfire_HSetGet_NLEN(NdefMap); in phFriNfc_Desfire_UpdateBinary()
1460 NdefMap->ApduBuffIndex = 0; in phFriNfc_Desfire_UpdateBinary()
1461 NdefMap->PrevOperation = 0; in phFriNfc_Desfire_UpdateBinary()
1464 phFriNfc_Desfire_HCrHandler(NdefMap,status); in phFriNfc_Desfire_UpdateBinary()
1474 static void phFriNfc_Desfire_HChkNDEFFileAccessRights(phFriNfc_NdefMap_t *NdefMap) in phFriNfc_Desfire_HChkNDEFFileAccessRights() argument
1476 if ( (NdefMap->DesfireCapContainer.ReadAccess == 0x00) && in phFriNfc_Desfire_HChkNDEFFileAccessRights()
1477 (NdefMap->DesfireCapContainer.WriteAccess == 0x00 )) in phFriNfc_Desfire_HChkNDEFFileAccessRights()
1482 NdefMap->CardState = PH_NDEFMAP_CARD_STATE_READ_WRITE; in phFriNfc_Desfire_HChkNDEFFileAccessRights()
1485 else if((NdefMap->DesfireCapContainer.ReadAccess == 0x00) && in phFriNfc_Desfire_HChkNDEFFileAccessRights()
1486 (NdefMap->DesfireCapContainer.WriteAccess == 0xFF )) in phFriNfc_Desfire_HChkNDEFFileAccessRights()
1489 NdefMap->CardState = PH_NDEFMAP_CARD_STATE_READ_ONLY; in phFriNfc_Desfire_HChkNDEFFileAccessRights()
1494 NdefMap->CardState = PH_NDEFMAP_CARD_STATE_INVALID; in phFriNfc_Desfire_HChkNDEFFileAccessRights()
1510 NFCSTATUS phFriNfc_Desfire_Update_SmartTagCapContainer(phFriNfc_NdefMap_t *NdefMap) in phFriNfc_Desfire_Update_SmartTagCapContainer() argument
1520 …CapContSize = ( (((uint16_t)NdefMap->SendRecvBuf[PH_FRINFC_NDEFMAP_DESF_CCLEN_BYTE_FIRST_INDEX])<<… in phFriNfc_Desfire_Update_SmartTagCapContainer()
1521 NdefMap->SendRecvBuf[PH_FRINFC_NDEFMAP_DESF_CCLEN_BYTE_SECOND_INDEX]); in phFriNfc_Desfire_Update_SmartTagCapContainer()
1533 status = phFriNfc_MapTool_ChkSpcVer ( NdefMap, in phFriNfc_Desfire_Update_SmartTagCapContainer()
1548 ((((uint16_t)NdefMap->SendRecvBuf[PH_FRINFC_NDEFMAP_DESF_MLE_BYTE_FIRST_INDEX]) << 8)\ in phFriNfc_Desfire_Update_SmartTagCapContainer()
1549 + NdefMap->SendRecvBuf[PH_FRINFC_NDEFMAP_DESF_MLE_BYTE_SECOND_INDEX]); in phFriNfc_Desfire_Update_SmartTagCapContainer()
1550 NdefMap->DesfireCapContainer.MaxRespSize = in phFriNfc_Desfire_Update_SmartTagCapContainer()
1555 NdefMap->DesfireCapContainer.MaxRespSize = in phFriNfc_Desfire_Update_SmartTagCapContainer()
1556 ((((uint16_t)NdefMap->SendRecvBuf[PH_FRINFC_NDEFMAP_DESF_MLE_BYTE_FIRST_INDEX]) << 8)\ in phFriNfc_Desfire_Update_SmartTagCapContainer()
1557 +NdefMap->SendRecvBuf[PH_FRINFC_NDEFMAP_DESF_MLE_BYTE_SECOND_INDEX]); in phFriNfc_Desfire_Update_SmartTagCapContainer()
1564 ((((uint16_t)NdefMap->SendRecvBuf[PH_FRINFC_NDEFMAP_DESF_MLC_BYTE_FIRST_INDEX])<<8)\ in phFriNfc_Desfire_Update_SmartTagCapContainer()
1565 + NdefMap->SendRecvBuf[PH_FRINFC_NDEFMAP_DESF_MLC_BYTE_SECOND_INDEX]); in phFriNfc_Desfire_Update_SmartTagCapContainer()
1567 NdefMap->DesfireCapContainer.MaxCmdSize = in phFriNfc_Desfire_Update_SmartTagCapContainer()
1572 NdefMap->DesfireCapContainer.MaxCmdSize = in phFriNfc_Desfire_Update_SmartTagCapContainer()
1573 ((((uint16_t)NdefMap->SendRecvBuf[PH_FRINFC_NDEFMAP_DESF_MLC_BYTE_FIRST_INDEX])<<8)\ in phFriNfc_Desfire_Update_SmartTagCapContainer()
1574 +NdefMap->SendRecvBuf[PH_FRINFC_NDEFMAP_DESF_MLC_BYTE_SECOND_INDEX]); in phFriNfc_Desfire_Update_SmartTagCapContainer()
1578 if( (NdefMap->DesfireCapContainer.MaxRespSize < 0x0f) || in phFriNfc_Desfire_Update_SmartTagCapContainer()
1579 ( NdefMap->DesfireCapContainer.MaxCmdSize == 0x00)) in phFriNfc_Desfire_Update_SmartTagCapContainer()
1591 status = phFriNfc_Desf_HChkAndParseTLV(NdefMap,PH_FRINFC_NDEFMAP_DESF_TLV_INDEX); in phFriNfc_Desfire_Update_SmartTagCapContainer()
1592 …if ( (status == NFCSTATUS_SUCCESS) && (NdefMap->TLVFoundFlag == PH_FRINFC_NDEFMAP_DESF_NDEF_CNTRL_… in phFriNfc_Desfire_Update_SmartTagCapContainer()
1597 if ( (( NdefMap->SendRecvBuf[PH_FRINFC_NDEFMAP_DESF_TLV_LEN_INDEX]) > 0x00 ) && in phFriNfc_Desfire_Update_SmartTagCapContainer()
1598 (( NdefMap->SendRecvBuf[PH_FRINFC_NDEFMAP_DESF_TLV_LEN_INDEX]) <= 0xFE )&& in phFriNfc_Desfire_Update_SmartTagCapContainer()
1599 (( NdefMap->SendRecvBuf[PH_FRINFC_NDEFMAP_DESF_TLV_LEN_INDEX]) == 0x06 )) in phFriNfc_Desfire_Update_SmartTagCapContainer()
1603 …NdefMap->DesfireCapContainer.NdefMsgFid = ( (((uint16_t)NdefMap->SendRecvBuf[PH_FRINFC_NDEFMAP_DES… in phFriNfc_Desfire_Update_SmartTagCapContainer()
1604 … NdefMap->SendRecvBuf[PH_FRINFC_NDEFMAP_DESF_NDEF_FILEID_BYTE_SECOND_INDEX]); in phFriNfc_Desfire_Update_SmartTagCapContainer()
1609 if ( (NdefMap->DesfireCapContainer.NdefMsgFid == 0xFFFF) || in phFriNfc_Desfire_Update_SmartTagCapContainer()
1610 (NdefMap->DesfireCapContainer.NdefMsgFid == 0xE102) || in phFriNfc_Desfire_Update_SmartTagCapContainer()
1611 (NdefMap->DesfireCapContainer.NdefMsgFid == 0xE103) || in phFriNfc_Desfire_Update_SmartTagCapContainer()
1612 (NdefMap->DesfireCapContainer.NdefMsgFid == 0x3F00) || in phFriNfc_Desfire_Update_SmartTagCapContainer()
1613 (NdefMap->DesfireCapContainer.NdefMsgFid == 0x3FFF ) ) in phFriNfc_Desfire_Update_SmartTagCapContainer()
1621 NdefMap->DesfireCapContainer.NdefFileSize = in phFriNfc_Desfire_Update_SmartTagCapContainer()
1622 … ((((uint16_t)NdefMap->SendRecvBuf[PH_FRINFC_NDEFMAP_DESF_NDEF_FILESZ_BYTE_FIRST_INDEX])<<8) in phFriNfc_Desfire_Update_SmartTagCapContainer()
1623 … | (NdefMap->SendRecvBuf[PH_FRINFC_NDEFMAP_DESF_NDEF_FILESZ_BYTE_SECOND_INDEX] & 0x00ff)); in phFriNfc_Desfire_Update_SmartTagCapContainer()
1628 if ( ((NdefMap->DesfireCapContainer.NdefFileSize -2) <= 0x0004 ) || in phFriNfc_Desfire_Update_SmartTagCapContainer()
1629 ((NdefMap->DesfireCapContainer.NdefFileSize -2) == 0xFFFD ) ) in phFriNfc_Desfire_Update_SmartTagCapContainer()
1638 NdefMap->DesfireCapContainer.ReadAccess = NdefMap->\ in phFriNfc_Desfire_Update_SmartTagCapContainer()
1642 …NdefMap->DesfireCapContainer.WriteAccess = NdefMap->SendRecvBuf[PH_FRINFC_NDEFMAP_DESF_NDEF_FILEWR… in phFriNfc_Desfire_Update_SmartTagCapContainer()
1646 phFriNfc_Desfire_HChkNDEFFileAccessRights(NdefMap); in phFriNfc_Desfire_Update_SmartTagCapContainer()
1662 if ( NdefMap->TLVFoundFlag == PH_FRINFC_NDEFMAP_DESF_PROP_CNTRL_TLV ) in phFriNfc_Desfire_Update_SmartTagCapContainer()
1690 static uint32_t phFriNfc_Desfire_HGetLeBytes(phFriNfc_NdefMap_t *NdefMap) in phFriNfc_Desfire_HGetLeBytes() argument
1695 if ( NdefMap->DespOpFlag == PH_FRINFC_NDEFMAP_DESF_GET_LEN_OP ) in phFriNfc_Desfire_HGetLeBytes()
1698 NdefMap->DesfireCapContainer.SkipNlenBytesFlag =0; in phFriNfc_Desfire_HGetLeBytes()
1705 … if((NdefMap->ApduBufferSize - NdefMap->ApduBuffIndex) >= NdefMap->DesfireCapContainer.MaxRespSize) in phFriNfc_Desfire_HGetLeBytes()
1711 BytesToRead = (((NdefMap->DesfireCapContainer.NdefDataLen - *NdefMap->DataCount) >= in phFriNfc_Desfire_HGetLeBytes()
1712 NdefMap->DesfireCapContainer.MaxRespSize) ? in phFriNfc_Desfire_HGetLeBytes()
1713 NdefMap->DesfireCapContainer.MaxRespSize : in phFriNfc_Desfire_HGetLeBytes()
1714 (NdefMap->DesfireCapContainer.NdefDataLen - in phFriNfc_Desfire_HGetLeBytes()
1715 *NdefMap->DataCount)); in phFriNfc_Desfire_HGetLeBytes()
1720 BytesToRead = (uint16_t)(NdefMap->ApduBufferSize - NdefMap->ApduBuffIndex); in phFriNfc_Desfire_HGetLeBytes()
1721 … if(BytesToRead >= (uint16_t)(NdefMap->DesfireCapContainer.NdefDataLen - *NdefMap->DataCount)) in phFriNfc_Desfire_HGetLeBytes()
1723 BytesToRead = (NdefMap->DesfireCapContainer.NdefDataLen - *NdefMap->DataCount); in phFriNfc_Desfire_HGetLeBytes()
1727 NdefMap->DesfireCapContainer.SkipNlenBytesFlag = in phFriNfc_Desfire_HGetLeBytes()
1728 … (uint8_t)(((NdefMap->Offset == PH_FRINFC_NDEFMAP_SEEK_BEGIN )&&( *NdefMap->DataCount == 0 )) ? in phFriNfc_Desfire_HGetLeBytes()
1745 static void phFriNfc_Desfire_HCrHandler( phFriNfc_NdefMap_t *NdefMap, in phFriNfc_Desfire_HCrHandler() argument
1749 NdefMap->State = PH_FRINFC_NDEFMAP_STATE_RESET_INIT; in phFriNfc_Desfire_HCrHandler()
1751 switch(NdefMap->DespOpFlag) in phFriNfc_Desfire_HCrHandler()
1756 NdefMap->CompletionRoutine[PH_FRINFC_NDEFMAP_CR_CHK_NDEF].\ in phFriNfc_Desfire_HCrHandler()
1757 CompletionRoutine(NdefMap->CompletionRoutine->Context,\ in phFriNfc_Desfire_HCrHandler()
1763 NdefMap->CompletionRoutine[PH_FRINFC_NDEFMAP_CR_RD_NDEF].\ in phFriNfc_Desfire_HCrHandler()
1764 CompletionRoutine(NdefMap->CompletionRoutine->Context,\ in phFriNfc_Desfire_HCrHandler()
1770 NdefMap->CompletionRoutine[PH_FRINFC_NDEFMAP_CR_WR_NDEF].\ in phFriNfc_Desfire_HCrHandler()
1771 CompletionRoutine(NdefMap->CompletionRoutine->Context,\ in phFriNfc_Desfire_HCrHandler()
1777 NdefMap->CompletionRoutine[PH_FRINFC_NDEFMAP_CR_INVALID_OPE].\ in phFriNfc_Desfire_HCrHandler()
1778 CompletionRoutine(NdefMap->CompletionRoutine->Context,\ in phFriNfc_Desfire_HCrHandler()
1785 static NFCSTATUS phFriNfc_Desfire_HSendTransCmd(phFriNfc_NdefMap_t *NdefMap,uint8_t SendRecvLen) in phFriNfc_Desfire_HSendTransCmd() argument
1792 NdefMap->Cmd.Iso144434Cmd = phHal_eIso14443_4_CmdListTClCmd; in phFriNfc_Desfire_HSendTransCmd()
1794 NdefMap->Cmd.Iso144434Cmd = phHal_eIso14443_4_Raw; in phFriNfc_Desfire_HSendTransCmd()
1798 NdefMap->psDepAdditionalInfo.DepFlags.MetaChaining = 0; in phFriNfc_Desfire_HSendTransCmd()
1799 NdefMap->psDepAdditionalInfo.DepFlags.NADPresent = 0; in phFriNfc_Desfire_HSendTransCmd()
1802 NdefMap->MapCompletionInfo.CompletionRoutine = phFriNfc_Desfire_Process; in phFriNfc_Desfire_HSendTransCmd()
1803 NdefMap->MapCompletionInfo.Context = NdefMap; in phFriNfc_Desfire_HSendTransCmd()
1806 *NdefMap->SendRecvLength = ((uint16_t)(SendRecvLen)); in phFriNfc_Desfire_HSendTransCmd()
1810 status = phFriNfc_OvrHal_Transceive(NdefMap->LowerDevice, in phFriNfc_Desfire_HSendTransCmd()
1811 &NdefMap->MapCompletionInfo, in phFriNfc_Desfire_HSendTransCmd()
1812 NdefMap->psRemoteDevInfo, in phFriNfc_Desfire_HSendTransCmd()
1813 NdefMap->Cmd, in phFriNfc_Desfire_HSendTransCmd()
1814 &NdefMap->psDepAdditionalInfo, in phFriNfc_Desfire_HSendTransCmd()
1815 NdefMap->SendRecvBuf, in phFriNfc_Desfire_HSendTransCmd()
1816 NdefMap->SendLength, in phFriNfc_Desfire_HSendTransCmd()
1817 NdefMap->SendRecvBuf, in phFriNfc_Desfire_HSendTransCmd()
1818 NdefMap->SendRecvLength); in phFriNfc_Desfire_HSendTransCmd()