|
|
|
@ -16,6 +16,8 @@ public class HikLoginModuleImpl implements CameraControlLoginModule {
|
|
|
|
|
|
|
|
|
|
|
|
public static HCNetSDK hcNetsdk = HCNetSDK.INSTANCE;
|
|
|
|
public static HCNetSDK hcNetsdk = HCNetSDK.INSTANCE;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static int MAX_RECONNET_TIME = 100000;
|
|
|
|
|
|
|
|
|
|
|
|
static HikExceptionCallBack hikExceptionCallBack = new HikExceptionCallBack();
|
|
|
|
static HikExceptionCallBack hikExceptionCallBack = new HikExceptionCallBack();
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
@ -40,10 +42,10 @@ public class HikLoginModuleImpl implements CameraControlLoginModule {
|
|
|
|
log.error("hik callback config error");
|
|
|
|
log.error("hik callback config error");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//设置登录超时时间和尝试次数,可选
|
|
|
|
//设置登录超时时间和尝试次数,可选
|
|
|
|
int waitTime = 5000; //登录请求响应超时时间设置为5S
|
|
|
|
int waitTime = 1000; //登录请求响应超时时间设置
|
|
|
|
int tryTimes = 1000; //登录时尝试建立链接1次
|
|
|
|
int tryTimes = 1000; //登录时尝试建立链接次数
|
|
|
|
hcNetsdk.NET_DVR_SetConnectTime(waitTime, tryTimes);
|
|
|
|
Boolean ok1 = hcNetsdk.NET_DVR_SetConnectTime(waitTime, tryTimes);
|
|
|
|
hcNetsdk.NET_DVR_SetReconnect(500,Boolean.TRUE);
|
|
|
|
Boolean ok2 = hcNetsdk.NET_DVR_SetReconnect(500,Boolean.TRUE);
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -75,18 +77,28 @@ public class HikLoginModuleImpl implements CameraControlLoginModule {
|
|
|
|
|
|
|
|
|
|
|
|
m_strLoginInfo.wPort = (short) m_nPort;
|
|
|
|
m_strLoginInfo.wPort = (short) m_nPort;
|
|
|
|
|
|
|
|
|
|
|
|
m_strLoginInfo.bUseAsynLogin = false; //是否异步登录:0- 否,1- 是
|
|
|
|
m_strLoginInfo.bUseAsynLogin = true; //是否异步登录:0- 否,1- 是
|
|
|
|
m_strLoginInfo.write();
|
|
|
|
m_strLoginInfo.write();
|
|
|
|
HCNetSDK.NET_DVR_DEVICEINFO_V30 m_strDeviceInfo30 = new HCNetSDK.NET_DVR_DEVICEINFO_V30();//设备信息
|
|
|
|
HCNetSDK.NET_DVR_DEVICEINFO_V30 m_strDeviceInfo30 = new HCNetSDK.NET_DVR_DEVICEINFO_V30();//设备信息
|
|
|
|
|
|
|
|
|
|
|
|
int m_lUserID = hcNetsdk.NET_DVR_Login_V30(m_strIp,(short) m_nPort,m_strUser,m_strPassword,m_strDeviceInfo30);
|
|
|
|
int m_lUserID = hcNetsdk.NET_DVR_Login_V30(m_strIp,(short) m_nPort,m_strUser,m_strPassword,m_strDeviceInfo30);
|
|
|
|
if(m_lUserID < 0){
|
|
|
|
int tryTimes = 0;
|
|
|
|
|
|
|
|
while(m_lUserID < 0 && tryTimes < MAX_RECONNET_TIME){
|
|
|
|
log.error("hik login error,ip:{},port:{},errorCode:{}",m_strIp,m_nPort,hcNetsdk.NET_DVR_GetLastError());
|
|
|
|
log.error("hik login error,ip:{},port:{},errorCode:{}",m_strIp,m_nPort,hcNetsdk.NET_DVR_GetLastError());
|
|
|
|
return null;
|
|
|
|
try {
|
|
|
|
}else {
|
|
|
|
Thread.sleep(500);
|
|
|
|
|
|
|
|
} catch (InterruptedException e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
m_lUserID = hcNetsdk.NET_DVR_Login_V30(m_strIp,(short) m_nPort,m_strUser,m_strPassword,m_strDeviceInfo30);
|
|
|
|
|
|
|
|
tryTimes ++;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(m_lUserID >= 0){
|
|
|
|
log.info("hik login success");
|
|
|
|
log.info("hik login success");
|
|
|
|
|
|
|
|
return new NetSDKLib.LLong(m_lUserID);
|
|
|
|
|
|
|
|
}else {
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return new NetSDKLib.LLong(m_lUserID);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|