|
@@ -1,186 +0,0 @@
|
|
|
-/////////////////////////////////////////////////////////////////////////////////
|
|
|
-/// Copyright (c) 2013 China Merchants Bank, all rights reserved ///
|
|
|
-/// Adapter Interface for Card Swiper. ///
|
|
|
-/// ///
|
|
|
-/// ///
|
|
|
-/////////////////////////////////////////////////////////////////////////////////
|
|
|
-#ifndef __CARD_SWIPER_CLASS_H
|
|
|
-#define __CARD_SWIPER_CLASS_H
|
|
|
-#include "DeviceBaseClass.h"
|
|
|
-#include "CardMix.h"
|
|
|
-
|
|
|
-
|
|
|
-//retain bin and issue hopper state
|
|
|
-struct CardSwiperStatus
|
|
|
-{
|
|
|
- CardStatusEnum eMedia; //state about card
|
|
|
- //RtBinStatusEnum eRetainBin;
|
|
|
- //DWORD dwRetainCount; //number of card retained
|
|
|
- //IssHopperStatusEnum eIssuerBin;
|
|
|
- //DWORD dwIssuerCount; //number of card issued
|
|
|
-};
|
|
|
-struct FWBStatus
|
|
|
-{
|
|
|
- DWORD BatteryCapacity; //capacity of battery(by hour) 暂未使用
|
|
|
- DWORD BatteryLeft; //0~100,剩余电量
|
|
|
-};
|
|
|
-
|
|
|
-class CardSwiperClass : public DeviceBaseClass
|
|
|
-{
|
|
|
-public:
|
|
|
- //
|
|
|
- // Connect to device and do initialization.
|
|
|
- // Make preparations for controlling the device.
|
|
|
- // Arguments:
|
|
|
- // - dwPort[in] com port number
|
|
|
- // - dwBaudRate[in] Baud rate
|
|
|
- //
|
|
|
- virtual ErrorCodeEnum DevOpen(DWORD dwPort,DWORD dwBaudRate) = 0;
|
|
|
- //
|
|
|
- // Get card issuer status
|
|
|
- //
|
|
|
- virtual ErrorCodeEnum GetDevStatus(CardSwiperStatus &devStatus) = 0;
|
|
|
- //
|
|
|
- // Abort current operation.
|
|
|
- //
|
|
|
- virtual ErrorCodeEnum AbortRead() = 0;
|
|
|
- //
|
|
|
- // Get card status:swiping card or inserted into ic slot or rf card in induction range
|
|
|
- //
|
|
|
- // dwPos: light position
|
|
|
- // CI_LIGHT_MAG = 0x1, //the magnetic stripe light flicker
|
|
|
- // CI_LIGHT_IC = 0x2, //the IC card light flicker
|
|
|
- // CI_LIGHT_CONTACTLESS = 0x4, //the contactless card light flicker
|
|
|
- // magnetic and IC light flicker :set dwPos = (CI_LIGHT_MAG | CI_LIGHT_IC)
|
|
|
- // all light flicker:set dwPos = (CI_LIGHT_MAG | CI_LIGHT_IC | CI_LIGHT_CONTACTLESS)
|
|
|
- //
|
|
|
- // iStatus:
|
|
|
- // <0 failed
|
|
|
- // 0:timeout,cannot find any card or cancel read
|
|
|
- // 1:magnetic card swiped
|
|
|
- // 2:contact card found.If has no magnetic,ATR should been put in magTracks[0].data,also set magTracks[0].size
|
|
|
- // 4:contactless card found.If has no magnetic,ATS should been put in magTracks[0].data,also set magTracks[0].size
|
|
|
- // 5: detect card in IC slot,but can't active it. the card may be don't have ic part
|
|
|
- // 6: detect ID Card
|
|
|
- // 7: magnetic card swiped,but!!!the checkcode is wrong!
|
|
|
- virtual ErrorCodeEnum QueryCardStatus(const DWORD dwPos,int &iStatus,MagTracks &magTracks) = 0;
|
|
|
- //
|
|
|
- // Read data from magnetic track(don't use for currently).
|
|
|
- //
|
|
|
- virtual ErrorCodeEnum MagRead(MagTracks &magTracks) = 0;
|
|
|
- //
|
|
|
- // Active contact IC card
|
|
|
- //
|
|
|
- virtual ErrorCodeEnum ActiveICCard() = 0;
|
|
|
- //
|
|
|
- // Active contactless IC 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) = 0;
|
|
|
- //
|
|
|
- // Move IC card to contact position
|
|
|
- //
|
|
|
- virtual ErrorCodeEnum ContactIC() = 0;
|
|
|
- //
|
|
|
- // Release IC contact
|
|
|
- //
|
|
|
- virtual ErrorCodeEnum ReleaseIC() = 0;
|
|
|
- //
|
|
|
- // Deactivate contact IC card
|
|
|
- //
|
|
|
- virtual ErrorCodeEnum DeactivateICCard() = 0;
|
|
|
- //
|
|
|
- // Deactivate contactless IC card
|
|
|
- //
|
|
|
- virtual ErrorCodeEnum DeactContactlessICCard() = 0;
|
|
|
- //
|
|
|
- // Warm reset card(IC)
|
|
|
- //
|
|
|
- virtual ErrorCodeEnum WarmReset() = 0;
|
|
|
- //
|
|
|
- // APDU:Application Protocol Data Unit
|
|
|
- // CmdSend.lpCmd:Command-APDU
|
|
|
- // CmdRecv.lpData:Response-APDU
|
|
|
- //
|
|
|
- virtual ErrorCodeEnum ICCommand(CmdInfo sendBuf,CmdInfo &recvBuf) = 0;
|
|
|
- //
|
|
|
- // Mifare operation
|
|
|
- // Arguments:
|
|
|
- // - eFunType:function type as load key,authentication and so on
|
|
|
- // - 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)]
|
|
|
-
|
|
|
- virtual ErrorCodeEnum MifareCommand(MifareFuctionEnum eFunType,CmdInfo sendBuf,CmdInfo &recvBuf) = 0;
|
|
|
- //
|
|
|
- // 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) = 0;
|
|
|
- //
|
|
|
- // Get key pair.
|
|
|
- // Generate a pair of key to encrypt data(using SM2).
|
|
|
- // priKey:private key; priSize:size of private key; pubKey:public key; pubSize:size of public key
|
|
|
- // priKey&pubKey both in ASCII style of HEX. 0x123456FFAB --> "123456FFAB"
|
|
|
- //
|
|
|
- virtual ErrorCodeEnum GetKeyPair(char *&priKey,int &priSize,char *&pubKey,int &pubSize) = 0;
|
|
|
- //
|
|
|
- // Load private key to machine.
|
|
|
- //
|
|
|
- virtual ErrorCodeEnum LoadPrivateKey(const char *pKey,const int size) = 0;
|
|
|
- //
|
|
|
- // Send random number to machine.
|
|
|
- // pRandomNum:random number(16 byte currently),in ASCII(32 byte of char)
|
|
|
- // pRamChk:first 16 byte of encrypted random number using SM3,in ASCII(32 byte of char)
|
|
|
- // pData:serial number(8 byte of char,ex:"14400001")
|
|
|
- //
|
|
|
- virtual ErrorCodeEnum SendRandomNum(const char *pRandomNum,const char *pRamChk,char *&pData) = 0;
|
|
|
- //
|
|
|
- // Save working key to memory.
|
|
|
- // pWorkingKey:working key value,in ASCII style of HEX: 0x123456FFAB --> "123456FFAB"
|
|
|
- virtual ErrorCodeEnum SendWorkingKey(const char *pWorkingKey) = 0;
|
|
|
- //
|
|
|
- // Get device serial number.
|
|
|
- // 设备唯一标识,且需贴在设备外壳上
|
|
|
- virtual ErrorCodeEnum GetDeviceSN(char *&pDevSN) = 0;
|
|
|
- // 返回值Error_Succeed表示成功,其他值表示失败
|
|
|
- // iStatus 0:成功 -1:银行公钥不存在 -2:产生设备密钥故障 -x:其他厂商自定义故障
|
|
|
- // Cr1:随机数r1的密文; Cr3:随机数r3的密文,dKey:用银行公钥加密的设备公钥密文
|
|
|
- // r1,r3第16字节为数据完整性校验字节,例如r1为B1B2...B15B16,则B16=B1^B2^...^B15
|
|
|
- virtual ErrorCodeEnum TransferEnInit(int &iStatus, BYTE *&Cr1, int &lenR1, BYTE *&Cr3, int &lenR3, BYTE *&dKey, int &lenKey) = 0;
|
|
|
-
|
|
|
- // 返回值Error_Succeed表示成功,其他值表示失败
|
|
|
- // iStatus 0:成功 -x:厂商自定义故障
|
|
|
- // r2第16字节为数据完整性校验字节,例如r2为B1B2...B15B16,则B16=B1^B2^...^B15
|
|
|
- virtual ErrorCodeEnum SetR2(int &iStatus, BYTE *pCr2, int lenR2) = 0;
|
|
|
- //
|
|
|
- // 查询设备是否掉线
|
|
|
- // bOn = 1表示设备在线,bOn = 0表示设备断开(掉线),返回Error_succeed
|
|
|
- virtual ErrorCodeEnum IfDevOnline(int &bOn) = 0;
|
|
|
- //
|
|
|
- // 移动卡片,吐卡ePos取值为CI_MOVECARD_FRONT_GATE
|
|
|
- //
|
|
|
- virtual ErrorCodeEnum EjectCard(CardPosEnum ePos){return Error_Succeed;}
|
|
|
- // 调用打开设备(蓝牙版)
|
|
|
- // 1. btOpenType:设定通过哪种方式连接设备,由DevOpenType的枚举值组合。usb及蓝牙设备连接可忽略dwPort,dwBaudRate
|
|
|
- // 2.通过pDevSN来指定连接对应设备号的蓝牙多合一
|
|
|
- // 例如通过蓝牙或者usb连接设备,则btOpenType = (DEV_OPEN_TYPE_USB|DEV_OPEN_TYPE_BLUETOOTH)
|
|
|
- // 3. btType返回设备实际通过哪种方式相连,返回值参考DevOpenType
|
|
|
- virtual ErrorCodeEnum DevOpenEx(DWORD dwPort, DWORD dwBaudRate, BYTE btOpenType,const char *pDevSN, BYTE &btType){return Error_NotImpl;}
|
|
|
- // 获取多合一剩余电量(蓝牙版)
|
|
|
- // --FWBStatus.BatteryLeft:剩余电量,取值为0~100
|
|
|
- virtual ErrorCodeEnum GetBatteryStatus(FWBStatus &status){return Error_NotImpl;}
|
|
|
-};
|
|
|
-
|
|
|
-#endif //__CARD_SWIPER_CLASS_H
|