com.pax.dal
Interface IPicc
-
public interface IPicc
关于 POS PICC的API。 如果开启权限检查,需在AndroidManifest下添加权限:"com.pax.permission.PICC"API for POS PICC. If permission check is enabled, you need to add permission under AndroidManifest: "com.pax.permission.PICC".
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method and Description byte[]cardEmulateListen(byte mode, int recvMaxSize, int waitTimeMs)启动模拟对应类型的卡片,并监听是否有被读卡器成功寻卡。Start the simulation of the corresponding type of card and listen for the reader to find the card successfully.byte[]cardEmulateReceive(int recvMaxSize, int waitTimeMs)卡端接收指令。The card side receives instructions.voidcardEmulateSend(byte[] buffer)卡端发送指令给读卡器。需在被读卡器成功寻卡之后调用。The card side sends instructions to the card reader.To be called after the card reader has successfully found the card.voidcardEmulateSetListenPara(byte[] sensRes, byte[] nfcId1, byte[] sleRes, byte[] pollingResp)设置模拟卡片的参数。Set the parameters of the emulate card.voidchangeBaudRate(int bps)更改外置密码键盘通信波特率。Change the external PINPAD communication Baud rate.voidclose()关闭PICC模块,使该模块处于下电状态。Close PICC module, and make it in power off status.byte[]cmdExchange(byte[] dataIn, int recvLen)与卡片进行APDU数据交互,终端将paucInData中的数据直接发送给卡片,并接收卡片的应答数据。Processing APDU data interaction with card.PiccCardInfodetect(byte mode)按指定的模式搜寻PICC卡片;搜到卡片后,将其选中并激活。 感应区内不允许多卡存在Detect PICC card according to appointed mode; when find the card,choose and activate it.PiccCardInfodetect(byte mode, byte[] other)按指定的模式搜寻PICC卡片;搜到卡片后,将其选中并激活。 感应区内不允许多卡存在Detect PICC card according to appointed mode; when find the card,choose and activate it.PiccCardInfodetect(EDetectMode mode)按指定的模式搜寻PICC卡片;搜到卡片后,将其选中并激活。 感应区内不允许多卡存在Detect PICC card according to appointed mode; when find the card,choose and activate it.byte[]extendFunction(byte[] data)非接扩展功能,比如通过命令模拟 NFC URL TAG功能。Contactless extension functions, such as simulating the NFC URL TAG function through commands.voidinitFelica(byte rate, byte pol)初始化射频卡接口芯片为FeliCa调制编码方式。Initializing Radio Frequency Card interface chip as FeliCa modulate coding function.voidinitIso15693(byte codeMode)对ISO15693卡进行初始化配置 [目前仅支持X5]。Initialize the ISO15693 card (currently only X5 is supported).byte[]isoCommand(byte cid, byte[] send)在指定的通道上,向卡片发送APDU格式的数据,并接收响应。In specific channel, send data of APDU format to card and receive response.ApduRespInfoisoCommandByApdu(byte cid, ApduSendInfo apduSendInfo)IC卡操作函数。该函数支持IC卡通用接口协议(T=0及T=1)IC card operation function.voidm1Auth(EM1KeyType type, byte blkNo, byte[] pwd, byte[] serialNo)验证m1卡访问时读写相应块需要提交的A密码或B密码。Verify password A or B that should be submitted when reading/writing correspoding block of M1 card.voidm1Operate(EM1OperateType type, byte blkNo, byte[] blkValue, byte updateBlkNo)对M1卡钱包进行充值或减值操作,并最终更新主钱包或备用钱包。 对m1卡的指定数据块BlkNo进行充/减值/备份操作,将操作后的值更新到另一个指定的数据块UpdateBlkNo。byte[]m1Read(byte blkNo)读取m1卡指定块的内容(共16字节)Read content of block specified by M1 card (totally 16 bytes).voidm1Write(byte blkNo, byte[] blkValue)向m1卡指定块写入指定的内容(共16字节)Write specified content to specified block of M1 card (totally 16 bytes).voidopen()对非接触卡模块上电并复位,检查复位后模块初始状态是否正常Power on and reset contactless module, and check whether initial status of the module is normal.PiccParareadParam()voidremove(EPiccRemoveMode mode, byte cid)依据指定的模式,向卡片发送停机指令;或者发送停活指令;或者复位载波,并判断卡片是否已经移开感应区。Send stop command to card according to specific mode, or send halt command,or reset carrier, judge whether card is removed from inductive area in addition.voidresetCarrier()重置载波,快速复位。Reset the carrier and quickly reset.voidsetFelicaTimeout(int timeout)voidsetFelicaTimeOut(long timeOut)voidsetLed(byte led)led:亮灯控制led:Light ControlvoidsetParam(PiccPara para)设置非接读卡器参数open()函数调用之后,所有参数将恢复成默认值。Contactless Card Reader parameters setting.voidsetPort(EUartPort port)设置外置非接触卡模块的连接端口Set connection port of the external PICC
-
-
-
Method Detail
-
open
void open() throws PiccDevException
对非接触卡模块上电并复位,检查复位后模块初始状态是否正常Power on and reset contactless module, and check whether initial status of the module is normal.- Throws:
PiccDevException
-
readParam
PiccPara readParam() throws PiccDevException
- Returns:
PiccPara- Throws:
PiccDevException
-
setParam
void setParam(PiccPara para) throws PiccDevException
设置非接读卡器参数open()函数调用之后,所有参数将恢复成默认值。
Contactless Card Reader parameters setting.- All the parameter will return to default value when calling
open()function.
- Parameters:
para-PiccPara- Throws:
PiccDevException
-
setFelicaTimeOut
void setFelicaTimeOut(long timeOut) throws PiccDevException
- Parameters:
timeOut-以ETU为单位,1ETU= 9.44微秒,如 设置超时时间10000(*9.44微秒),大约为94.4msunit:ETU, 1ETU= 9.44μs,if the timeout time is 10000(*9.44 microseconds), it is about 94.4 milliseconds.- Throws:
PiccDevException
-
detect
PiccCardInfo detect(EDetectMode mode) throws PiccDevException
按指定的模式搜寻PICC卡片;搜到卡片后,将其选中并激活。 感应区内不允许多卡存在Detect PICC card according to appointed mode; when find the card,choose and activate it.- Parameters:
mode-EDetectMode- Returns:
PiccCardInfo- Throws:
PiccDevException
-
detect
PiccCardInfo detect(byte mode) throws PiccDevException
按指定的模式搜寻PICC卡片;搜到卡片后,将其选中并激活。 感应区内不允许多卡存在Detect PICC card according to appointed mode; when find the card,choose and activate it.- Parameters:
mode-- 0x00:搜寻A型卡和B型卡一次, 此模式适用于需要增强多卡检测功能的场合。 该模式是符合ISO14443规范的寻卡模式
- 0x01:搜寻A型卡和B型卡一次;此模式为EMV寻卡模式,通常使用该模式;
- 'a'或 'A':只搜寻A型卡一次;
- 'b'或'B':只搜寻B型卡一次;
- 'm'或'M':只搜寻M1卡一次;
- 'u'或'U':搜寻A型卡、B型卡和M卡一次;
- 0x10:VAS_OR_PAYMENT_MODE
- 0x11:VAS_AND_PAYMENT_MODE
- 0x12:VAS_MODE
- 0x13:PAYMENT_MODE
- 0x00:Detect type A card once, and detect type B card once; it is not permitted to find more than 1 card in inductive area (includeing type A and type B card).This mode is the PICC card detecting mode conforming the regulation of VISA WAVE, Master PayPass and China Union Pay.
- 0x01:Detect type A card once, and detect type B card once;This mode is the EMV detecting mode,usually use this mode.
- 'a'or'A':Only detect type A card once; it is not permitted to find more than 1 type A card in inductive area
- 'b'or'B':Only detect type B card once; it is not permitted to find more than 1 type B card in inductive area
- 'm'or'M':Only detect type M1 card once; it is not permitted to find more than 1 type M1 card in inductive area
- 'u' or 'U': Search for A-type card, B-type card and M card once
- 0x10:VAS_OR_PAYMENT_MODE
- 0x11:VAS_AND_PAYMENT_MODE
- 0x12:VAS_MODE
- 0x13:PAYMENT_MODE
- Returns:
PiccCardInfo- Throws:
PiccDevException- Since:
- V2.00.03
-
isoCommand
byte[] isoCommand(byte cid, byte[] send) throws PiccDevException
在指定的通道上,向卡片发送APDU格式的数据,并接收响应。In specific channel, send data of APDU format to card and receive response.- Parameters:
cid-用于指定卡片逻辑通道号;该通道号由 detect()的CID参数项输出,其取值范围为 0~14,目前取值均为0Used to appoint card logical channel number which is output by CID of detect(); Its range is 0~14 and its current value is 0.send-发送的IC卡命令数据(command, lc, dataIn, le)Data structure of command sent to IC card.(command, lc, dataIn, le)- Returns:
- 接收的IC命令数据(byte[] DataOut; byte SWA; byte SWB;)Data structure returned from IC card.(byte[] DataOut; byte SWA; byte SWB;)
- Throws:
PiccDevException
-
remove
void remove(EPiccRemoveMode mode, byte cid) throws PiccDevException
依据指定的模式,向卡片发送停机指令;或者发送停活指令;或者复位载波,并判断卡片是否已经移开感应区。Send stop command to card according to specific mode, or send halt command,or reset carrier, judge whether card is removed from inductive area in addition.- Parameters:
mode-EPiccRemoveMode- EMV - Comply with the remove card mode of EMV non-connected standard Reset carrier, and execute card removed detection.
cid-detect()调用中返回的卡片逻辑通道号,目前均为0Logical channel number returned from calling detect(), all 0 at present.- Throws:
PiccDevException
-
close
void close() throws PiccDevException
关闭PICC模块,使该模块处于下电状态。Close PICC module, and make it in power off status.- Throws:
PiccDevException
-
m1Auth
void m1Auth(EM1KeyType type, byte blkNo, byte[] pwd, byte[] serialNo) throws PiccDevException
验证m1卡访问时读写相应块需要提交的A密码或B密码。Verify password A or B that should be submitted when reading/writing correspoding block of M1 card.- Parameters:
type-EM1KeyType- TYPE_A
- TYPE_B
blkNo-用于指定访问的块号Used to specify visiting block number.pwd-指向提交的密码缓冲区Points to password buffer.serialNo-指向存放卡片序列号的缓冲区;存放 detect()调用返回的序列号信息SerialInfo 中的序列号部分,即SerialInfo+1Points to first address of buffer storing card serial number; should point to serial number part of SerialInfo returned after calling detect(), that is SerialInfo+1- Throws:
PiccDevException
-
m1Read
byte[] m1Read(byte blkNo) throws PiccDevException
读取m1卡指定块的内容(共16字节)Read content of block specified by M1 card (totally 16 bytes).- Parameters:
blkNo-用于指定访问的块号Used to appoint visiting block number.- Returns:
- 返回指定块的内容return the specified block content.
- Throws:
PiccDevException
-
m1Write
void m1Write(byte blkNo, byte[] blkValue) throws PiccDevException
向m1卡指定块写入指定的内容(共16字节)Write specified content to specified block of M1 card (totally 16 bytes).- Parameters:
blkNo-用于指定访问的块号Used to appoint visiting block number.blkValue-指向待存取块内容的缓冲区;该缓冲区至少应分 配16字节Points to first address of buffer waiting for storing block content; this buffer should be allocated at least 16 bytes.- Throws:
PiccDevException
-
m1Operate
void m1Operate(EM1OperateType type, byte blkNo, byte[] blkValue, byte updateBlkNo) throws PiccDevException
对M1卡钱包进行充值或减值操作,并最终更新主钱包或备用钱包。 对m1卡的指定数据块BlkNo进行充/减值/备份操作,将操作后的值更新到另一个指定的数据块UpdateBlkNo。说明:
- 若BlkNo与UpdateBlkNo块号相同时,若进行
EM1OperateType.DECREMENT或EM1OperateType.INCREMENT操作,则对该块号进行增值或减值 - 若BlkNo与UpdateBlkNo块号不同时,若进行
EM1OperateType.DECREMENT或EM1OperateType.INCREMENT操作,则BlkNo内存储的金额不变,UpdateBlkNo的金额等于BlkNo的金额进行相应的增值或减值 - 若进行
EM1OperateType.BACKUP操作,则Value不起作用,将BlkNo内的金额存储到UpdateNo中
此函数涉及的块号必须是数值块,同时BlkNo与UpdateBlkNo必须在同一个扇区中
Do increase or decrease or backup to the specified data block BlkNo , get the result,and updates the result to another specified data block UpdateBlkNo.introduction:
- If the block numbers of BlkNo and UpdateBlkNo are the same , use "INCREMENT" or"DECREMENT" to increase or decrease the value of block number.
- If the block numbers are different,when use "INCREMENT" or "DECREMENT" , the value stored in BlkNo will have no change, and the value of UpdateBlkNo block is equal to the corresponding increased or decreased value of BlkNo.
- If doing the "BACKUP" operation, the value is invalid,then store the value of BlkNo into UpdateNo.
The block numbers which refered in this function must be Chunk, BlkNo and UpdateBlkNo must be in the same sector.
- Parameters:
type-EM1OperateTypeblkNo-用于指定访问的块号Use to specify the visiting block number.blkValue-待充值或减值的金额数缓冲区;金额数共4 字节,低字节在前Points to the first address of amount buffer waiting for increasing or decreasing value; amount is 4 bytes, and lower bytes ahead.updateBlkNo-指定操作结果最终写入到的块号。M1卡通常都有两个钱包:主钱包和备用钱包。 为了在对主钱包进行操作时,可以从出现的异常错误中恢复, 主钱包的操作结果通常会写入备用钱包。Specifies the block number to which the operation result is ultimately written. M1 cards usually have two wallets: the main wallet and the spare wallet. In order to recover from exceptional errors when operating the main wallet, the operation results of the main wallet are usually written to the standby wallet.- Throws:
PiccDevException
- 若BlkNo与UpdateBlkNo块号相同时,若进行
-
initFelica
void initFelica(byte rate, byte pol) throws PiccDevException
初始化射频卡接口芯片为FeliCa调制编码方式。Initializing Radio Frequency Card interface chip as FeliCa modulate coding function.- Parameters:
rate-设置与卡片交互的传输速率。- 0-212Kbps
- 1-424Kbps
Setting transmission speed with card.- 0-212Kbps
- 1-424Kbps
pol-设置FeliCa调制方式- 0-为正向调制输出
- 1-为反向调制输出
Setting FeliCa modulate function.- 0 -forward modulate output.
- 1 -reverse modulate output.
- Throws:
PiccDevException
-
setLed
void setLed(byte led) throws PiccDevException
led:亮灯控制led:Light Control- Parameters:
led-- 标志位为0表示灯灭
- 标志位为1表示灯亮
- 0x01 – 红灯标志位
- 0x02 – 绿灯标志位
- 0x04 – 黄灯标志位
- 0x08 – 蓝灯标志位
- 0x0f – 全亮
- 0x00 – 全灭
- 0x01 - Red Light
- 0x02 - Green Light
- 0x04 - Yellow Light
- 0x08 - Blue Light
- 0x0f - All on
- 0x00 - All off
- Throws:
PiccDevException
-
isoCommandByApdu
ApduRespInfo isoCommandByApdu(byte cid, ApduSendInfo apduSendInfo) throws PiccDevException
IC卡操作函数。该函数支持IC卡通用接口协议(T=0及T=1)IC card operation function. This function supports IC card universal interface protocol (T=0 and T=1).- Parameters:
cid-用于指定卡片逻辑通道号;该通道号由 detect()的CID参数项输出,其取值范围为 0~14,目前取值均为0Used to appoint card logical channel number which is output by CID of detect(); Its range is 0~14 and its current value is 0.apduSendInfo-ApduSendInfo- command -CLA, INS, P1, P2.
- dataIn -发送给ICC的数据
- lc -发送的数据的长度
- le -期望接收到的数据长度
Note: set apduSendInfo.le value to 256 to make LE 0 in the command(i.e. expect response data as much as possible) ; setting apduSendInfo.le value to 0 means no response data expected.- dataOut -Returned data pointer from PICC.
- lenOut -The actual returned data length.
- swA -PICC status 1.
- swB -PICC status 2.
- Returns:
ApduRespInfo- Throws:
PiccDevException
-
cmdExchange
byte[] cmdExchange(byte[] dataIn, int recvLen) throws PiccDevException
与卡片进行APDU数据交互,终端将paucInData中的数据直接发送给卡片,并接收卡片的应答数据。Processing APDU data interaction with card. Sending data of paucInData to the card directly,and receive the returned data.- Parameters:
dataIn-待发送的命令数据Command data which are waiting to sent.recvLen-该参数作废,可传任意值This parameter is invalid and can be passed to any value.- Returns:
- 接收到的卡片数据paucOutData Data of received card.
- Throws:
PiccDevException- Since:
- V2.00.01
-
setPort
void setPort(EUartPort port)
设置外置非接触卡模块的连接端口Set connection port of the external PICC- Parameters:
port-EUartPort- Since:
- V3.02.00
-
setFelicaTimeout
void setFelicaTimeout(int timeout) throws PiccDevException
- Parameters:
timeout-超时时间。单位:毫秒。Timeout. unit:milliseconds.- Throws:
PiccDevException
-
detect
PiccCardInfo detect(byte mode, byte[] other) throws PiccDevException
按指定的模式搜寻PICC卡片;搜到卡片后,将其选中并激活。 感应区内不允许多卡存在Detect PICC card according to appointed mode; when find the card,choose and activate it.- Parameters:
mode-- 0x00:搜寻A型卡和B型卡一次, 此模式适用于需要增强多卡检测功能的场合。 该模式是符合ISO14443规范的寻卡模式
- 0x01:搜寻A型卡和B型卡一次;此模式为EMV寻卡模式,通常使用该模式;
- 'a'或 'A':只搜寻A型卡一次;
- 'b'或'B':只搜寻B型卡一次;
- 'm'或'M':只搜寻M1卡一次;
- 0x10:VAS_OR_PAYMENT_MODE
- 0x11:VAS_AND_PAYMENT_MODE
- 0x12:VAS_MODE
- 0x13:PAYMENT_MODE
- 'v'或'V':支持Apple ECP2.0。
- 0x00:Detect type A card once, and detect type B card once; it is not permitted to find more than 1 card in inductive area (includeing type A and type B card).This mode is the PICC card detecting mode conforming the regulation of VISA WAVE, Master PayPass and China Union Pay.
- 0x01:Detect type A card once, and detect type B card once;This mode is the EMV detecting mode,usually use this mode.
- 'a'or'A':Only detect type A card once; it is not permitted to find more than 1 type A card in inductive area
- 'b'or'B':Only detect type B card once; it is not permitted to find more than 1 type B card in inductive area
- 'm'or'M':Only detect type M1 card once; it is not permitted to find more than 1 type M1 card in inductive area
- 0x10:VAS_OR_PAYMENT_MODE
- 0x11:VAS_AND_PAYMENT_MODE
- 0x12:VAS_MODE
- 0x13:PAYMENT_MODE
- 'v'or'V':Support Apple ECP2.0
other-- 当mode是'v'或'V'模式时,other参数可做为输入发送的命令。
- 首字节为0x01时,输入固定四字节长度。
- 首字节为0x02时,输入变长字节,第二字节的低半字节X表示Terminal Data长度:"\x02\x8X\x00\x00"+X字节Terminal Data。
- 当mode是其它值时,other可直接为NULL,此时同
detect(byte)。
- When mode is 'v' or 'v' mode, the other parameter can be sent as input.
- When the first byte is 0x01, input a fixed four-byte length.
- When the first byte is 0x02, input variable length byte, and the low half byte X of the second byte represents Terminal Data length: "\x02\x8X\x00\x00"+X byte Terminal Data.
- When mode is something else, other can be NULL, which is the same as
detect(byte).
- 当mode是'v'或'V'模式时,other参数可做为输入发送的命令。
- Returns:
PiccCardInfo- Throws:
PiccDevException- Since:
- V3.13.00
-
cardEmulateSetListenPara
void cardEmulateSetListenPara(byte[] sensRes, byte[] nfcId1, byte[] sleRes, byte[] pollingResp) throws PiccDevException
设置模拟卡片的参数。Set the parameters of the emulate card.- Parameters:
sensRes-传入2字节的ATQA。ATQA为WUPA/REQA的应答。如果传入NULL,则使用默认的0x04, 0x00。Pass in 2 bytes of ATQA. ATQA is responses of WUPA/REQA. If NULL is passed, the default 0x04, 0x00 is used.nfcId1-传入3个字节的UID,为UID的第2,3,4字节,第1字节为硬件码,由非接芯片生成。如果传入NULL,则使用默认的0xA1, 0xA2, 0xA3。The UID of 3 bytes is passed in, which is the 2nd, 3rd, 4th byte of UID, and the 1st byte is the hardware code, which is generated by contractless card chip.If NULL is passed, the default 0xA1, 0xA2, 0xA3 is used.sleRes-传入1字节的SAK。如果传入NULL,则使用默认的0x00。The SAK of 1-byte is passed in. If NULL is passed in, the default 0x00 is used.pollingResp-暂未启用,传入NULL。Not enabled, pass NULL.- Throws:
PiccDevException- Since:
- V3.17.00
-
cardEmulateListen
byte[] cardEmulateListen(byte mode, int recvMaxSize, int waitTimeMs) throws PiccDevException
启动模拟对应类型的卡片,并监听是否有被读卡器成功寻卡。Start the simulation of the corresponding type of card and listen for the reader to find the card successfully.- Parameters:
mode-0x01:表示模拟A类型的卡片。0x01:Simulate a card of type A.recvMaxSize-接收的最大长度。The maximum length of reception.waitTimeMs-等下被读卡器寻卡的等待时间,单位:毫秒。The waiting time for the card reader to find the card. Units: milliseconds.- Returns:
- 对A类型卡,表示在防冲突完成之后,收到来自读卡器的第一条指令内容。For type A CARDS, the first instruction from the card reader is received after the conflict prevention is completed.
- Throws:
PiccDevException- Since:
- V3.17.00
-
cardEmulateSend
void cardEmulateSend(byte[] buffer) throws PiccDevException
卡端发送指令给读卡器。需在被读卡器成功寻卡之后调用。The card side sends instructions to the card reader.To be called after the card reader has successfully found the card.- Parameters:
buffer-卡端发送指令的内容。The card side sends the contents of the instruction.- Throws:
PiccDevException- Since:
- V3.17.00
-
cardEmulateReceive
byte[] cardEmulateReceive(int recvMaxSize, int waitTimeMs) throws PiccDevException
卡端接收指令。The card side receives instructions.- Parameters:
recvMaxSize-接收的最大字节数。Maximum number of bytes received.waitTimeMs-接收的等待时间。单位:毫秒。Waiting time to receive. Units: milliseconds.- Returns:
- 接收的内容 。Received content.
- Throws:
PiccDevException- Since:
- V3.17.00
-
changeBaudRate
void changeBaudRate(int bps) throws PiccDevException
更改外置密码键盘通信波特率。Change the external PINPAD communication Baud rate.- Parameters:
bps-波特率。- 9600
- 115200
Baud rate.- 9600
- 115200
- Throws:
PiccDevException- Since:
- V3.18.00
-
resetCarrier
void resetCarrier() throws PiccDevException
重置载波,快速复位。Reset the carrier and quickly reset.- Throws:
PiccDevException- PiccDevException- Since:
- V3.26.00
-
extendFunction
byte[] extendFunction(byte[] data) throws PiccDevException
非接扩展功能,比如通过命令模拟 NFC URL TAG功能。Contactless extension functions, such as simulating the NFC URL TAG function through commands.- Parameters:
data-输入的数据。Input data.- Returns:
- 接收的数据。Received data.
- Throws:
PiccDevException- PiccDevException- Since:
- V3.27.00
-
initIso15693
void initIso15693(byte codeMode) throws PiccDevException
对ISO15693卡进行初始化配置 [目前仅支持X5]。Initialize the ISO15693 card (currently only X5 is supported).- Parameters:
codeMode-设置与卡片交互的传输速率:
0: 26.48 kbits/s
其它值: 暂不支持Set the transmission rate for interacting with the card :
0:26.48 kbits/s
Other values: not supported- Throws:
PiccDevException- PiccDevException- Since:
- V3.33.00
-
-