aijinhui
2023-10-24 8a87e4226aa802d6a0e3566c66824fedf68e77da
ard-work/src/main/java/com/ruoyi/device/dhsdk/module/LoginModule.java
@@ -6,6 +6,7 @@
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;
/**
@@ -18,7 +19,7 @@
    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);//
@@ -53,9 +54,9 @@
        //System.out.println(logPath);
        //setLog.bSetPrintStrategy = 1;
        //bLogopen = netsdk.CLIENT_LogOpen(setLog);
      //  if (!bLogopen) {
           // System.err.println("Failed to open NetSDK log");
       // }
        //  if (!bLogopen) {
        // System.err.println("Failed to open NetSDK log");
        // }
        // 设置断线重连回调接口,设置过断线重连成功回调函数后,当设备出现断线情况,SDK内部会自动进行重连操作
        // 此操作为可选操作,但建议用户进行设置
@@ -65,7 +66,6 @@
        int waitTime = 5000; //登录请求响应超时时间设置为5S
        int tryTimes = 1;    //登录时尝试建立链接1次
        netsdk.CLIENT_SetConnectTime(waitTime, tryTimes);
        // 设置更多网络参数,NET_PARAM的nWaittime,nConnectTryNum成员与CLIENT_SetConnectTime
        // 接口设置的登录设备超时时间和尝试次数意义相同,可选
@@ -102,7 +102,7 @@
     * 登录设备
     * \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();
@@ -111,12 +111,11 @@
        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 + ":" + m_nPort + " ]");
        }