Commit fb77a91b authored by 957dd's avatar 957dd

Merge branch 'feature/mqtt_reboot_local' into 'master'

解决了重启bug See merge request !5
parents ed288022 669b9888
No preview for this file type
......@@ -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() &&
......
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