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
0
Merge Requests
0
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
07a92e1b
Commit
07a92e1b
authored
Oct 11, 2024
by
guof
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature-1007488' into 'release'
修改mqtt断线08 See merge request
!70
parents
b3a7628b
c8177478
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
1 additions
and
39 deletions
+1
-39
CameraHandle.cpp
+1
-10
MqttSubscriber.cpp
+0
-18
MqttSubscriber.h
+0
-3
mainwindow.cpp
+0
-6
mainwindow.h
+0
-2
No files found.
CameraHandle.cpp
View file @
07a92e1b
...
@@ -1072,11 +1072,8 @@ int CameraHandle::resetGb28181(QString &uuiq){
...
@@ -1072,11 +1072,8 @@ int CameraHandle::resetGb28181(QString &uuiq){
}
}
}
}
// 阻塞等待5秒
// 阻塞等待5秒
//QThread::sleep(5);
QThread
::
sleep
(
5
);
QTimer
*
timer
=
new
QTimer
(
this
);
timer
->
moveToThread
(
this
->
thread
());
// 连接 QTimer 的超时信号到匿名槽函数
// 连接 QTimer 的超时信号到匿名槽函数
QObject
::
connect
(
timer
,
&
QTimer
::
timeout
,
[
this
,
&
is_wifi
,
&
result
,
&
uuiq
,
&
connectedCameraHandle
,
&
newHandle
,
&
device
,
&
old
,
timer
]()
{
QString
old_ip
;
QString
old_ip
;
int
res
=
1
;
int
res
=
1
;
MainWindow
::
sp_this
->
findSnMapIp
(
this
->
sSn
,
old_ip
);
MainWindow
::
sp_this
->
findSnMapIp
(
this
->
sSn
,
old_ip
);
...
@@ -1109,13 +1106,7 @@ int CameraHandle::resetGb28181(QString &uuiq){
...
@@ -1109,13 +1106,7 @@ int CameraHandle::resetGb28181(QString &uuiq){
}
}
}
}
}
}
MainWindow
::
sp_this
->
mqttEmitAsynchronous
(
uuiq
,
res
,
device
.
sSn
);
timer
->
deleteLater
();
// 确保在任务完成后删除 QTimer
});
// 设置 QTimer 的超时时间为 5 秒
timer
->
setSingleShot
(
true
);
timer
->
start
(
5000
);
//this->updateSdkDevStatus(true);
//this->updateSdkDevStatus(true);
return
1
;
return
1
;
}
}
...
...
MqttSubscriber.cpp
View file @
07a92e1b
...
@@ -58,8 +58,6 @@ void MqttSubscriber::init(vides_data::MqttConfig &config, QString &httpUrl, QStr
...
@@ -58,8 +58,6 @@ void MqttSubscriber::init(vides_data::MqttConfig &config, QString &httpUrl, QStr
MqttSubscriber
::
MqttSubscriber
(
QObject
*
parent
)
MqttSubscriber
::
MqttSubscriber
(
QObject
*
parent
)
:
QObject
(
parent
),
retryTimer
(
new
QTimer
(
this
)),
client
(
nullptr
)
{
:
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
);
connect
(
this
,
&
MqttSubscriber
::
connectionLostSignal
,
this
,
&
MqttSubscriber
::
reconnectAndFetchConfig
,
Qt
::
QueuedConnection
);
...
@@ -107,9 +105,6 @@ void MqttSubscriber::start() {
...
@@ -107,9 +105,6 @@ void MqttSubscriber::start() {
qInfo
()
<<
"启动连接失败,返回编码"
<<
rc
;
qInfo
()
<<
"启动连接失败,返回编码"
<<
rc
;
}
}
}
}
void
MqttSubscriber
::
emitAsynchronous
(
QString
&
uniq
,
int
&
res
,
QString
&
sn
){
emit
asynchronousMqtt
(
uniq
,
res
,
sn
);
}
void
MqttSubscriber
::
onConnect
(
MQTTAsync_successData
*
response
)
{
void
MqttSubscriber
::
onConnect
(
MQTTAsync_successData
*
response
)
{
...
@@ -250,11 +245,6 @@ int MqttSubscriber::messageArrived(char* topicName, int topicLen, MQTTAsync_mess
...
@@ -250,11 +245,6 @@ int MqttSubscriber::messageArrived(char* topicName, int topicLen, MQTTAsync_mess
}
}
res
=
(
connectedCameraHandle
->
distributionNetwork
(
ipAddress
,
response
.
sn
,
hDevice
)
?
0x01
:-
1
);
res
=
(
connectedCameraHandle
->
distributionNetwork
(
ipAddress
,
response
.
sn
,
hDevice
)
?
0x01
:-
1
);
}
}
if
(
response
.
msg_type
==
8
)
{
qInfo
()
<<
"mqtt 复位GB28181 异步走卡槽函数触发"
;
return
-
1
;
}
vides_data
::
requestMqttData
request
;
vides_data
::
requestMqttData
request
;
request
.
code
=
(
res
>=
0
)
?
0
:
0x01
;
request
.
code
=
(
res
>=
0
)
?
0
:
0x01
;
request
.
msg
=
(
res
>=
0
)
?
"成功"
:
"失败"
;
request
.
msg
=
(
res
>=
0
)
?
"成功"
:
"失败"
;
...
@@ -265,14 +255,6 @@ int MqttSubscriber::messageArrived(char* topicName, int topicLen, MQTTAsync_mess
...
@@ -265,14 +255,6 @@ int MqttSubscriber::messageArrived(char* topicName, int topicLen, MQTTAsync_mess
MQTTAsync_free
(
topicName
);
MQTTAsync_free
(
topicName
);
return
1
;
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
)
{
void
MqttSubscriber
::
sendSubscriptionConfirmation
(
const
vides_data
::
requestMqttData
&
response
,
QString
&
sn
)
{
QString
responseTopic
=
"/thingshub/"
+
response
.
uniq
+
"/device/post"
;
QString
responseTopic
=
"/thingshub/"
+
response
.
uniq
+
"/device/post"
;
QByteArray
bResponseTopic
=
responseTopic
.
toUtf8
();
QByteArray
bResponseTopic
=
responseTopic
.
toUtf8
();
...
...
MqttSubscriber.h
View file @
07a92e1b
...
@@ -14,15 +14,12 @@ public:
...
@@ -14,15 +14,12 @@ public:
void
init
(
vides_data
::
MqttConfig
&
config
,
QString
&
httpUrl
,
QString
&
serialNumber
);
void
init
(
vides_data
::
MqttConfig
&
config
,
QString
&
httpUrl
,
QString
&
serialNumber
);
void
start
();
void
start
();
void
emitAsynchronous
(
QString
&
uniq
,
int
&
res
,
QString
&
sn
);
signals
:
signals
:
void
connectionLostSignal
();
void
connectionLostSignal
();
void
asynchronousMqtt
(
QString
&
uniq
,
int
&
res
,
QString
&
sn
);
private
slots
:
private
slots
:
void
reconnectAndFetchConfig
();
void
reconnectAndFetchConfig
();
void
asynchronousPush
(
QString
&
uniq
,
int
&
res
,
QString
&
sn
);
private
:
private
:
MqttSubscriber
(
QObject
*
parent
=
nullptr
);
MqttSubscriber
(
QObject
*
parent
=
nullptr
);
...
...
mainwindow.cpp
View file @
07a92e1b
...
@@ -133,12 +133,6 @@ MainWindow::MainWindow():isResetting(false)
...
@@ -133,12 +133,6 @@ MainWindow::MainWindow():isResetting(false)
this
->
mqttConfig
=
config
.
mqttConfig
;
this
->
mqttConfig
=
config
.
mqttConfig
;
runOrRebootMqtt
(
mqttConfig
,
httpurl
,
serialNumber
);
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
){
void
MainWindow
::
runOrRebootMqtt
(
vides_data
::
MqttConfig
&
mqtt_config
,
QString
&
httpUrl
,
QString
&
serialNumber
){
MqttSubscriber
*
subscriber
=
MqttSubscriber
::
getInstance
(
this
);
MqttSubscriber
*
subscriber
=
MqttSubscriber
::
getInstance
(
this
);
subscriber
->
init
(
mqtt_config
,
httpUrl
,
serialNumber
);
subscriber
->
init
(
mqtt_config
,
httpUrl
,
serialNumber
);
...
...
mainwindow.h
View file @
07a92e1b
...
@@ -50,8 +50,6 @@ public:
...
@@ -50,8 +50,6 @@ public:
static
MainWindow
*
sp_this
;
static
MainWindow
*
sp_this
;
void
mqttEmitAsynchronous
(
QString
&
uniq
,
int
&
res
,
QString
&
sn
);
CameraHandle
*
findHandle
(
QString
sn
);
CameraHandle
*
findHandle
(
QString
sn
);
void
modifySnMapIp
(
QString
&
sn
,
QString
&
ip
);
void
modifySnMapIp
(
QString
&
sn
,
QString
&
ip
);
...
...
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