Commit 3e494907 by 郭峰

Merge branch 'feature-1007488' into 'release'

修改mqtt断线06

See merge request !67
parents 009f7d69 97c5d870
......@@ -1073,43 +1073,49 @@ int CameraHandle::resetGb28181(QString &uuiq){
}
// 阻塞等待5秒
//QThread::sleep(5);
QTimer::singleShot(5000, this, [this, &is_wifi,&result,&uuiq,&connectedCameraHandle, &newHandle, &device, &old]() { QString old_ip;
int res=1;
MainWindow::sp_this->findSnMapIp(this->sSn,old_ip);
if(old_ip.length()>0){
if(is_wifi){
result=connectedCameraHandle->wifiChangeIp(old_ip,newHandle,sSn);
int sdk_handle=this->sdkDevLoginSyn(old_ip,loginParam->nDevPort,loginParam->sUserName,loginParam->sPassword,3000);
if(sdk_handle<0){
qInfo()<<QString("SN(%1): WIFI新句柄生成失败").arg(sSn);
this->hDevice=newHandle;
res= -1;
}else {
QTimer* timer = new QTimer(this);
// 连接 QTimer 的超时信号到匿名槽函数
QObject::connect(timer, &QTimer::timeout, [this, &is_wifi, &result, &uuiq, &connectedCameraHandle, &newHandle, &device, &old, timer]() {
QString old_ip;
int res = 1;
MainWindow::sp_this->findSnMapIp(this->sSn, old_ip);
if (old_ip.length() > 0) {
if (is_wifi) {
result = connectedCameraHandle->wifiChangeIp(old_ip, newHandle, sSn);
int sdk_handle = this->sdkDevLoginSyn(old_ip, loginParam->nDevPort, loginParam->sUserName, loginParam->sPassword, 3000);
if (sdk_handle < 0) {
qInfo() << QString("SN(%1): WIFI新句柄生成失败").arg(sSn);
this->hDevice = newHandle;
res = -1;
} else {
XSDK_DevLogout(newHandle);
qInfo()<<QString("SN(%1): WIFI新句柄生成成功").arg(sSn);
qInfo() << QString("SN(%1): WIFI新句柄生成成功").arg(sSn);
}
}else {
device.reachableIp=old_ip;
device.sSn=sSn;
bool result= connectedCameraHandle->changeCameraIp(device);
if(result){
int sdk_handle=this->sdkDevLoginSyn(old_ip,loginParam->nDevPort,loginParam->sUserName,loginParam->sPassword,3000);
if(sdk_handle<0){
qInfo()<<QString("SN(%1): 有线新句柄生成失败").arg(sSn);
this->hDevice=old;
res= -1;
}else {
} else {
device.reachableIp = old_ip;
device.sSn = sSn;
bool result = connectedCameraHandle->changeCameraIp(device);
if (result) {
int sdk_handle = this->sdkDevLoginSyn(old_ip, loginParam->nDevPort, loginParam->sUserName, loginParam->sPassword, 3000);
if (sdk_handle < 0) {
qInfo() << QString("SN(%1): 有线新句柄生成失败").arg(sSn);
this->hDevice = old;
res = -1;
} else {
XSDK_DevLogout(old);
qInfo()<<QString("SN(%1): 有线新句柄生成成功").arg(sSn);
qInfo() << QString("SN(%1): 有线新句柄生成成功").arg(sSn);
}
}
}
}
MainWindow::sp_this->mqttEmitAsynchronous(uuiq,res,device.sSn);
return res;
MainWindow::sp_this->mqttEmitAsynchronous(uuiq, res, device.sSn);
timer->deleteLater(); // 确保在任务完成后删除 QTimer
});
// 设置 QTimer 的超时时间为 5 秒
timer->setSingleShot(true);
timer->start(5000);
//this->updateSdkDevStatus(true);
return 1;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment