Commit 61400094 by guof

Merge branch 'feature-1007488' into 'release'

修改gb28181

See merge request !59
parents 35a730c7 545cccd2
......@@ -1020,6 +1020,7 @@ void CameraHandle::printWifi(XSDK_HANDLE hDevice,XSDK_CFG::NetWork_Wifi &cfg){
int CameraHandle::resetGb28181(){
NonConnectedCameraHandle *connectedCameraHandle =NonConnectedCameraHandle::getInstance();
int old=hDevice;
MainWindow::sp_this->setIsResetting(true);
bool is_wifi=false;
ScopeSemaphoreExit guard([]() {
......@@ -1054,6 +1055,7 @@ int CameraHandle::resetGb28181(){
int sdk_handle=this->sdkDevLoginSyn(reachableIp,loginParam->nDevPort,loginParam->sUserName,loginParam->sPassword,3000);
if(sdk_handle<0){
qInfo()<<QString("SN(%1): WIFI新句柄生成失败").arg(sSn);
this->hDevice=old;
return -1;
}else {
qInfo()<<QString("SN(%1): WIFI新句柄生成成功").arg(sSn);
......@@ -1074,10 +1076,11 @@ int CameraHandle::resetGb28181(){
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;
return -1;
}else {
XSDK_DevLogout(newHandle);
qInfo()<<QString("SN(%1): WIFI新句柄生成成功").arg(sSn);
}
}else {
device.reachableIp=old_ip;
......@@ -1087,6 +1090,8 @@ int CameraHandle::resetGb28181(){
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;
return -1;
}else {
XSDK_DevLogout(old);
qInfo()<<QString("SN(%1): 有线新句柄生成成功").arg(sSn);
......@@ -1100,6 +1105,71 @@ int CameraHandle::resetGb28181(){
}
int CameraHandle::forceWriteGb28181(){
Common & instace= Common::getInstance();
HttpService http_gb28181(httpUrl);
vides_data::response *res=http_gb28181.httpFindGb28181Config(sSn);
ScopeSemaphoreExit guard([&instace,&res]() {
instace.deleteObj(res);
});
if(res->code!=0){
qInfo()<<"请求摄像头gb28181配置失败";
return -1;
}
vides_data::responseGb28181 *gb28181 = reinterpret_cast<vides_data::responseGb28181*>(res->data);
XSDK_CFG::NetWork_SPVMN config;
config.Camreaid.InitArraySize(64);
for (int i = 1; i <= 64; ++i) {
if (i == 1) {
QByteArray b_StrValue = gb28181->channel_id.toUtf8();
const char* str_Value = b_StrValue.constData();
JStrObj* newCameraId = &config.Camreaid[i - 1];
newCameraId->operator=(str_Value);
} else {
QString str("3402000000131000001" + QString::number(i, 10).rightJustified(2, '0'));
QByteArray b_Str = str.toUtf8();
const char* s_ct = b_Str.constData();
JStrObj* newCameraId = &config.Camreaid[i - 1];
newCameraId->operator=(s_ct);
}
}
QByteArray && bSip_ip= gb28181->sip_ip.toUtf8();
char* sip_ip = bSip_ip.data();
config.szCsIP.SetValue(sip_ip);
QByteArray && bSzServerNo=gb28181->serial.toUtf8();
char* sz_ServerNo = bSzServerNo.data();
config.szServerNo.SetValue(sz_ServerNo);
config.sCsPort.SetValue(gb28181->sip_port);
config.sUdpPort.SetValue(5060);
QByteArray && bSzServerDn=gb28181->realm.toUtf8();
char* sz_ServerDn = bSzServerDn.data();
config.szServerDn.SetValue(sz_ServerDn);
config.bCsEnable.SetValue(true);
config.iRsAgedTime.SetValue(gb28181->register_validity);
config.iHsIntervalTime.SetValue(gb28181->heartbeat_interval);
QByteArray && bSzConnPass=gb28181->password.toUtf8();
char* sz_connPass = bSzConnPass.data();
config.szConnPass.SetValue(sz_connPass);
QByteArray && bDevice_id=gb28181->device_id.toUtf8();
char* cdevice_id = bDevice_id.data();
config.szDeviceNO.SetValue(cdevice_id);
const char* pCfg = config.ToString();
sdkDevSpvMn(pCfg);
}
bool CameraHandle::sdkWifi(QString &pwd,QString &ssid){
Common & instace= Common::getInstance();
XSDK_CFG::NetWork_Wifi wif;
......@@ -1279,13 +1349,15 @@ void CameraHandle::updateSdkDevSpvMn(vides_data::responseGb28181 *gb28181){
}
void CameraHandle::sdkDevSpvMn(const char *spvMn){
int CameraHandle::sdkDevSpvMn(const char *spvMn){
char szOutBuffer[512] = { 0 };
int nLen = sizeof(szOutBuffer);
int res=XSDK_DevSetSysConfigSyn(hDevice,JK_NetWork_SPVMN,spvMn,strlen(spvMn),szOutBuffer,&nLen,3000,EXCMD_CONFIG_SET);
if(res<0){
qInfo() <<sSn<< ":sdkDevSpvMn 28181->修改失败"<<res;
return -1;
}
return res;
}
int CameraHandle::deviceReboot(){
int nRet=0;
......
......@@ -100,11 +100,13 @@ public:
//配置编码设置
void sdkEncodeCfg(const char *enCode);
//28181更新
void sdkDevSpvMn(const char* spvMn);
int sdkDevSpvMn(const char* spvMn);
//gb218开启
int updateSdkDevStatus(bool status);
void updateSdkDevSpvMn(vides_data::responseGb28181 *gb28181);
//重启设备
int deviceReboot();
//设备关机
......@@ -114,6 +116,9 @@ public:
//复位GB28181
int resetGb28181();
//强制gb28181配置后写入摄像头
int forceWriteGb28181();
//获取ip
void findIp(QString &ip);
......
......@@ -242,8 +242,7 @@ int MqttSubscriber::messageArrived(char* topicName, int topicLen, MQTTAsync_mess
} else {
qInfo() << "IP address not found in msg_body.";
}
res=connectedCameraHandle->distributionNetwork(ipAddress,response.sn,hDevice);
res=(connectedCameraHandle->distributionNetwork(ipAddress,response.sn,hDevice)?0x01 :-1);
}
vides_data::requestMqttData request;
......
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