Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
pg_gps
Project
Project
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
957dd
pg_gps
Commits
fb77a91b
Commit
fb77a91b
authored
Sep 15, 2025
by
957dd
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature/mqtt_reboot_local' into 'master'
解决了重启bug See merge request
!5
parents
ed288022
669b9888
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
1 addition
and
7 deletions
+1
-7
main.cc.o
build/CMakeFiles/main.dir/src/main.cc.o
+0
-0
main
build/main
+0
-0
main.cc
src/main.cc
+1
-7
No files found.
build/CMakeFiles/main.dir/src/main.cc.o
View file @
fb77a91b
No preview for this file type
build/main
View file @
fb77a91b
No preview for this file type
src/main.cc
View file @
fb77a91b
...
...
@@ -118,6 +118,7 @@ std::shared_ptr<MqttTopicsHandler> mqtt_init_and_connect() {
[
weak_handler
=
std
::
weak_ptr
<
MqttTopicsHandler
>
(
handler
)](
const
std
::
string
&
topic
,
const
nlohmann
::
json
&
json
)
{
std
::
cout
<<
"收到来自指令主题 ["
<<
topic
<<
"] 的消息。"
<<
std
::
endl
;
try
{
if
(
json
.
value
(
"/head/message_type"
_json_pointer
,
0
)
==
2011
)
system
(
"sudo reboot"
);
if
(
json
.
value
(
"/head/message_type"
_json_pointer
,
0
)
!=
5000
)
return
;
auto
dev_id
=
json
.
at
(
"body"
).
at
(
"dev_id"
).
get
<
std
::
string
>
();
...
...
@@ -144,13 +145,6 @@ std::shared_ptr<MqttTopicsHandler> mqtt_init_and_connect() {
shared_handler
->
AddSubscription
(
data_topic
,
[](
const
std
::
string
&
sub_topic
,
const
nlohmann
::
json
&
sub_json
)
{
if
(
sub_json
.
contains
(
"head"
)
&&
sub_json
[
"head"
].
is_object
()
&&
sub_json
[
"head"
].
contains
(
"message_type"
)
&&
sub_json
[
"head"
][
"message_type"
].
is_number_integer
()
&&
sub_json
[
"head"
][
"message_type"
].
get
<
int
>
()
==
2011
){
system
(
"sudo reboot"
);
}
if
(
sub_json
.
contains
(
"head"
)
&&
sub_json
[
"head"
].
is_object
()
&&
sub_json
[
"head"
].
contains
(
"message_type"
)
&&
sub_json
[
"head"
][
"message_type"
].
is_number_integer
()
&&
...
...
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