Commit 97c5d870 by “liusq”

修改mqtt断线06

parent e3cfe167
...@@ -1073,43 +1073,49 @@ int CameraHandle::resetGb28181(QString &uuiq){ ...@@ -1073,43 +1073,49 @@ int CameraHandle::resetGb28181(QString &uuiq){
} }
// 阻塞等待5秒 // 阻塞等待5秒
//QThread::sleep(5); //QThread::sleep(5);
QTimer::singleShot(5000, this, [this, &is_wifi,&result,&uuiq,&connectedCameraHandle, &newHandle, &device, &old]() { QString old_ip; QTimer* timer = new QTimer(this);
int res=1;
MainWindow::sp_this->findSnMapIp(this->sSn,old_ip); // 连接 QTimer 的超时信号到匿名槽函数
if(old_ip.length()>0){ QObject::connect(timer, &QTimer::timeout, [this, &is_wifi, &result, &uuiq, &connectedCameraHandle, &newHandle, &device, &old, timer]() {
if(is_wifi){ QString old_ip;
result=connectedCameraHandle->wifiChangeIp(old_ip,newHandle,sSn); int res = 1;
int sdk_handle=this->sdkDevLoginSyn(old_ip,loginParam->nDevPort,loginParam->sUserName,loginParam->sPassword,3000); MainWindow::sp_this->findSnMapIp(this->sSn, old_ip);
if(sdk_handle<0){ if (old_ip.length() > 0) {
qInfo()<<QString("SN(%1): WIFI新句柄生成失败").arg(sSn); if (is_wifi) {
this->hDevice=newHandle; result = connectedCameraHandle->wifiChangeIp(old_ip, newHandle, sSn);
res= -1; int sdk_handle = this->sdkDevLoginSyn(old_ip, loginParam->nDevPort, loginParam->sUserName, loginParam->sPassword, 3000);
}else { if (sdk_handle < 0) {
qInfo() << QString("SN(%1): WIFI新句柄生成失败").arg(sSn);
this->hDevice = newHandle;
res = -1;
} else {
XSDK_DevLogout(newHandle); XSDK_DevLogout(newHandle);
qInfo()<<QString("SN(%1): WIFI新句柄生成成功").arg(sSn); qInfo() << QString("SN(%1): WIFI新句柄生成成功").arg(sSn);
} }
}else { } else {
device.reachableIp=old_ip; device.reachableIp = old_ip;
device.sSn=sSn; device.sSn = sSn;
bool result= connectedCameraHandle->changeCameraIp(device); bool result = connectedCameraHandle->changeCameraIp(device);
if(result){ if (result) {
int sdk_handle=this->sdkDevLoginSyn(old_ip,loginParam->nDevPort,loginParam->sUserName,loginParam->sPassword,3000); int sdk_handle = this->sdkDevLoginSyn(old_ip, loginParam->nDevPort, loginParam->sUserName, loginParam->sPassword, 3000);
if(sdk_handle<0){ if (sdk_handle < 0) {
qInfo()<<QString("SN(%1): 有线新句柄生成失败").arg(sSn); qInfo() << QString("SN(%1): 有线新句柄生成失败").arg(sSn);
this->hDevice=old; this->hDevice = old;
res= -1; res = -1;
}else { } else {
XSDK_DevLogout(old); XSDK_DevLogout(old);
qInfo()<<QString("SN(%1): 有线新句柄生成成功").arg(sSn); qInfo() << QString("SN(%1): 有线新句柄生成成功").arg(sSn);
} }
} }
} }
} }
MainWindow::sp_this->mqttEmitAsynchronous(uuiq,res,device.sSn); MainWindow::sp_this->mqttEmitAsynchronous(uuiq, res, device.sSn);
return res; timer->deleteLater(); // 确保在任务完成后删除 QTimer
}); });
// 设置 QTimer 的超时时间为 5 秒
timer->setSingleShot(true);
timer->start(5000);
//this->updateSdkDevStatus(true); //this->updateSdkDevStatus(true);
return 1; 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