|
@@ -707,11 +707,19 @@ bool CAccessAuthEntity::GetTerminalPublicKey(BYTE* pBuf, int& nBufLen, string& p
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
-//oilyang@20210510 嵌入"bool CAccessAuthEntity::HasPinPad()"的逻辑
|
|
|
-// 返回1:只有PinPadID;2:只有DeviceID;3:两者都有;0:没有;-1表示失败
|
|
|
ErrorCodeEnum CAccessAuthEntity::GetPinPadModel(CSimpleStringA& pinpadModel, bool& bPinPadOnline)
|
|
|
{
|
|
|
bPinPadOnline = false;
|
|
|
+ int waitMS = 0;
|
|
|
+
|
|
|
+ CSmartPointer<IConfigInfo> spConfig;
|
|
|
+ ErrorCodeEnum Error = GetFunction()->OpenConfig(Config_CenterSetting, spConfig);
|
|
|
+ ErrorCodeEnum errCode = spConfig->ReadConfigValueInt("AccessAuthorization", "WaitPinPadMS", waitPinPadMS);
|
|
|
+ if (waitPinPadMS <= 0)
|
|
|
+ {
|
|
|
+ waitPinPadMS = DEFALT_WAIT_PINPAD_MS; //默认不等待
|
|
|
+ }
|
|
|
+
|
|
|
CSimpleStringA strErrMsg;
|
|
|
CSmartPointer<IEntityFunction> spFunction = this->GetFunction();
|
|
|
std::map<std::string, std::string> errInfo;
|
|
@@ -723,98 +731,88 @@ ErrorCodeEnum CAccessAuthEntity::GetPinPadModel(CSimpleStringA& pinpadModel, boo
|
|
|
}
|
|
|
|
|
|
ErrorCodeEnum nRet = Error_Unexpect;
|
|
|
- auto pPinPadClient = new PinPadService_ClientBase(this);
|
|
|
- bool bPinPadID = false;
|
|
|
- bool bDeviceID = false;
|
|
|
- bool bVendor = false;
|
|
|
- bool bBluetooth = false;
|
|
|
- CSimpleStringA strVendor;
|
|
|
- CSimpleStringA strBluetoothID;
|
|
|
- CSimpleStringA strPID;
|
|
|
- CSimpleStringA strMID;
|
|
|
- auto rc = 0;
|
|
|
- if ((rc = pPinPadClient->Connect()) == Error_Succeed)
|
|
|
+ ErrorCodeEnum rc = Error_Unexpect;
|
|
|
+ do
|
|
|
{
|
|
|
- //初始错误信息
|
|
|
- errInfo["errcode"] = "RTA5205";
|
|
|
- errInfo["msg"] = "调用PinPad发生错误";
|
|
|
- errInfo["getLastErr"] = GetLastError();
|
|
|
- pinpadModel = generateJsonStr(errInfo).second.c_str();
|
|
|
-
|
|
|
- PinPadService_GetDevInfo_Req req = {};
|
|
|
- PinPadService_GetDevInfo_Ans ans = {};
|
|
|
-
|
|
|
- rc = pPinPadClient->GetDevInfo(req, ans, 3000);
|
|
|
- if (rc == Error_Succeed)
|
|
|
+ auto pPinPadClient = new PinPadService_ClientBase(this);
|
|
|
+ if ((rc = pPinPadClient->Connect()) == Error_Succeed)
|
|
|
{
|
|
|
- bPinPadOnline = true;
|
|
|
- nRet = Error_Succeed;
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("pinpad model: %s", ans.model.GetData());
|
|
|
-
|
|
|
- // CM = V2.0#PM = V1.0#MID = 75500001#PID = 12345678#FWID = V1234567#Vendor = nantian
|
|
|
- // 密码键盘ID,PID,8到16字节; 设备ID,MID,8到16字节; 固件版本号,FWID,8字节
|
|
|
- pinpadModel = ans.model;
|
|
|
+ PinPadService_GetDevInfo_Req req = {};
|
|
|
+ PinPadService_GetDevInfo_Ans ans = {};
|
|
|
+
|
|
|
+ rc = pPinPadClient->GetDevInfo(req, ans, 3000);
|
|
|
+ if (rc == Error_Succeed)
|
|
|
+ {
|
|
|
+ bPinPadOnline = true;
|
|
|
+ nRet = Error_Succeed;
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("pinpad model: %s", ans.model.GetData());
|
|
|
+
|
|
|
+ // CM = V2.0#PM = V1.0#MID = 75500001#PID = 12345678#FWID = V1234567#Vendor = nantian
|
|
|
+ // 密码键盘ID,PID,8到16字节; 设备ID,MID,8到16字节; 固件版本号,FWID,8字节
|
|
|
+ pinpadModel = ans.model;
|
|
|
+
|
|
|
+ pPinPadClient->GetFunction()->CloseSession();
|
|
|
+ pPinPadClient->SafeDelete();
|
|
|
+ pPinPadClient = NULL;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ pPinPadClient->GetFunction()->CloseSession();
|
|
|
}
|
|
|
- else if(rc == Error_NotInit)
|
|
|
- {
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("pinpad NOT INIT!, state: %d", ans.state);
|
|
|
- strErrMsg = "PinPad打开失败";
|
|
|
- SetAuthErrMsg(strErrMsg.GetData());
|
|
|
+
|
|
|
+ pPinPadClient->SafeDelete();
|
|
|
+ pPinPadClient = NULL;
|
|
|
+ waitMS += INTERVAL_WAIT_PINPAD_MS;
|
|
|
|
|
|
- string outStr = GetOutPutStr("%s%08X%s%s", "GetDevInfo", rc, "strErrMsg", strErrMsg.GetData());
|
|
|
- m_FSM.doWarnMsg(ERR_ACCESSAUTH_FROM_PINPAD, outStr.c_str());
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setResultCode("RTA5205")(outStr.c_str());
|
|
|
- return nRet;
|
|
|
- }
|
|
|
- else
|
|
|
+ if (waitPinPadMS > 0) //配置有效时才进行等待,不然直接跳出循环
|
|
|
{
|
|
|
- strErrMsg = "调用PinPad实体的GetDevInfo方法失败";
|
|
|
- SetAuthErrMsg(strErrMsg.GetData());
|
|
|
-
|
|
|
- string outStr = GetOutPutStr("%s%08X%s%s", "GetDevInfo", rc, "strErrMsg", strErrMsg.GetData());
|
|
|
- m_FSM.doWarnMsg(ERR_ACCESSAUTH_FROM_PINPAD, outStr.c_str());
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setResultCode("RTA5205")(outStr.c_str());
|
|
|
-
|
|
|
- return nRet;
|
|
|
+ Sleep(INTERVAL_WAIT_PINPAD_MS); //等待200ms
|
|
|
}
|
|
|
+ }
|
|
|
+ while (bPinPadOnline == false && waitMS < waitPinPadMS); //获取pinpad成功,或者时间超过阈值跳出
|
|
|
|
|
|
- pPinPadClient->GetFunction()->CloseSession();
|
|
|
- }
|
|
|
- else if (rc == Error_NetBroken)
|
|
|
+ if (rc == Error_NotInit)
|
|
|
{
|
|
|
- strErrMsg = "PinPad实体未启动, 连接密码键盘失败";
|
|
|
- SetAuthErrMsg((const char*)strErrMsg);
|
|
|
+ strErrMsg = "PinPad超时未打开";
|
|
|
+ SetAuthErrMsg(strErrMsg.GetData());
|
|
|
|
|
|
- m_FSM.doWarnMsg(ERR_ACCESSAUTH_CONNECT_PINPAD_UNLOAD,
|
|
|
- GetOutPutStr("%s%08X%s%s", "Connect", rc, "strErrMsg", "PinPad实体未启动, 连接密码键盘失败").c_str());
|
|
|
- pPinPadClient->SafeDelete();
|
|
|
+ string outStr = GetOutPutStr("%s%08X%s%s", "GetDevInfo", rc, "strErrMsg", strErrMsg.GetData());
|
|
|
+ m_FSM.doWarnMsg(ERR_ACCESSAUTH_PINPAD_OPEN_OVERTIME, outStr.c_str());
|
|
|
+ DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setResultCode("RTA5204")(outStr.c_str());
|
|
|
|
|
|
- errInfo["errcode"] = "RTA5218";
|
|
|
- errInfo["msg"] = "PinPad实体未启动";
|
|
|
+ errInfo["errcode"] = "RTA5204";
|
|
|
+ errInfo["msg"] = "PinPad超时未打开";
|
|
|
errInfo["getLastErr"] = GetLastError();
|
|
|
pinpadModel = generateJsonStr(errInfo).second.c_str();
|
|
|
|
|
|
- return nRet;
|
|
|
}
|
|
|
- else
|
|
|
+ else if(rc == Error_DevNotAvailable)
|
|
|
{
|
|
|
- strErrMsg = "连接PinPad实体失败";
|
|
|
- SetAuthErrMsg((const char*)strErrMsg);
|
|
|
+ strErrMsg = "PinPad打开失败";
|
|
|
+ SetAuthErrMsg(strErrMsg.GetData());
|
|
|
|
|
|
- m_FSM.doWarnMsg(ERR_ACCESSAUTH_CONNECT_PINPAD,
|
|
|
- GetOutPutStr("%s%08X%s%s", "Connect", rc, "strErrMsg", "连接PinPad实体失败").c_str());
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setResultCode("RTA5204")("连接密码键盘异常");
|
|
|
- pPinPadClient->SafeDelete();
|
|
|
+ string outStr = GetOutPutStr("%s%08X%s%s", "GetDevInfo", rc, "strErrMsg", strErrMsg.GetData());
|
|
|
+ m_FSM.doWarnMsg(ERR_ACCESSAUTH_PINPAD_OPEN_FAILED, outStr.c_str());
|
|
|
+ DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setResultCode("RTA5218")(outStr.c_str());
|
|
|
|
|
|
- errInfo["errcode"] = "RTA5204";
|
|
|
- errInfo["msg"] = "PinPad实体启动成功,但连接PinPad实体失败";
|
|
|
+ errInfo["errcode"] = "RTA5218";
|
|
|
+ errInfo["msg"] = "PinPad打开失败";
|
|
|
errInfo["getLastErr"] = GetLastError();
|
|
|
pinpadModel = generateJsonStr(errInfo).second.c_str();
|
|
|
-
|
|
|
- return nRet; //此时nRet = -1, pinpad调用失败
|
|
|
}
|
|
|
+ else if(rc != Error_Succeed)
|
|
|
+ {
|
|
|
+ strErrMsg = "连接PinPad取数据异常";
|
|
|
+ SetAuthErrMsg(strErrMsg.GetData());
|
|
|
|
|
|
- pPinPadClient = NULL;
|
|
|
+ string outStr = GetOutPutStr("%s%08X%s%s", "GetPinPadModel", rc, "strErrMsg", strErrMsg.GetData());
|
|
|
+ m_FSM.doWarnMsg(ERR_ACCESSAUTH_PINPAD_GETDATA_FAILED, outStr.c_str());
|
|
|
+ DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setResultCode("RTA5205")(outStr.c_str());
|
|
|
+
|
|
|
+ errInfo["errcode"] = "RTA5205";
|
|
|
+ errInfo["msg"] = "连接PinPad取数据异常";
|
|
|
+ errInfo["getLastErr"] = GetLastError();
|
|
|
+ pinpadModel = generateJsonStr(errInfo).second.c_str();
|
|
|
+ }
|
|
|
|
|
|
return nRet;
|
|
|
}
|