| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- #ifndef LIBFRAMEWORK_CONTACTLESSCARD_IMPL_H
- #define LIBFRAMEWORK_CONTACTLESSCARD_IMPL_H
- #include "RFICClass.h"
- #include "PcscLibrary.h"
- #define PCSC_SUCCESS 0 // command succeeded
- #define PCSC_NOT_OPEN -1 // command succeeded
- #define PCSC_HARDWARE_ERROR -2 // command failed because of hardware error
- #define PCSC_TIMEOUT -3 // wait for user interaction timed out
- #define PCSC_PARA_ERR -4 //
- #define PCSC_NOT_CONN -5 //未连接卡片
- #define PCSC_NO_CARD -12 //
- #define FILE_VERSION 1
- class ContactlessCardImpl : public RFICClass
- {
- public:
- ContactlessCardImpl();
- ~ContactlessCardImpl();
- //DeviceBaseClass
- virtual ErrorCodeEnum DevOpen(DWORD dwPort,DWORD dwBaudRate);
- virtual ErrorCodeEnum GetDevCategory(DevCategoryInfo &devCategory);
- virtual ErrorCodeEnum Reset();
- virtual ErrorCodeEnum DevClose();
- virtual ErrorCodeEnum GetLastErr(DevErrorInfo &devErrInfo);
- //
- // Get card reader status
- //
- virtual ErrorCodeEnum GetDevStatus(RFICReaderStatus& devStatus);
- //
- // Abort current operation.
- //
- virtual ErrorCodeEnum AbortRead();
- //
- // Active contactless card(Type A,B,Mifare)
- // The first,second,third activation order decided by fstType,scdType,thdType respectively
- // fstType,scdType,thdType can be one of 'A','B','M','0'(30H,no type)
- // outType indicates the type of activation result
- //
- virtual ErrorCodeEnum ActiveContactlessICCard(char fstType, char scdType, char thdType, char& outType);
- //
- // Deactivate contactless IC card
- //
- virtual ErrorCodeEnum DeactContactlessICCard();
- //
- // Warm reset card(IC)
- //
- virtual ErrorCodeEnum WarmReset();
- //
- // Mifare operation
- // Arguments:
- // - eFunType:function type as load key,authentication and so on
- // - 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
- // - sendBuf:[parameter(hex)][data(hex)]
- // - recvBuf:[status(1byte)][return data(hex)]
- // -- [eFunType],[parameter,data],[status(1byte),return data]
- // -- [CI_MIFARE_LOAD_KEY],[key select(1byte),sector num(1byte),uncoded keys(6bytes)],[status(1byte)]
- // -- [CI_MIFARE_AUTH],[key select(1byte),sector num(1byte)],[status(1byte)]
- // -- [CI_MIFARE_READ],[block num(1byte)],[status(1byte),data(16bytes)]
- // -- [CI_MIFARE_WRITE],[block num(1byte),data(16bytes)],[status(1byte)]
- // -- [CI_MIFARE_INC],[source block num(1byte),destination block num(1byte),inc value(4bytes)],[status(1byte)]
- // -- [CI_MIFARE_DEC],[source block num(1byte),destination block num(1byte),dec value(4bytes)],[status(1byte)]
- // -- key select(1byte):AKey(00h),BKey(01h)
- // -- status(1byte):OK(00h),other error code(!00h)
- virtual ErrorCodeEnum MifareCommand(MifareFuctionEnum eFunType, CmdInfo sendBuf, CmdInfo& recvBuf);
- //
- // RF Type A,B command.
- // APDU:Application Protocol Data Unit
- // Arguments:
- // - CmdSend.lpCmd:Command-APDU
- // - CmdRecv.lpData:Response-APDU
- //
- virtual ErrorCodeEnum RFTypeABCommand(CmdInfo sendBuf, CmdInfo& recvBuf);
- //halt card
- //card have been halted must move from induction zone then can be found again
- virtual ErrorCodeEnum HaltCard();
- private:
- CPcscLibrary* m_pConnect;
- ErrorCodeEnum GetErrorInfo(int iCode, char* sErr, ...);
- DevErrorInfo m_DevErrInfo;
- char m_sLibPath[260];
- bool m_bCardConn;
- };
- #endif //LIBFRAMEWORK_CONTACTLESSCARD_IMPL_H
|