00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 #if !defined(_FEDM_NO_TAG_HANDLER_ISO14443)
00035
00036 #include "FedmIscTagHandler_ISO14443_4_MIFARE_Plus_SL3.h"
00037 #include "../FEDM_ISCReader.h"
00038 #include "../FEDM_ISOTabItem.h"
00039 #include "../FEDM_ISCReaderID.h"
00040 #include "../FEDM_ISC.h"
00041
00042
00043 #if _MSC_VER >= 1400
00044 #pragma warning(disable : 4996)
00045 #endif
00046
00047
00048
00049
00050
00051
00052
00053
00054 FedmIscTagHandler_ISO14443_4_MIFARE_Plus_SL3::FedmIscTagHandler_ISO14443_4_MIFARE_Plus_SL3(
00055 FEDM_ISCReader* pReader,
00056 FEDM_ISOTabItem* pTabItem )
00057 : FedmIscTagHandler_ISO14443_4_MIFARE_Plus(pReader, FedmIscTagHandler::TYPE_ISO14443_4_MIFARE_PLUS_SL3, pTabItem)
00058 {
00059 m_sTagName = "ISO 14443-4 Type A : MIFARE Plus in Security Level 3";
00060 }
00061
00062 FedmIscTagHandler_ISO14443_4_MIFARE_Plus_SL3::FedmIscTagHandler_ISO14443_4_MIFARE_Plus_SL3(
00063 FEDM_ISCReader* pReader,
00064 unsigned int uiTagHandlerType,
00065 FEDM_ISOTabItem* pTabItem )
00066 : FedmIscTagHandler_ISO14443_4_MIFARE_Plus(pReader, uiTagHandlerType, pTabItem)
00067 {
00068 m_sTagName = "ISO 14443-4 Type A : MIFARE Plus in Security Level 3";
00069 }
00070
00071 FedmIscTagHandler_ISO14443_4_MIFARE_Plus_SL3::~FedmIscTagHandler_ISO14443_4_MIFARE_Plus_SL3()
00072 {
00073 }
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097 int FedmIscTagHandler_ISO14443_4_MIFARE_Plus_SL3::ResetAuthentication()
00098 {
00099 int iErr = 0;
00100
00101 FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_CMD, (unsigned char)0x78));
00102 FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_MODE, (unsigned char)0x00));
00103
00104
00105 int iBack = m_pReader->SendProtocol(0xC2);
00106 if( iBack==0x00 )
00107 {
00108 m_ucErrorSource = 0;
00109 m_uiErrorCode = 0;
00110 }
00111 else if( iBack==0x97 )
00112 {
00113 FEDM_CHK1(iErr, m_pReader->GetData(FEDM_ISC_TMP_0xC2_ERROR_SOURCE, &m_ucErrorSource));
00114 FEDM_CHK1(iErr, m_pReader->GetData(FEDM_ISC_TMP_0xC2_ERROR_CODE, &m_uiErrorCode));
00115 }
00116
00117 return iBack;
00118 }
00119
00120
00121 int FedmIscTagHandler_ISO14443_4_MIFARE_Plus_SL3::Read_Encrypted(
00122 unsigned int uiBlockNo,
00123 unsigned char ucExt,
00124 unsigned char* pucResponseData )
00125 {
00126 return Read(0x30, uiBlockNo, ucExt, pucResponseData);
00127 }
00128
00129
00130 int FedmIscTagHandler_ISO14443_4_MIFARE_Plus_SL3::Read_EncryptedMaced(
00131 unsigned int uiBlockNo,
00132 unsigned char ucExt,
00133 unsigned char* pucResponseData )
00134 {
00135 return Read(0x31, uiBlockNo, ucExt, pucResponseData);
00136 }
00137
00138
00139 int FedmIscTagHandler_ISO14443_4_MIFARE_Plus_SL3::Read_Plain(
00140 unsigned int uiBlockNo,
00141 unsigned char ucExt,
00142 unsigned char* pucResponseData )
00143 {
00144 return Read(0x32, uiBlockNo, ucExt, pucResponseData);
00145 }
00146
00147
00148 int FedmIscTagHandler_ISO14443_4_MIFARE_Plus_SL3::Read_PlainMaced(
00149 unsigned int uiBlockNo,
00150 unsigned char ucExt,
00151 unsigned char* pucResponseData )
00152 {
00153 return Read(0x33, uiBlockNo, ucExt, pucResponseData);
00154 }
00155
00156
00157 int FedmIscTagHandler_ISO14443_4_MIFARE_Plus_SL3::Read_EncryptedUnmaced(
00158 unsigned int uiBlockNo,
00159 unsigned char ucExt,
00160 unsigned char* pucResponseData )
00161 {
00162 return Read(0x34, uiBlockNo, ucExt, pucResponseData);
00163 }
00164
00165
00166 int FedmIscTagHandler_ISO14443_4_MIFARE_Plus_SL3::Read_EncryptedUnmaced_RespondMaced(
00167 unsigned int uiBlockNo,
00168 unsigned char ucExt,
00169 unsigned char* pucResponseData )
00170 {
00171 return Read(0x35, uiBlockNo, ucExt, pucResponseData);
00172 }
00173
00174
00175 int FedmIscTagHandler_ISO14443_4_MIFARE_Plus_SL3::Read_PlainUnmaced(
00176 unsigned int uiBlockNo,
00177 unsigned char ucExt,
00178 unsigned char* pucResponseData )
00179 {
00180 return Read(0x36, uiBlockNo, ucExt, pucResponseData);
00181 }
00182
00183
00184 int FedmIscTagHandler_ISO14443_4_MIFARE_Plus_SL3::Read_PlainUnmaced_RespondMaced(
00185 unsigned int uiBlockNo,
00186 unsigned char ucExt,
00187 unsigned char* pucResponseData )
00188 {
00189 return Read(0x37, uiBlockNo, ucExt, pucResponseData);
00190 }
00191
00192
00193 int FedmIscTagHandler_ISO14443_4_MIFARE_Plus_SL3::Write_Encrypted(
00194 unsigned int uiBlockNo,
00195 unsigned char ucLength,
00196 unsigned char* pucRequestData )
00197 {
00198 return Write(0xA0, uiBlockNo, ucLength, pucRequestData);
00199 }
00200
00201
00202 int FedmIscTagHandler_ISO14443_4_MIFARE_Plus_SL3::Write_EncryptedMaced(
00203 unsigned int uiBlockNo,
00204 unsigned char ucLength,
00205 unsigned char* pucRequestData )
00206 {
00207 return Write(0xA1, uiBlockNo, ucLength, pucRequestData);
00208 }
00209
00210
00211 int FedmIscTagHandler_ISO14443_4_MIFARE_Plus_SL3::Write_Plain(
00212 unsigned int uiBlockNo,
00213 unsigned char ucLength,
00214 unsigned char* pucRequestData )
00215 {
00216 return Write(0xA2, uiBlockNo, ucLength, pucRequestData);
00217 }
00218
00219
00220 int FedmIscTagHandler_ISO14443_4_MIFARE_Plus_SL3::Write_PlainMaced(
00221 unsigned int uiBlockNo,
00222 unsigned char ucLength,
00223 unsigned char* pucRequestData )
00224 {
00225 return Write(0xA3, uiBlockNo, ucLength, pucRequestData);
00226 }
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245 int FedmIscTagHandler_ISO14443_4_MIFARE_Plus_SL3::Increment_Encrypted(
00246 unsigned int uiSourceBlockNo,
00247 unsigned int uiValue )
00248 {
00249 int iErr = 0;
00250
00251 FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_CMD, (unsigned char)0xB0));
00252 FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_MODE, (unsigned char)0x00));
00253 FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_SRC_BLOCK_NO, uiSourceBlockNo));
00254 FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_VALUE, uiValue));
00255
00256
00257 int iBack = m_pReader->SendProtocol(0xC2);
00258 if( iBack==0x00 )
00259 {
00260 m_ucErrorSource = 0;
00261 m_uiErrorCode = 0;
00262 }
00263 else if( iBack==0x97 )
00264 {
00265 FEDM_CHK1(iErr, m_pReader->GetData(FEDM_ISC_TMP_0xC2_ERROR_SOURCE, &m_ucErrorSource));
00266 FEDM_CHK1(iErr, m_pReader->GetData(FEDM_ISC_TMP_0xC2_ERROR_CODE, &m_uiErrorCode));
00267 }
00268
00269 return iBack;
00270 }
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289 int FedmIscTagHandler_ISO14443_4_MIFARE_Plus_SL3::Increment_EncryptedMaced(
00290 unsigned int uiSourceBlockNo,
00291 unsigned int uiValue )
00292 {
00293 int iErr = 0;
00294
00295 FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_CMD, (unsigned char)0xB1));
00296 FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_MODE, (unsigned char)0x00));
00297 FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_SRC_BLOCK_NO, uiSourceBlockNo));
00298 FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_VALUE, uiValue));
00299
00300
00301 int iBack = m_pReader->SendProtocol(0xC2);
00302 if( iBack==0x00 )
00303 {
00304 m_ucErrorSource = 0;
00305 m_uiErrorCode = 0;
00306 }
00307 else if( iBack==0x97 )
00308 {
00309 FEDM_CHK1(iErr, m_pReader->GetData(FEDM_ISC_TMP_0xC2_ERROR_SOURCE, &m_ucErrorSource));
00310 FEDM_CHK1(iErr, m_pReader->GetData(FEDM_ISC_TMP_0xC2_ERROR_CODE, &m_uiErrorCode));
00311 }
00312
00313 return iBack;
00314 }
00315
00316
00317
00318
00319
00320
00321
00322
00323
00324
00325
00326
00327
00328
00329
00330
00331
00332
00333 int FedmIscTagHandler_ISO14443_4_MIFARE_Plus_SL3::Decrement_Encrypted(
00334 unsigned int uiSourceBlockNo,
00335 unsigned int uiValue )
00336 {
00337 int iErr = 0;
00338
00339 FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_CMD, (unsigned char)0xB2));
00340 FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_MODE, (unsigned char)0x00));
00341 FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_SRC_BLOCK_NO, uiSourceBlockNo));
00342 FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_VALUE, uiValue));
00343
00344
00345 int iBack = m_pReader->SendProtocol(0xC2);
00346 if( iBack==0x00 )
00347 {
00348 m_ucErrorSource = 0;
00349 m_uiErrorCode = 0;
00350 }
00351 else if( iBack==0x97 )
00352 {
00353 FEDM_CHK1(iErr, m_pReader->GetData(FEDM_ISC_TMP_0xC2_ERROR_SOURCE, &m_ucErrorSource));
00354 FEDM_CHK1(iErr, m_pReader->GetData(FEDM_ISC_TMP_0xC2_ERROR_CODE, &m_uiErrorCode));
00355 }
00356
00357 return iBack;
00358 }
00359
00360
00361
00362
00363
00364
00365
00366
00367
00368
00369
00370
00371
00372
00373
00374
00375
00376
00377 int FedmIscTagHandler_ISO14443_4_MIFARE_Plus_SL3::Decrement_EncryptedMaced(
00378 unsigned int uiSourceBlockNo,
00379 unsigned int uiValue )
00380 {
00381 int iErr = 0;
00382
00383 FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_CMD, (unsigned char)0xB3));
00384 FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_MODE, (unsigned char)0x00));
00385 FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_SRC_BLOCK_NO, uiSourceBlockNo));
00386 FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_VALUE, uiValue));
00387
00388
00389 int iBack = m_pReader->SendProtocol(0xC2);
00390 if( iBack==0x00 )
00391 {
00392 m_ucErrorSource = 0;
00393 m_uiErrorCode = 0;
00394 }
00395 else if( iBack==0x97 )
00396 {
00397 FEDM_CHK1(iErr, m_pReader->GetData(FEDM_ISC_TMP_0xC2_ERROR_SOURCE, &m_ucErrorSource));
00398 FEDM_CHK1(iErr, m_pReader->GetData(FEDM_ISC_TMP_0xC2_ERROR_CODE, &m_uiErrorCode));
00399 }
00400
00401 return iBack;
00402 }
00403
00404
00405
00406
00407
00408
00409
00410
00411
00412
00413
00414
00415
00416
00417
00418
00419
00420 int FedmIscTagHandler_ISO14443_4_MIFARE_Plus_SL3::Transfer(
00421 unsigned int uiDestinationBlockNo )
00422 {
00423 int iErr = 0;
00424
00425 FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_CMD, (unsigned char)0xB4));
00426 FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_MODE, (unsigned char)0x00));
00427 FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_DST_BLOCK_NO, uiDestinationBlockNo));
00428
00429
00430 int iBack = m_pReader->SendProtocol(0xC2);
00431 if( iBack==0x00 )
00432 {
00433 m_ucErrorSource = 0;
00434 m_uiErrorCode = 0;
00435 }
00436 else if( iBack==0x97 )
00437 {
00438 FEDM_CHK1(iErr, m_pReader->GetData(FEDM_ISC_TMP_0xC2_ERROR_SOURCE, &m_ucErrorSource));
00439 FEDM_CHK1(iErr, m_pReader->GetData(FEDM_ISC_TMP_0xC2_ERROR_CODE, &m_uiErrorCode));
00440 }
00441
00442 return iBack;
00443 }
00444
00445
00446
00447
00448
00449
00450
00451
00452
00453
00454
00455
00456
00457
00458
00459
00460
00461 int FedmIscTagHandler_ISO14443_4_MIFARE_Plus_SL3::Transfer_Maced(
00462 unsigned int uiDestinationBlockNo )
00463 {
00464 int iErr = 0;
00465
00466 FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_CMD, (unsigned char)0xB5));
00467 FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_MODE, (unsigned char)0x00));
00468 FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_DST_BLOCK_NO, uiDestinationBlockNo));
00469
00470
00471 int iBack = m_pReader->SendProtocol(0xC2);
00472 if( iBack==0x00 )
00473 {
00474 m_ucErrorSource = 0;
00475 m_uiErrorCode = 0;
00476 }
00477 else if( iBack==0x97 )
00478 {
00479 FEDM_CHK1(iErr, m_pReader->GetData(FEDM_ISC_TMP_0xC2_ERROR_SOURCE, &m_ucErrorSource));
00480 FEDM_CHK1(iErr, m_pReader->GetData(FEDM_ISC_TMP_0xC2_ERROR_CODE, &m_uiErrorCode));
00481 }
00482
00483 return iBack;
00484 }
00485
00486
00487
00488
00489
00490
00491
00492
00493
00494
00495
00496
00497
00498
00499
00500
00501
00502
00503
00504 int FedmIscTagHandler_ISO14443_4_MIFARE_Plus_SL3::Increment_Transfer_Encrypted(
00505 unsigned int uiSourceBlockNo,
00506 unsigned int uiDestinationBlockNo,
00507 unsigned int uiValue )
00508 {
00509 int iErr = 0;
00510
00511 FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_CMD, (unsigned char)0xB6));
00512 FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_MODE, (unsigned char)0x00));
00513 FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_SRC_BLOCK_NO, uiSourceBlockNo));
00514 FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_DST_BLOCK_NO, uiDestinationBlockNo));
00515 FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_VALUE, uiValue));
00516
00517
00518 int iBack = m_pReader->SendProtocol(0xC2);
00519 if( iBack==0x00 )
00520 {
00521 m_ucErrorSource = 0;
00522 m_uiErrorCode = 0;
00523 }
00524 else if( iBack==0x97 )
00525 {
00526 FEDM_CHK1(iErr, m_pReader->GetData(FEDM_ISC_TMP_0xC2_ERROR_SOURCE, &m_ucErrorSource));
00527 FEDM_CHK1(iErr, m_pReader->GetData(FEDM_ISC_TMP_0xC2_ERROR_CODE, &m_uiErrorCode));
00528 }
00529
00530 return iBack;
00531 }
00532
00533
00534
00535
00536
00537
00538
00539
00540
00541
00542
00543
00544
00545
00546
00547
00548
00549
00550
00551 int FedmIscTagHandler_ISO14443_4_MIFARE_Plus_SL3::Increment_Transfer_EncryptedMaced(
00552 unsigned int uiSourceBlockNo,
00553 unsigned int uiDestinationBlockNo,
00554 unsigned int uiValue )
00555 {
00556 int iErr = 0;
00557
00558 FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_CMD, (unsigned char)0xB7));
00559 FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_MODE, (unsigned char)0x00));
00560 FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_SRC_BLOCK_NO, uiSourceBlockNo));
00561 FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_DST_BLOCK_NO, uiDestinationBlockNo));
00562 FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_VALUE, uiValue));
00563
00564
00565 int iBack = m_pReader->SendProtocol(0xC2);
00566 if( iBack==0x00 )
00567 {
00568 m_ucErrorSource = 0;
00569 m_uiErrorCode = 0;
00570 }
00571 else if( iBack==0x97 )
00572 {
00573 FEDM_CHK1(iErr, m_pReader->GetData(FEDM_ISC_TMP_0xC2_ERROR_SOURCE, &m_ucErrorSource));
00574 FEDM_CHK1(iErr, m_pReader->GetData(FEDM_ISC_TMP_0xC2_ERROR_CODE, &m_uiErrorCode));
00575 }
00576
00577 return iBack;
00578 }
00579
00580
00581
00582
00583
00584
00585
00586
00587
00588
00589
00590
00591
00592
00593
00594
00595
00596
00597
00598 int FedmIscTagHandler_ISO14443_4_MIFARE_Plus_SL3::Decrement_Transfer_Encrypted(
00599 unsigned int uiSourceBlockNo,
00600 unsigned int uiDestinationBlockNo,
00601 unsigned int uiValue )
00602 {
00603 int iErr = 0;
00604
00605 FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_CMD, (unsigned char)0xB8));
00606 FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_MODE, (unsigned char)0x00));
00607 FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_SRC_BLOCK_NO, uiSourceBlockNo));
00608 FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_DST_BLOCK_NO, uiDestinationBlockNo));
00609 FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_VALUE, uiValue));
00610
00611
00612 int iBack = m_pReader->SendProtocol(0xC2);
00613 if( iBack==0x00 )
00614 {
00615 m_ucErrorSource = 0;
00616 m_uiErrorCode = 0;
00617 }
00618 else if( iBack==0x97 )
00619 {
00620 FEDM_CHK1(iErr, m_pReader->GetData(FEDM_ISC_TMP_0xC2_ERROR_SOURCE, &m_ucErrorSource));
00621 FEDM_CHK1(iErr, m_pReader->GetData(FEDM_ISC_TMP_0xC2_ERROR_CODE, &m_uiErrorCode));
00622 }
00623
00624 return iBack;
00625 }
00626
00627
00628
00629
00630
00631
00632
00633
00634
00635
00636
00637
00638
00639
00640
00641
00642
00643
00644
00645 int FedmIscTagHandler_ISO14443_4_MIFARE_Plus_SL3::Decrement_Transfer_EncryptedMaced(
00646 unsigned int uiSourceBlockNo,
00647 unsigned int uiDestinationBlockNo,
00648 unsigned int uiValue )
00649 {
00650 int iErr = 0;
00651
00652 FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_CMD, (unsigned char)0xB9));
00653 FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_MODE, (unsigned char)0x00));
00654 FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_SRC_BLOCK_NO, uiSourceBlockNo));
00655 FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_DST_BLOCK_NO, uiDestinationBlockNo));
00656 FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_VALUE, uiValue));
00657
00658
00659 int iBack = m_pReader->SendProtocol(0xC2);
00660 if( iBack==0x00 )
00661 {
00662 m_ucErrorSource = 0;
00663 m_uiErrorCode = 0;
00664 }
00665 else if( iBack==0x97 )
00666 {
00667 FEDM_CHK1(iErr, m_pReader->GetData(FEDM_ISC_TMP_0xC2_ERROR_SOURCE, &m_ucErrorSource));
00668 FEDM_CHK1(iErr, m_pReader->GetData(FEDM_ISC_TMP_0xC2_ERROR_CODE, &m_uiErrorCode));
00669 }
00670
00671 return iBack;
00672 }
00673
00674
00675
00676
00677
00678
00679
00680
00681
00682
00683
00684
00685
00686
00687
00688
00689
00690 int FedmIscTagHandler_ISO14443_4_MIFARE_Plus_SL3::Restore(
00691 unsigned int uiSourceBlockNo )
00692 {
00693 int iErr = 0;
00694
00695 FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_CMD, (unsigned char)0xC2));
00696 FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_MODE, (unsigned char)0x00));
00697 FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_SRC_BLOCK_NO, uiSourceBlockNo));
00698
00699
00700 int iBack = m_pReader->SendProtocol(0xC2);
00701 if( iBack==0x00 )
00702 {
00703 m_ucErrorSource = 0;
00704 m_uiErrorCode = 0;
00705 }
00706 else if( iBack==0x97 )
00707 {
00708 FEDM_CHK1(iErr, m_pReader->GetData(FEDM_ISC_TMP_0xC2_ERROR_SOURCE, &m_ucErrorSource));
00709 FEDM_CHK1(iErr, m_pReader->GetData(FEDM_ISC_TMP_0xC2_ERROR_CODE, &m_uiErrorCode));
00710 }
00711
00712 return iBack;
00713 }
00714
00715
00716
00717
00718
00719
00720
00721
00722
00723
00724
00725
00726
00727
00728
00729
00730
00731 int FedmIscTagHandler_ISO14443_4_MIFARE_Plus_SL3::Restore_Maced(
00732 unsigned int uiSourceBlockNo )
00733 {
00734 int iErr = 0;
00735
00736 FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_CMD, (unsigned char)0xC3));
00737 FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_MODE, (unsigned char)0x00));
00738 FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_SRC_BLOCK_NO, uiSourceBlockNo));
00739
00740
00741 int iBack = m_pReader->SendProtocol(0xC2);
00742 if( iBack==0x00 )
00743 {
00744 m_ucErrorSource = 0;
00745 m_uiErrorCode = 0;
00746 }
00747 else if( iBack==0x97 )
00748 {
00749 FEDM_CHK1(iErr, m_pReader->GetData(FEDM_ISC_TMP_0xC2_ERROR_SOURCE, &m_ucErrorSource));
00750 FEDM_CHK1(iErr, m_pReader->GetData(FEDM_ISC_TMP_0xC2_ERROR_CODE, &m_uiErrorCode));
00751 }
00752
00753 return iBack;
00754 }
00755
00756
00757
00758
00759
00760
00761
00762
00763
00764
00765
00766
00767
00768
00769
00770
00771
00772
00773
00774
00775
00776
00777
00778
00779 int FedmIscTagHandler_ISO14443_4_MIFARE_Plus_SL3::Read(
00780 unsigned char ucCmdByte,
00781 unsigned int uiBlockNo,
00782 unsigned char ucExt,
00783 unsigned char* pucResponseData )
00784 {
00785 int iErr = 0;
00786 unsigned int uiBlockNoLsb = 0;
00787
00788 if(ucExt * 16 > FEDM_ISC_ISO_TABLE_RxDB_SIZE)
00789 return FEDM_ERROR_ARRAY_BOUNDARY;
00790
00791 FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_CMD, ucCmdByte));
00792 FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_MODE, (unsigned char)0x00));
00793 FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_BLOCK_NO, uiBlockNo));
00794 FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_EXT, ucExt));
00795
00796
00797 int iBack = m_pReader->SendProtocol(0xC2);
00798 if( iBack==0x00 )
00799 {
00800 uiBlockNoLsb = (uiBlockNo & 0x000000FF);
00801 memcpy(pucResponseData, &m_pTabItem->m_ucRxDB[uiBlockNoLsb * 16], ucExt * 16);
00802 m_ucErrorSource = 0;
00803 m_uiErrorCode = 0;
00804 }
00805 else if( iBack==0x97 )
00806 {
00807 FEDM_CHK1(iErr, m_pReader->GetData(FEDM_ISC_TMP_0xC2_ERROR_SOURCE, &m_ucErrorSource));
00808 FEDM_CHK1(iErr, m_pReader->GetData(FEDM_ISC_TMP_0xC2_ERROR_CODE, &m_uiErrorCode));
00809 }
00810
00811 return iBack;
00812 }
00813
00814
00815
00816
00817
00818
00819
00820
00821
00822
00823
00824
00825
00826
00827
00828
00829
00830
00831
00832 int FedmIscTagHandler_ISO14443_4_MIFARE_Plus_SL3::Write(
00833 unsigned char ucCmdByte,
00834 unsigned int uiBlockNo,
00835 unsigned char ucLength,
00836 unsigned char* pucRequestData )
00837 {
00838 int iErr = 0;
00839 unsigned int uiBlockNoLsb = 0;
00840
00841 if(ucLength * 16 > FEDM_ISC_ISO_TABLE_TxDB_SIZE)
00842 return FEDM_ERROR_ARRAY_BOUNDARY;
00843
00844 FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_CMD, ucCmdByte));
00845 FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_MODE, (unsigned char)0x00));
00846 FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_BLOCK_NO, uiBlockNo));
00847 FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_EXT, ucLength));
00848
00849 uiBlockNoLsb = (uiBlockNo & 0x000000FF);
00850
00851 memcpy(&m_pTabItem->m_ucTxDB[uiBlockNoLsb * 16], pucRequestData, ucLength * 16);
00852
00853
00854 int iBack = m_pReader->SendProtocol(0xC2);
00855 if( iBack==0x00 )
00856 {
00857 m_ucErrorSource = 0;
00858 m_uiErrorCode = 0;
00859 }
00860 else if( iBack==0x97 )
00861 {
00862 FEDM_CHK1(iErr, m_pReader->GetData(FEDM_ISC_TMP_0xC2_ERROR_SOURCE, &m_ucErrorSource));
00863 FEDM_CHK1(iErr, m_pReader->GetData(FEDM_ISC_TMP_0xC2_ERROR_CODE, &m_uiErrorCode));
00864 }
00865
00866 return iBack;
00867 }
00868
00869 #endif // #if !defined(_FEDM_NO_TAG_HANDLER_ISO14443)