Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gamera_videos_no_ui
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
liusq
gamera_videos_no_ui
Commits
c8177478
Commit
c8177478
authored
Oct 11, 2024
by
“liusq”
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改mqtt断线08
parent
02df32fc
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
26 additions
and
64 deletions
+26
-64
CameraHandle.cpp
+26
-35
MqttSubscriber.cpp
+0
-18
MqttSubscriber.h
+0
-3
mainwindow.cpp
+0
-6
mainwindow.h
+0
-2
No files found.
CameraHandle.cpp
View file @
c8177478
...
...
@@ -1072,50 +1072,41 @@ int CameraHandle::resetGb28181(QString &uuiq){
}
}
// 阻塞等待5秒
//QThread::sleep(5);
QTimer
*
timer
=
new
QTimer
(
this
);
timer
->
moveToThread
(
this
->
thread
());
QThread
::
sleep
(
5
);
// 连接 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
);
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
);
}
}
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):
WIFI
新句柄生成失败"
).
arg
(
sSn
);
this
->
hDevice
=
newHandle
;
qInfo
()
<<
QString
(
"SN(%1):
有线
新句柄生成失败"
).
arg
(
sSn
);
this
->
hDevice
=
old
;
res
=
-
1
;
}
else
{
XSDK_DevLogout
(
newHandle
);
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
{
XSDK_DevLogout
(
old
);
qInfo
()
<<
QString
(
"SN(%1): 有线新句柄生成成功"
).
arg
(
sSn
);
}
XSDK_DevLogout
(
old
);
qInfo
()
<<
QString
(
"SN(%1): 有线新句柄生成成功"
).
arg
(
sSn
);
}
}
}
MainWindow
::
sp_this
->
mqttEmitAsynchronous
(
uuiq
,
res
,
device
.
sSn
);
timer
->
deleteLater
();
// 确保在任务完成后删除 QTimer
});
}
// 设置 QTimer 的超时时间为 5 秒
timer
->
setSingleShot
(
true
);
timer
->
start
(
5000
);
//this->updateSdkDevStatus(true);
return
1
;
}
...
...
MqttSubscriber.cpp
View file @
c8177478
...
...
@@ -58,8 +58,6 @@ void MqttSubscriber::init(vides_data::MqttConfig &config, QString &httpUrl, QStr
MqttSubscriber
::
MqttSubscriber
(
QObject
*
parent
)
:
QObject
(
parent
),
retryTimer
(
new
QTimer
(
this
)),
client
(
nullptr
)
{
connect
(
this
,
&
MqttSubscriber
::
asynchronousMqtt
,
this
,
&
MqttSubscriber
::
asynchronousPush
,
Qt
::
QueuedConnection
);
// 连接信号和槽
connect
(
this
,
&
MqttSubscriber
::
connectionLostSignal
,
this
,
&
MqttSubscriber
::
reconnectAndFetchConfig
,
Qt
::
QueuedConnection
);
...
...
@@ -107,9 +105,6 @@ void MqttSubscriber::start() {
qInfo
()
<<
"启动连接失败,返回编码"
<<
rc
;
}
}
void
MqttSubscriber
::
emitAsynchronous
(
QString
&
uniq
,
int
&
res
,
QString
&
sn
){
emit
asynchronousMqtt
(
uniq
,
res
,
sn
);
}
void
MqttSubscriber
::
onConnect
(
MQTTAsync_successData
*
response
)
{
...
...
@@ -250,11 +245,6 @@ int MqttSubscriber::messageArrived(char* topicName, int topicLen, MQTTAsync_mess
}
res
=
(
connectedCameraHandle
->
distributionNetwork
(
ipAddress
,
response
.
sn
,
hDevice
)
?
0x01
:-
1
);
}
if
(
response
.
msg_type
==
8
)
{
qInfo
()
<<
"mqtt 复位GB28181 异步走卡槽函数触发"
;
return
-
1
;
}
vides_data
::
requestMqttData
request
;
request
.
code
=
(
res
>=
0
)
?
0
:
0x01
;
request
.
msg
=
(
res
>=
0
)
?
"成功"
:
"失败"
;
...
...
@@ -265,14 +255,6 @@ int MqttSubscriber::messageArrived(char* topicName, int topicLen, MQTTAsync_mess
MQTTAsync_free
(
topicName
);
return
1
;
}
void
MqttSubscriber
::
asynchronousPush
(
QString
&
uniq
,
int
&
res
,
QString
&
sn
){
vides_data
::
requestMqttData
request
;
request
.
code
=
(
res
>=
0
)
?
0
:
0x01
;
request
.
msg
=
(
res
>=
0
)
?
"成功"
:
"失败"
;
request
.
uniq
=
uniq
;
sendSubscriptionConfirmation
(
request
,
sn
);
}
void
MqttSubscriber
::
sendSubscriptionConfirmation
(
const
vides_data
::
requestMqttData
&
response
,
QString
&
sn
)
{
QString
responseTopic
=
"/thingshub/"
+
response
.
uniq
+
"/device/post"
;
QByteArray
bResponseTopic
=
responseTopic
.
toUtf8
();
...
...
MqttSubscriber.h
View file @
c8177478
...
...
@@ -14,15 +14,12 @@ public:
void
init
(
vides_data
::
MqttConfig
&
config
,
QString
&
httpUrl
,
QString
&
serialNumber
);
void
start
();
void
emitAsynchronous
(
QString
&
uniq
,
int
&
res
,
QString
&
sn
);
signals
:
void
connectionLostSignal
();
void
asynchronousMqtt
(
QString
&
uniq
,
int
&
res
,
QString
&
sn
);
private
slots
:
void
reconnectAndFetchConfig
();
void
asynchronousPush
(
QString
&
uniq
,
int
&
res
,
QString
&
sn
);
private
:
MqttSubscriber
(
QObject
*
parent
=
nullptr
);
...
...
mainwindow.cpp
View file @
c8177478
...
...
@@ -133,12 +133,6 @@ MainWindow::MainWindow():isResetting(false)
this
->
mqttConfig
=
config
.
mqttConfig
;
runOrRebootMqtt
(
mqttConfig
,
httpurl
,
serialNumber
);
}
void
MainWindow
::
mqttEmitAsynchronous
(
QString
&
uuiq
,
int
&
res
,
QString
&
sn
){
MqttSubscriber
*
subscriber
=
MqttSubscriber
::
getInstance
(
this
);
subscriber
->
emitAsynchronous
(
uuiq
,
res
,
sn
);
}
void
MainWindow
::
runOrRebootMqtt
(
vides_data
::
MqttConfig
&
mqtt_config
,
QString
&
httpUrl
,
QString
&
serialNumber
){
MqttSubscriber
*
subscriber
=
MqttSubscriber
::
getInstance
(
this
);
subscriber
->
init
(
mqtt_config
,
httpUrl
,
serialNumber
);
...
...
mainwindow.h
View file @
c8177478
...
...
@@ -49,8 +49,6 @@ public:
void
divParameterUpdate
(
vides_data
::
responseConfig
&
cloudConfig
,
QString
&
httpUrl
,
QString
&
serialNumber
);
static
MainWindow
*
sp_this
;
void
mqttEmitAsynchronous
(
QString
&
uniq
,
int
&
res
,
QString
&
sn
);
CameraHandle
*
findHandle
(
QString
sn
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment