NEW:Add request access code function from printer

JIRA: 4690
Change-Id: I18657629b714823fa5691901c5807bdaccf56000
This commit is contained in:
hu.wang 2023-10-16 15:45:23 +08:00 committed by Lane.Wei
parent 9c55209518
commit 82684b1d20
3 changed files with 26 additions and 1 deletions

View File

@ -1461,6 +1461,16 @@ int MachineObject::command_get_version(bool with_retry)
return this->publish_json(j.dump(), 1);
}
int MachineObject::command_get_access_code() {
BOOST_LOG_TRIVIAL(info) << "command_get_access_code";
json j;
j["system"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++);
j["system"]["command"] = "get_access_code";
return this->publish_json(j.dump());
}
int MachineObject::command_request_push_all(bool request_now)
{
auto curr_time = std::chrono::system_clock::now();
@ -2677,7 +2687,18 @@ int MachineObject::parse_json(std::string payload)
}
}
}
if (j_pre.contains("system")) {
if (j_pre["system"].contains("command")) {
if (j_pre["system"]["command"].get<std::string>() == "get_access_code") {
if (j_pre["system"].contains("access_code")) {
std::string access_code = j_pre["system"]["access_code"].get<std::string>();
if (!access_code.empty()) {
set_access_code(access_code);
}
}
}
}
}
if (!restored_json) {
j = j_pre;
}

View File

@ -791,6 +791,8 @@ public:
int command_pushing(std::string cmd);
int command_clean_print_error(std::string task_id, int print_error);
int command_set_printer_nozzle(std::string nozzle_type, float diameter);
int command_get_access_code();
/* command upgrade */
int command_upgrade_confirm();

View File

@ -1878,6 +1878,8 @@ void GUI_App::init_networking_callbacks()
obj->is_tunnel_mqtt = tunnel;
obj->command_request_push_all(true);
obj->command_get_version();
obj->erase_user_access_code();
obj->command_get_access_code();
GUI::wxGetApp().sidebar().load_ams_list(obj->dev_id, obj);
}
});