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
8a850c09
Commit
8a850c09
authored
Sep 09, 2024
by
“liusq”
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mqtt断线重连,配置修改重新创建连接01
parent
1716236d
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
3 deletions
+3
-3
MqttSubscriber.cpp
+2
-3
mainwindow.cpp
+1
-0
No files found.
MqttSubscriber.cpp
View file @
8a850c09
...
...
@@ -44,7 +44,7 @@ MqttSubscriber::~MqttSubscriber() {
MQTTAsync_destroy
(
&
client
);
instance
=
nullptr
;
}
s
void
MqttSubscriber
::
start
()
{
retryTimer
->
stop
();
// 确保每次开始连接前停止定时器
MQTTAsync_connectOptions
conn_opts
=
MQTTAsync_connectOptions_initializer
;
...
...
@@ -95,7 +95,6 @@ void MqttSubscriber::onConnect(MQTTAsync_successData* response) {
void
MqttSubscriber
::
reconnectAndFetchConfig
()
{
Common
&
instace
=
Common
::
getInstance
();
vides_data
::
responseConfig
re_config
;
// 使用 HttpService 从远程云端拉取配置
HttpService
httpService
(
httpUrl
);
// 替换为实际的远程URL
...
...
@@ -106,7 +105,7 @@ void MqttSubscriber::reconnectAndFetchConfig() {
QString
topic
=
QStringLiteral
(
"/thingshub/%1/device/reply"
).
arg
(
serialNumber
);
re_config
.
mqttConfig
.
topic
=
topic
;
this
->
config
=
re_config
.
mqttConfig
;
init
(
re_config
.
mqttConfig
,
httpUrl
,
serialNumber
);
this
->
init
(
re_config
.
mqttConfig
,
httpUrl
,
serialNumber
);
start
();
}
else
{
qInfo
()
<<
"配置拉取失败,等待10秒后重试"
;
...
...
mainwindow.cpp
View file @
8a850c09
...
...
@@ -129,6 +129,7 @@ MainWindow::MainWindow()
config
.
mqttConfig
.
clientId
=
serialNumber
;
QString
topic
=
QStringLiteral
(
"/thingshub/%1/device/reply"
).
arg
(
serialNumber
);
config
.
mqttConfig
.
topic
=
topic
;
this
->
mqttConfig
=
config
.
mqttConfig
;
runOrRebootMqtt
(
mqttConfig
,
httpurl
,
serialNumber
);
...
...
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