RFICClass.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /////////////////////////////////////////////////////////////////////////////////
  2. /// Copyright (c) 2012 China Merchants Bank, all rights reserved ///
  3. /// Adapter Interface for RF IC Card. ///
  4. /// ///
  5. /// ///
  6. /////////////////////////////////////////////////////////////////////////////////
  7. #ifndef __RFIC_CLASS_H
  8. #define __RFIC_CLASS_H
  9. #pragma once
  10. #include "DeviceBaseClass.h"
  11. #include "CardMix.h"
  12. /*const int RF_BLOCK_DATA_SIZE = 16;
  13. const int KEY_SIZE = 6;
  14. struct RFBlockData
  15. {
  16. DWORD dwSize;
  17. BYTE data[RF_BLOCK_DATA_SIZE];
  18. };
  19. enum KeyModeEnum
  20. {
  21. RF_KEYMODE_KEY_A_SET0, //KEY A,keyset0
  22. RF_KEYMODE_KEY_A_SET1, //KEY A,keyset1
  23. RF_KEYMODE_KEY_A_SET2, //KEY A,keyset2
  24. RF_KEYMODE_KEY_B_SET0, //KEY B,keyset0
  25. RF_KEYMODE_KEY_B_SET1, //KEY B,keyset1
  26. RF_KEYMODE_KEY_B_SET2, //KEY B,keyset2
  27. };
  28. struct KeyInfo
  29. {
  30. KeyModeEnum eMode;
  31. BYTE btSector; //sector number
  32. BYTE data[KEY_SIZE];
  33. };*/
  34. struct RFICReaderStatus
  35. {
  36. CardStatusEnum eMediaPos; //detect rf card or not:CI_MEDIA_NOTPRESENT,CI_MEDIA_RF
  37. };
  38. class RFICClass : public DeviceBaseClass
  39. {
  40. public:
  41. //device initialization
  42. virtual ErrorCodeEnum DevOpen(DWORD dwPort,DWORD dwBaudRate) = 0;
  43. //
  44. // Get card reader status
  45. //
  46. virtual ErrorCodeEnum GetDevStatus(RFICReaderStatus &devStatus) = 0;
  47. //
  48. // Abort current operation.
  49. //
  50. virtual ErrorCodeEnum AbortRead() = 0;
  51. //
  52. // Active contactless card(Type A,B,Mifare)
  53. // The first,second,third activation order decided by fstType,scdType,thdType respectively
  54. // fstType,scdType,thdType can be one of 'A','B','M','0'(30H,no type)
  55. // outType indicates the type of activation result
  56. //
  57. virtual ErrorCodeEnum ActiveContactlessICCard(char fstType,char scdType,char thdType,char &outType) = 0;
  58. //
  59. // Deactivate contactless IC card
  60. //
  61. virtual ErrorCodeEnum DeactContactlessICCard() = 0;
  62. //
  63. // Warm reset card(IC)
  64. //
  65. virtual ErrorCodeEnum WarmReset() = 0;
  66. //
  67. // Mifare operation
  68. // Arguments:
  69. // - eFunType:function type as load key,authentication and so on
  70. // - return/data(hex) byte order like BIG EDIAN. ex:0x12345678 --> data[i] = 0x12,data[i+1] = 0x34,data[i+2] = 0x56,data[i+3] = 0x78
  71. // - sendBuf:[parameter(hex)][data(hex)]
  72. // - recvBuf:[status(1byte)][return data(hex)]
  73. // -- [eFunType],[parameter,data],[status(1byte),return data]
  74. // -- [CI_MIFARE_LOAD_KEY],[key select(1byte),sector num(1byte),uncoded keys(6bytes)],[status(1byte)]
  75. // -- [CI_MIFARE_AUTH],[key select(1byte),sector num(1byte)],[status(1byte)]
  76. // -- [CI_MIFARE_READ],[block num(1byte)],[status(1byte),data(16bytes)]
  77. // -- [CI_MIFARE_WRITE],[block num(1byte),data(16bytes)],[status(1byte)]
  78. // -- [CI_MIFARE_INC],[source block num(1byte),destination block num(1byte),inc value(4bytes)],[status(1byte)]
  79. // -- [CI_MIFARE_DEC],[source block num(1byte),destination block num(1byte),dec value(4bytes)],[status(1byte)]
  80. // -- key select(1byte):AKey(00h),BKey(01h)
  81. // -- status(1byte):OK(00h),other error code(!00h)
  82. virtual ErrorCodeEnum MifareCommand(MifareFuctionEnum eFunType,CmdInfo sendBuf,CmdInfo &recvBuf) = 0;
  83. //
  84. // RF Type A,B command.
  85. // APDU:Application Protocol Data Unit
  86. // Arguments:
  87. // - CmdSend.lpCmd:Command-APDU
  88. // - CmdRecv.lpData:Response-APDU
  89. //
  90. virtual ErrorCodeEnum RFTypeABCommand(CmdInfo sendBuf,CmdInfo &recvBuf) = 0;
  91. //halt card
  92. //card have been halted must move from induction zone then can be found again
  93. virtual ErrorCodeEnum HaltCard() = 0;
  94. private:
  95. };
  96. #endif //__RFIC_CLASS_H