配置模塊
調用流程
設置
創建一個實例,並通過 getControllerInstance()
and connectController()
連接到終端。
如果發生任何錯誤,應通過 onError
通知應用程序。
abstract class ApolloConfiguration(private val context: Context) : ConfigurationDelegate {
private var configurationController: ConfigurationController? = null
fun connect(): Boolean {
try {
if (configurationController == null) {
// get instance
configurationController = getControllerInstance(context, this)
// enable debug log display in console
SPDeviceController.enableDebugLog(true)
}
// establish the communication channel with terminal
configurationController?.connectController()
} catch (ex: Exception) {
return false
}
return true
}
fun disconnect() {
configurationController?.disconnectController()
configurationController?.releaseControllerInstance()
}
override fun onError(errorType: ControllerError.Error?, message: String?) {
// handle error here
}
}
獲取終端信息和參數
獲取終端信息
// getting infos
fun getDeviceInfo() {
configurationController?.getDeviceInfo()
}
override fun onDeviceInfoReceived(p0: Hashtable<String, String>?) {
// p0: terminal info
// {isSupportedTrack2=true, isSupportedTrack1=true, firmwareVersion=1.00.9, hardwareVersion=msm8909, vendorID=1234567, isCharging=true, batteryPercentage=99, serialNumber=1234567, isSupportedNfc=true, isUsbConnected=false, productID=A10, bID=APOLLO, isSupportedTrack3=true, batteryLevel=99}
}
獲取 AID
// getting aids
fun getAllAid(isContactLess: Boolean) {
configurationController?.getAllAid(isContactLess)
}
override fun onAllAidReceived(p0: Hashtable<String, String>?) {
// p0: All AIDs received
// {03=A00000002501, 02=A0000003330101, 01=A0000000041010, 00=A0000000031010, 04=A0000000651010}
}
fun getAidInfo(isContactLess: Boolean, index: String) {
configurationController?.getAidInfo(isContactLess, index)
}
override fun onAidInfoReceived(p0: Hashtable<String, Any>?) {
// p0: received AID
// {eRSBMax=63, contactlessTACDenial=0000000000, transCurrencyCode=0344, defaultTDOL=9F02069F0306, aid=A0000000031010, terminalCountryCode=0344, terminalCapabilities=0000C8, contactlessFloorLimit=000000050001, appIndex=00, eRSTarget=00, eRSBThresh=000000005000, contactlessTransactionLimit=000000050001, contactlessTACOnline=0000000000, contactlessCVMRequiredLimit=000000050001, eType=82, appVersion=0002, eBitField=02, defaultDDOL=9F3704, additTermCapabilities=6000F02001, contactlessTACDefault=0000000000}
}
獲取 CAPK
// getting capks
fun getAllCapk(isContactLess: Boolean) {
configurationController?.getAllCapk(isContactLess)
}
override fun onAllCapkReceived(p0: MutableList<CAPK>?) {
// p0: All CAPKs received
// [com.spectratech.controllers.CAPK@a4f610, ...]
}
fun getCapkInfo(isContactLess: Boolean, index: String) {
configurationController?.getCapkInfo(isContactLess, index)
}
override fun onCapkInfoReceived(p0: CAPK?) {
// p0: CAPK received
// CAPK(location=, rid=A000000003, index=89, exponent=03, modulus=..., checksum=, size=C0, expirydate=1225, effectdate=0115)
}
更新 AID
// updating AID
fun updateAID(isContactLess: Boolean, aid: Hashtable<String, String>) {
aid["action"] = "update"
configurationController?.updateAid(isContactLess, aid)
}
override fun onAidUpdated(p0: Hashtable<String, ConfigurationStatus>?) {
// p0: aid update result
// {eRSBMax=SUCCESS, terminalType=SUCCESS, transCurrencyCode=SUCCESS, defaultTDOL=SUCCESS, aid=SUCCESS, terminalCountryCode=SUCCESS, terminalFloorLimit=SUCCESS, terminalCapabilities=SUCCESS, contactTACDefault=SUCCESS, contactTACDenial=SUCCESS, eRSTarget=SUCCESS, eRSBThresh=SUCCESS, action=SUCCESS, contactTACOnline=SUCCESS, eType=SUCCESS, appVersion=SUCCESS, eBitField=SUCCESS, defaultDDOL=SUCCESS, additTermCapabilities=SUCCESS}
}
更新 CAPK
// updating CAPK
fun updateCapk(isContactLess: Boolean, capk: CAPK) {
configurationController?.updateCapk(isContactLess, capk)
}
override fun onCapkUpdated(p0: Boolean) {
// p0: update result
// true | false
}