FedmIscTagHandler_ISO14443_4.cpp
Go to the documentation of this file.
00001 /*-------------------------------------------------------
00002 |                                                       |
00003 |      FedmIscTagHandler_ISO14443_4.cpp                 |
00004 |                                                       |
00005 ---------------------------------------------------------
00006 
00007 Copyright © 2009-2011   FEIG ELECTRONIC GmbH, All Rights Reserved.
00008                                                 Lange Strasse 4
00009                                                 D-35781 Weilburg
00010                                                 Federal Republic of Germany
00011                                                 phone    : +49 6471 31090
00012                                                 fax      : +49 6471 310999
00013                                                 e-mail   : obid-support@feig.de
00014                                                 Internet : http://www.feig.de
00015                                         
00016 Author                  :       Markus Hultsch
00017 Begin                   :       01.04.2009
00018 
00019 Version                 :       03.03.02 / 29.04.2011 / M. Hultsch
00020 
00021 Operation Systems       :       independent
00022 
00023 Function                        :       class for OBID® classic-pro transponder ISO14443-4
00024 
00025 NOTE                            :       this class supports only selected or addressed mode in Host-Mode
00026 
00027 
00028 Trademarks:
00029 -----------
00030 OBID®, OBID i-scan® and OBID myAXXESS® are registered Trademarks of FEIG ELECTRONIC GmbH
00031 Other Trademarks: see FEDM.h
00032 */
00033 
00034 #if !defined(_FEDM_NO_TAG_HANDLER_ISO14443)
00035 
00036 #include "FedmIscTagHandler_ISO14443_4.h"
00037 #include "../FEDM_ISCReader.h"
00038 #include "../FEDM_ISOTabItem.h"
00039 #include "../FEDM_ISCReaderID.h"
00040 #include "../FEDM_ISC.h"
00041 
00042 //#ifdef _FEDM_WINDOWS
00043         #include "fetcl.h"
00044 //#endif
00045 
00046 
00047 #if _MSC_VER >= 1400
00048         #pragma warning(disable : 4996)
00049 #endif
00050 
00051 
00052 
00053 //####################################################################
00054 // class FedmIscTagHandler_ISO14443_4
00055 // >> supports only ISO Host Commands <<
00056 //####################################################################
00057 
00058 FedmIscTagHandler_ISO14443_4::FedmIscTagHandler_ISO14443_4(
00059         FEDM_ISCReader* pReader, 
00060         FEDM_ISOTabItem* pTabItem )
00061         : FedmIscTagHandler_ISO14443_3(pReader, FedmIscTagHandler::TYPE_ISO14443_4, pTabItem)
00062 {
00063         m_iFetclHnd = 0;
00064 
00065         m_cbFct = NULL;
00066         m_pAny  = NULL;
00067 
00068         if(m_pTabItem != NULL)
00069         {
00070                 if(m_pTabItem->m_ucTrType == FEDM_ISC_TR_TYPE_ISO14443A)
00071                         m_sTagName = "ISO 14443-4 Type A";
00072                 else if(m_pTabItem->m_ucTrType == FEDM_ISC_TR_TYPE_ISO14443B)
00073                         m_sTagName = "ISO 14443-4 Type B";
00074 
00075                 if(m_pReader != NULL)
00076                 {
00077                         // create default transponder without CID and without NAD
00078                         m_iFetclHnd = FETCL_NewTransponder(     m_pReader->GetReaderHnd(),
00079                                                                                                 m_pReader->GetBusAddress(),
00080                                                                                                 0,
00081                                                                                                 0,
00082                                                                                                 false,
00083                                                                                                 false );
00084                 }
00085         }
00086 
00087         Init();
00088 }
00089 
00090 FedmIscTagHandler_ISO14443_4::FedmIscTagHandler_ISO14443_4(
00091         FEDM_ISCReader* pReader, 
00092         unsigned int uiTagHandlerType,
00093         FEDM_ISOTabItem* pTabItem )
00094         : FedmIscTagHandler_ISO14443_3(pReader, uiTagHandlerType, pTabItem)
00095 {
00096         m_iFetclHnd = 0;
00097 
00098         m_cbFct = NULL;
00099         m_pAny  = NULL;
00100 
00101         if(m_pTabItem != NULL)
00102         {
00103                 if(m_pTabItem->m_ucTrType == FEDM_ISC_TR_TYPE_ISO14443A)
00104                         m_sTagName = "ISO 14443-4 Type A";
00105                 else if(m_pTabItem->m_ucTrType == FEDM_ISC_TR_TYPE_ISO14443B)
00106                         m_sTagName = "ISO 14443-4 Type B";
00107 
00108                 if(m_pReader != NULL)
00109                 {
00110                         // create default transponder without CID and without NAD
00111                         m_iFetclHnd = FETCL_NewTransponder(     m_pReader->GetReaderHnd(),
00112                                                                                                 m_pReader->GetBusAddress(),
00113                                                                                                 0,
00114                                                                                                 0,
00115                                                                                                 false,
00116                                                                                                 false );
00117                 }
00118         }
00119 
00120         Init();
00121 }
00122 
00123 FedmIscTagHandler_ISO14443_4::~FedmIscTagHandler_ISO14443_4()
00124 {
00125         if(m_iFetclHnd > 0)
00126                 FETCL_DeleteTransponder(m_iFetclHnd);
00127 }
00128 
00129 // set all data members to 0
00130 void FedmIscTagHandler_ISO14443_4::Init()
00131 {
00132         FedmIscTagHandler::Init();
00133 
00134         m_ucCID         = 0;
00135         m_ucNAD         = 0;
00136         m_bUseCID       = false;
00137         m_bUseNAD       = false;
00138 
00139         m_uiResponseLen = 0;
00140 
00141         m_ucISO14443ErrorCode = 0;
00142 }
00143 
00144 unsigned char FedmIscTagHandler_ISO14443_4::GetLastISOErrorCode()
00145 {
00146         return m_ucISO14443ErrorCode;
00147 }
00148 
00149 void FedmIscTagHandler_ISO14443_4::SetCID(unsigned char ucCID)
00150 {
00151         m_ucCID = ucCID;
00152 }
00153 
00154 int FedmIscTagHandler_ISO14443_4::EnableCID(bool bEnable)
00155 {
00156         m_bUseCID = bEnable;
00157 
00158         if(m_iFetclHnd > 0)
00159                 FETCL_DeleteTransponder(m_iFetclHnd);
00160 
00161         // create transponder with or without CID and with or without NAD
00162         m_iFetclHnd = FETCL_NewTransponder(     m_pReader->GetReaderHnd(),
00163                                                                                 m_pReader->GetBusAddress(),
00164                                                                                 m_ucCID,
00165                                                                                 m_ucNAD,
00166                                                                                 m_bUseCID,
00167                                                                                 m_bUseNAD );
00168 
00169         if(m_iFetclHnd < 0)
00170                 return m_iFetclHnd;
00171 
00172         return 0;
00173 }
00174 
00175 unsigned char FedmIscTagHandler_ISO14443_4::GetCID()
00176 {
00177         return m_ucCID;
00178 }
00179 
00180 bool FedmIscTagHandler_ISO14443_4::IsCIDEnabled()
00181 {
00182         return m_bUseCID;
00183 }
00184 
00185 
00186 void FedmIscTagHandler_ISO14443_4::SetNAD(unsigned char ucNAD)
00187 {
00188         m_ucNAD = ucNAD;
00189 }
00190 
00191 int FedmIscTagHandler_ISO14443_4::EnableNAD(bool bEnable)
00192 {
00193         m_bUseNAD = bEnable;
00194 
00195         if(m_iFetclHnd > 0)
00196                 FETCL_DeleteTransponder(m_iFetclHnd);
00197 
00198         // create transponder with or without CID and with or without NAD
00199         m_iFetclHnd = FETCL_NewTransponder(     m_pReader->GetReaderHnd(),
00200                                                                                 m_pReader->GetBusAddress(),
00201                                                                                 m_ucCID,
00202                                                                                 m_ucNAD,
00203                                                                                 m_bUseCID,
00204                                                                                 m_bUseNAD );
00205 
00206         if(m_iFetclHnd < 0)
00207                 return m_iFetclHnd;
00208 
00209         return 0;
00210 }
00211 
00212 unsigned char FedmIscTagHandler_ISO14443_4::GetNAD()
00213 {
00214         return m_ucNAD;
00215 }
00216 
00217 bool FedmIscTagHandler_ISO14443_4::IsNADEnabled()
00218 {
00219         return m_bUseNAD;
00220 }
00221 
00222 
00223 
00224 /***************************************************************************
00225   Begin                 :       31.03.2009 / M. Hultsch
00226 
00227   Version               :       03.01.00 / 11.05.2009 / M. Hultsch
00228 
00229   Function                      :       [0xB2][0x2B] Transponder Info
00230 
00231                                                 NOTE: only for selected tags
00232 
00233   Parameters            :       unsigned char ucFSCI            - [out]
00234                                                 unsigned char ucFWI                     - [out]
00235                                                 unsigned char ucDSI                     - [out]
00236                                                 unsigned char ucDRI                     - [out]
00237                                                 unsigned char ucNADSupport      - [out]
00238                                                 unsigned char ucCIDSupport      - [out]
00239 
00240   Return value          :       0                               - if tramsmission was successful
00241                                                 status byte (>1)- if the reader signals a problem
00242                                                 error code (<0) - if something goes wrong
00243 ***************************************************************************/
00244 int FedmIscTagHandler_ISO14443_4::GetTransponderInfo(
00245         unsigned char& ucFSCI,
00246         unsigned char& ucFWI,
00247         unsigned char& ucDSI,
00248         unsigned char& ucDRI,
00249         unsigned char& ucNADSupport,
00250         unsigned char& ucCIDSupport )
00251 {
00252         FEDM_TRACE(m_pReader->GetLogger(), FELOGMNG_DBG_FUNCTION_CALL | FELOGMNG_DBG_LF_COMM_TAG_HANDLER, __FUNCTION__);
00253 
00254         int iErr = 0;
00255 
00256         FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_B2_CMD, (unsigned char)0x2B));
00257         FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_B2_MODE, (unsigned char)FEDM_ISC_ISO_MODE_SEL));
00258 
00259         m_ucISO14443ErrorCode = 0;
00260 
00261         // ... and execute
00262         int iBack = m_pReader->SendProtocol(0xB2);
00263         if(iBack == 0)
00264         {
00265                 int iIdx = m_pReader->FindTableIndex(0, FEDM_ISC_ISO_TABLE, FEDM_ISC_DATA_IS_SELECTED, true);
00266                 if(iIdx < 0)
00267                 {
00268                         // exception for ISO 14443 Transponder, when Reader is configuered with Anticollision = off
00269                         if(  m_pReader->m_uiISOTableLength == 1 && (m_pReader->m_ISOTable[0]->m_ucTrType == FEDM_ISC_TR_TYPE_ISO14443A || m_pReader->m_ISOTable[0]->m_ucTrType == FEDM_ISC_TR_TYPE_ISO14443B) )
00270                                 iIdx = 0;
00271                         else
00272                                 return FEDM_ERROR_NO_TABLE_DATA;
00273                 }
00274 
00275                 FEDM_CHK1(iErr, m_pReader->GetTableData(iIdx, FEDM_ISC_ISO_TABLE, FEDM_ISC_DATA_FSCI, &ucFSCI));
00276                 FEDM_CHK1(iErr, m_pReader->GetTableData(iIdx, FEDM_ISC_ISO_TABLE, FEDM_ISC_DATA_FWI, &ucFWI));
00277                 FEDM_CHK1(iErr, m_pReader->GetTableData(iIdx, FEDM_ISC_ISO_TABLE, FEDM_ISC_DATA_DSI, &ucDSI));
00278                 FEDM_CHK1(iErr, m_pReader->GetTableData(iIdx, FEDM_ISC_ISO_TABLE, FEDM_ISC_DATA_DRI, &ucDRI));
00279                 FEDM_CHK1(iErr, m_pReader->GetTableData(iIdx, FEDM_ISC_ISO_TABLE, FEDM_ISC_DATA_NAD, &ucNADSupport));
00280                 FEDM_CHK1(iErr, m_pReader->GetTableData(iIdx, FEDM_ISC_ISO_TABLE, FEDM_ISC_DATA_CID, &ucCIDSupport));
00281         }
00282         else if(iBack == 0x96)
00283         {
00284                 // ISO 14443 Error
00285                 FEDM_CHK1(iErr, m_pReader->GetData(FEDM_ISC_TMP_B2_ISO_ERROR, &m_ucISO14443ErrorCode));
00286         }
00287 
00288         return iBack;
00289 }
00290 
00291 
00292 /***************************************************************************
00293   Begin                 :       31.03.2009 / M. Hultsch
00294 
00295   Version               :       03.03.02 / 28.04.2011 / M. Hultsch
00296 
00297   Function                      :       [0xB2][0xBE] T=CL APDU - synchronous call
00298 
00299                                                 NOTE: only for selected tags
00300 
00301   Parameters            :       unsigned char*  pucRequestData          - [in] buffer with APDU request
00302                                                 unsigned int    uiRequestLen            - [in] length of APDU (number of bytes)
00303                                                 unsigned char*  pucResponseData         - [out] for synchronous mode: buffer for APDU response
00304                                                 unsigned int    uiResponseBufferLen     - [in]  for synchronous mode: length of response buffer
00305                                                 unsigned int&   uiResponseLen           - [out] length of APDU response (number of bytes)
00306 
00307   Return value          :       0                               - if tramsmission was successful
00308                                                 status byte (>1)- if the reader signals a problem
00309                                                 error code (<0) - if something goes wrong
00310 ***************************************************************************/
00311 int FedmIscTagHandler_ISO14443_4::Apdu(
00312         unsigned char*  pucRequestData,
00313         unsigned int    uiRequestLen,
00314         unsigned char*  pucResponseData,
00315         unsigned int    uiResponseBufferLen,
00316         unsigned int&   uiResponseLen )
00317 {
00318         FEDM_TRACE(m_pReader->GetLogger(), FELOGMNG_DBG_FUNCTION_CALL | FELOGMNG_DBG_LF_COMM_TAG_HANDLER, __FUNCTION__ << " sync call");
00319 
00320         FEDM_CHK3(pucRequestData);
00321         FEDM_CHK3(pucResponseData);
00322 
00323         if(m_iFetclHnd < 0)
00324                 return m_iFetclHnd;
00325 
00326         int iBack = 0;
00327         int iErr = 0;
00328 
00329         m_ucISO14443ErrorCode = 0;
00330 
00331         // sychronous invoke
00332         iBack = FETCL_Apdu(m_iFetclHnd, pucRequestData, uiRequestLen, NULL);
00333         m_pReader->SetLastError(iBack);
00334         if(iBack != 0 && iBack != 0x96)
00335                 return iBack;
00336 
00337         int iResponseLen = FETCL_GetResponseData(m_iFetclHnd, pucResponseData, uiResponseBufferLen);
00338         if(iResponseLen < 0)
00339         {
00340                 m_pReader->SetLastError(iResponseLen);
00341                 return iResponseLen;
00342         }
00343         else if(iResponseLen == 0)
00344         {
00345                 m_pReader->SetLastError(FEDM_ERROR_NO_DATA);
00346                 return FEDM_ERROR_NO_DATA;
00347         }
00348 
00349         uiResponseLen = (unsigned int)iResponseLen;
00350 
00351         if(iBack == 0x96)
00352         {
00353                 // ISO 14443 Error
00354                 m_ucISO14443ErrorCode = pucResponseData[0];
00355                 FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_B2_ISO_ERROR, m_ucISO14443ErrorCode));
00356         }
00357 
00358         return iBack;
00359 }
00360 
00361 
00362 /***************************************************************************
00363   Begin                 :       31.03.2009 / M. Hultsch
00364 
00365   Version               :       03.03.02 / 28.04.2011 / M. Hultsch
00366 
00367   Function                      :       [0xB2][0xBE] T=CL APDU - asynchronous call
00368 
00369                                                 NOTE: only for selected tags
00370 
00371   Parameters            :       unsigned char*  pucRequestData          - [in] buffer with APDU request
00372                                                 unsigned int    uiRequestLen            - [in] length of APDU (number of bytes)
00373                                                 void* pAny                                                      - [in] pojnter to anything reflected with the first parameter of callback
00374                                                 void (*cbFct)(void*, int, int, int)     - [in] callback function
00375 
00376   Return value          :       0                               - if tramsmission was successful
00377                                                 status byte (>1)- if the reader signals a problem
00378                                                 error code (<0) - if something goes wrong
00379 ***************************************************************************/
00380 int FedmIscTagHandler_ISO14443_4::Apdu(
00381         unsigned char*  pucRequestData,
00382         unsigned int    uiRequestLen,
00383         void* pAny,
00384         void (*cbFct)(void*, int, int, int) )
00385 {
00386         FEDM_TRACE(m_pReader->GetLogger(), FELOGMNG_DBG_FUNCTION_CALL | FELOGMNG_DBG_LF_COMM_TAG_HANDLER, __FUNCTION__ << " async call");
00387 
00388         FEDM_CHK3(pucRequestData);
00389 
00390         if(m_iFetclHnd < 0)
00391                 return m_iFetclHnd;
00392 
00393         int iBack = 0;
00394         int iErr = 0;
00395         int iResponseLen = 0;
00396         unsigned char ucResponseData = 0;
00397         FETCL_EVENT_INIT Init;
00398 
00399         // asychronous invoke
00400         m_cbFct = cbFct;
00401         m_pAny  = pAny;
00402 
00403         Init.pAny       = this;
00404         Init.uiFlag = FETCL_CALLBACK2;
00405 #if defined(__BORLANDC__)
00406         Init.cbFct2     = (void(*)(void*,int,int,int))ApduCallback;
00407 #else
00408         Init.cbFct2     = ApduCallback;
00409 #endif
00410 
00411         m_ucISO14443ErrorCode = 0;
00412 
00413         iBack = FETCL_Apdu(m_iFetclHnd, pucRequestData, uiRequestLen, &Init);
00414         m_pReader->SetLastError(iBack);
00415         if(iBack == 0x96)
00416         {
00417                 iResponseLen = FETCL_GetResponseData(m_iFetclHnd, &ucResponseData, 1);
00418                 if(iResponseLen < 0)
00419                 {
00420                         m_pReader->SetLastError(iResponseLen);
00421                         return iResponseLen;
00422                 }
00423                 else if(iResponseLen == 0)
00424                 {
00425                         m_pReader->SetLastError(FEDM_ERROR_NO_DATA);
00426                         return FEDM_ERROR_NO_DATA;
00427                 }
00428 
00429                 // ISO 14443 Error
00430                 m_ucISO14443ErrorCode = ucResponseData;
00431                 FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_B2_ISO_ERROR, m_ucISO14443ErrorCode));
00432         }
00433 
00434         return iBack;
00435 }
00436 
00437 // [0xB2][0xBE] T=CL Ping
00438 int FedmIscTagHandler_ISO14443_4::Ping()
00439 {
00440         FEDM_TRACE(m_pReader->GetLogger(), FELOGMNG_DBG_FUNCTION_CALL | FELOGMNG_DBG_LF_COMM_TAG_HANDLER, __FUNCTION__);
00441 
00442         if(m_iFetclHnd < 0)
00443                 return m_iFetclHnd;
00444 
00445         int iBack = 0;
00446         int iErr = 0;
00447         int iResponseLen = 0;
00448         unsigned char ucResponseData = 0;
00449 
00450         m_ucISO14443ErrorCode = 0;
00451 
00452         iBack = FETCL_Ping(m_iFetclHnd);
00453         m_pReader->SetLastError(iBack);
00454         if(iBack == 0x96)
00455         {
00456                 iResponseLen = FETCL_GetResponseData(m_iFetclHnd, &ucResponseData, 1);
00457                 if(iResponseLen < 0)
00458                 {
00459                         m_pReader->SetLastError(iResponseLen);
00460                         return iResponseLen;
00461                 }
00462                 else if(iResponseLen == 0)
00463                 {
00464                         m_pReader->SetLastError(FEDM_ERROR_NO_DATA);
00465                         return FEDM_ERROR_NO_DATA;
00466                 }
00467 
00468                 // ISO 14443 Error
00469                 m_ucISO14443ErrorCode = ucResponseData;
00470                 FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_B2_ISO_ERROR, m_ucISO14443ErrorCode));
00471         }
00472 
00473         return iBack;
00474 }
00475 
00476 // [0xB2][0xBE] T=CL Deselect
00477 int FedmIscTagHandler_ISO14443_4::Deselect()
00478 {
00479         FEDM_TRACE(m_pReader->GetLogger(), FELOGMNG_DBG_FUNCTION_CALL | FELOGMNG_DBG_LF_COMM_TAG_HANDLER, __FUNCTION__);
00480 
00481         if(m_iFetclHnd < 0)
00482                 return m_iFetclHnd;
00483 
00484         int iBack = 0;
00485         int iErr = 0;
00486         int iResponseLen = 0;
00487         unsigned char ucResponseData = 0;
00488 
00489         m_ucISO14443ErrorCode = 0;
00490 
00491         iBack = FETCL_Deselect(m_iFetclHnd);
00492         m_pReader->SetLastError(iBack);
00493         if(iBack == 0x96)
00494         {
00495                 iResponseLen = FETCL_GetResponseData(m_iFetclHnd, &ucResponseData, 1);
00496                 if(iResponseLen < 0)
00497                 {
00498                         m_pReader->SetLastError(iResponseLen);
00499                         return iResponseLen;
00500                 }
00501                 else if(iResponseLen == 0)
00502                 {
00503                         m_pReader->SetLastError(FEDM_ERROR_NO_DATA);
00504                         return FEDM_ERROR_NO_DATA;
00505                 }
00506 
00507                 // ISO 14443 Error
00508                 m_ucISO14443ErrorCode = ucResponseData;
00509                 FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_B2_ISO_ERROR, m_ucISO14443ErrorCode));
00510         }
00511 
00512         return iBack;
00513 }
00514 
00515 
00516 /***************************************************************************
00517   Begin                 :       31.03.2009 / M. Hultsch
00518 
00519   Version               :       03.01.00 / 11.05.2009 / M. Hultsch
00520 
00521   Function                      :       query of APDU response after asynchronous call
00522 
00523   Parameters            :       unsigned char*  pucResponseData         - [out] for synchronous mode: buffer for APDU response
00524                                                 unsigned int    uiResponseBufferLen     - [in]  for synchronous mode: legth of response bufer
00525                                                 unsigned int&   uiResponseLen           - [out] length of APDU response (number of bytes)
00526 
00527   Return value          :       0                               - if OK
00528                                                 error code (<0) - if something goes wrong
00529 ***************************************************************************/
00530 int FedmIscTagHandler_ISO14443_4::GetResponseData(
00531         unsigned char*  pucResponseData,
00532         unsigned int    uiResponseBufferLen,
00533         unsigned int&   uiResponseLen )
00534 {
00535         FEDM_TRACE(m_pReader->GetLogger(), FELOGMNG_DBG_FUNCTION_CALL | FELOGMNG_DBG_LF_COMM_TAG_HANDLER, __FUNCTION__);
00536 
00537         FEDM_CHK3(pucResponseData);
00538 
00539         if(uiResponseBufferLen < m_uiResponseLen)
00540         {
00541                 m_pReader->SetLastError(FEDM_ERROR_BUFFER_LENGTH);
00542                 return FEDM_ERROR_BUFFER_LENGTH;
00543         }
00544 
00545         memcpy(pucResponseData, m_ucResponseData, m_uiResponseLen);
00546         uiResponseLen = m_uiResponseLen;
00547         return 0;
00548 }
00549 
00550 
00551 /***************************************************************************
00552   Begin                 :       31.03.2009 / M. Hultsch
00553 
00554   Version               :       03.03.02 / 29.04.2011 / M. Hultsch
00555 
00556   Function                      :       APDU callback for asynchronous call
00557 
00558   Parameters            :       void* pAny                      - [in] pojnter to this
00559                                                 int iApduHnd            - [in] handle of FETCL library
00560                                                 int iError                      - [in] error code
00561                                                 int iDataLength         - [in] length of APDU response
00562 
00563   Return value          :       -
00564 ***************************************************************************/
00565 void FedmIscTagHandler_ISO14443_4::ApduCallback(void* pAny, int iApduHnd, int iError, int iDataLength)
00566 {
00567         if(pAny == NULL)
00568                 return;
00569 
00570         FEDM_TRACE(((FedmIscTagHandler_ISO14443_4*)pAny)->m_pReader->GetLogger(), FELOGMNG_DBG_FUNCTION_CALL | FELOGMNG_DBG_LF_COMM_TAG_HANDLER, __FUNCTION__);
00571 
00572         if(iApduHnd != ((FedmIscTagHandler_ISO14443_4*)pAny)->m_iFetclHnd)
00573                 return;
00574 
00575         int iResponseLen = 0;
00576 
00577         ((FedmIscTagHandler_ISO14443_4*)pAny)->m_pReader->SetLastError(iError);
00578 
00579         if(iError < 0)
00580         {
00581                 ((FedmIscTagHandler_ISO14443_4*)pAny)->m_cbFct(((FedmIscTagHandler_ISO14443_4*)pAny)->m_pAny, iApduHnd, iError, iDataLength);
00582         }
00583         else if(iError == 0x96)
00584         {
00585                 iResponseLen = FETCL_GetResponseData(iApduHnd, ((FedmIscTagHandler_ISO14443_4*)pAny)->m_ucResponseData, FEDM_ISO14443_4_APDU_BUFFER_SIZE);
00586                 if(iResponseLen < 0)
00587                 {
00588                         ((FedmIscTagHandler_ISO14443_4*)pAny)->m_pReader->SetLastError(iResponseLen);
00589                         ((FedmIscTagHandler_ISO14443_4*)pAny)->m_cbFct(((FedmIscTagHandler_ISO14443_4*)pAny)->m_pAny, iApduHnd, iResponseLen, 0);
00590                 }
00591                 else if(iResponseLen == 0)
00592                 {
00593                         ((FedmIscTagHandler_ISO14443_4*)pAny)->m_pReader->SetLastError(FEDM_ERROR_NO_DATA);
00594                         ((FedmIscTagHandler_ISO14443_4*)pAny)->m_cbFct(((FedmIscTagHandler_ISO14443_4*)pAny)->m_pAny, iApduHnd, FEDM_ERROR_NO_DATA, 0);
00595                 }
00596                 else
00597                 {
00598                         // ISO 14443 Error
00599                         ((FedmIscTagHandler_ISO14443_4*)pAny)->m_ucISO14443ErrorCode = ((FedmIscTagHandler_ISO14443_4*)pAny)->m_ucResponseData[0];
00600                         ((FedmIscTagHandler_ISO14443_4*)pAny)->m_pReader->SetData(FEDM_ISC_TMP_B2_ISO_ERROR, ((FedmIscTagHandler_ISO14443_4*)pAny)->m_ucISO14443ErrorCode);
00601                         ((FedmIscTagHandler_ISO14443_4*)pAny)->m_cbFct(((FedmIscTagHandler_ISO14443_4*)pAny)->m_pAny, iApduHnd, iError, iDataLength);
00602                 }
00603         }
00604         else if(iError == 0)
00605         {
00606                 iResponseLen = FETCL_GetResponseData(iApduHnd, ((FedmIscTagHandler_ISO14443_4*)pAny)->m_ucResponseData, FEDM_ISO14443_4_APDU_BUFFER_SIZE);
00607                 if(iResponseLen < 0)
00608                 {
00609                         ((FedmIscTagHandler_ISO14443_4*)pAny)->m_cbFct(((FedmIscTagHandler_ISO14443_4*)pAny)->m_pAny, iApduHnd, iResponseLen, 0);
00610                 }
00611                 else if(iResponseLen == 0)
00612                 {
00613                         ((FedmIscTagHandler_ISO14443_4*)pAny)->m_cbFct(((FedmIscTagHandler_ISO14443_4*)pAny)->m_pAny, iApduHnd, FEDM_ERROR_NO_DATA, 0);
00614                 }
00615                 else
00616                 {
00617                         ((FedmIscTagHandler_ISO14443_4*)pAny)->m_cbFct(((FedmIscTagHandler_ISO14443_4*)pAny)->m_pAny, iApduHnd, iError, iDataLength);
00618                 }
00619         }
00620         else
00621         {
00622                 ((FedmIscTagHandler_ISO14443_4*)pAny)->m_cbFct(((FedmIscTagHandler_ISO14443_4*)pAny)->m_pAny, iApduHnd, iError, iDataLength);
00623         }
00624 }
00625 
00626 #endif // #if !defined(_FEDM_NO_TAG_HANDLER_ISO14443)


rfid_drivers
Author(s): Raul Perula-Martinez
autogenerated on Thu Apr 2 2015 03:06:14