| | |
| | | import com.ruoyi.device.dhsdk.lib.NetSDKLib.NET_OUT_LOGIN_WITH_HIGHLEVEL_SECURITY; |
| | | import com.sun.jna.ptr.IntByReference; |
| | | import lombok.extern.slf4j.Slf4j; |
| | |
|
| | | import static com.ruoyi.device.dhsdk.lib.ToolKits.getErrorCodePrint; |
| | | |
| | | /** |
| | |
| | | public static NetSDKLib netsdk = NetSDKLib.NETSDK_INSTANCE; |
| | | |
| | | // 设备信息 |
| | | public static NetSDKLib.NET_DEVICEINFO_Ex m_stDeviceInfo = new NetSDKLib.NET_DEVICEINFO_Ex(); |
| | | // public static NetSDKLib.NET_DEVICEINFO_Ex m_stDeviceInfo = new NetSDKLib.NET_DEVICEINFO_Ex();
|
| | | |
| | | // 登陆句柄 |
| | | public static LLong m_hLoginHandle = new LLong(0);// |
| | |
| | | int tryTimes = 1; //登录时尝试建立链接1次 |
| | | netsdk.CLIENT_SetConnectTime(waitTime, tryTimes); |
| | | |
| | | |
| | | // 设置更多网络参数,NET_PARAM的nWaittime,nConnectTryNum成员与CLIENT_SetConnectTime |
| | | // 接口设置的登录设备超时时间和尝试次数意义相同,可选 |
| | | NetSDKLib.NET_PARAM netParam = new NetSDKLib.NET_PARAM(); |
| | |
| | | * 登录设备 |
| | | * \endif |
| | | */ |
| | | public static LLong login(String m_strIp, int m_nPort, String m_strUser, String m_strPassword) { |
| | | public static LLong login(String m_strIp, int m_nPort, String m_strUser, String m_strPassword, NetSDKLib.NET_DEVICEINFO_Ex lpDeviceInfo) {
|
| | | IntByReference nError = new IntByReference(0); |
| | | //入参 |
| | | NET_IN_LOGIN_WITH_HIGHLEVEL_SECURITY pstInParam = new NET_IN_LOGIN_WITH_HIGHLEVEL_SECURITY(); |
| | |
| | | pstInParam.szPassword = m_strPassword.getBytes(); |
| | | pstInParam.szUserName = m_strUser.getBytes(); |
| | | //出参 |
| | | NET_OUT_LOGIN_WITH_HIGHLEVEL_SECURITY pstOutParam = new NET_OUT_LOGIN_WITH_HIGHLEVEL_SECURITY(); |
| | | pstOutParam.stuDeviceInfo = m_stDeviceInfo; |
| | | LLong m_hLoginHandle = netsdk.CLIENT_LoginEx2(m_strIp, m_nPort, m_strUser, m_strPassword, 0, null, m_stDeviceInfo, nError); |
| | | //NET_OUT_LOGIN_WITH_HIGHLEVEL_SECURITY pstOutParam = new NET_OUT_LOGIN_WITH_HIGHLEVEL_SECURITY();
|
| | | LLong m_hLoginHandle = netsdk.CLIENT_LoginEx2(m_strIp, m_nPort, m_strUser, m_strPassword, 0, null, lpDeviceInfo, nError);
|
| | | //m_hLoginHandle=netsdk.CLIENT_LoginWithHighLevelSecurity(pstInParam, pstOutParam); |
| | | if (m_hLoginHandle.longValue() == 0) { |
| | | log.debug("Login Device[%s] Port[%d]Failed. %s\n", m_strIp, m_nPort, getErrorCodePrint()); |
| | | log.debug("Login Failed [" + m_strIp + ":" + m_nPort + "],错误码:" + getErrorCodePrint());
|
| | | } else { |
| | | log.debug("Login Success [ " + m_strIp + " ]"); |
| | | log.debug("Login Success [ " + m_strIp + ":" + m_nPort + " ]");
|
| | | } |
| | | return m_hLoginHandle; |
| | | //return m_hLoginHandle.longValue() == 0? false:true; |
| | | } |
| | | |
| | | /** |