ENH: add sec_link field to start_bind

Change-Id: Ia48592f096b14ea0fe4de20126287c6f885d73a5
Signed-off-by: Stone Li <stone.li@bambulab.com>
This commit is contained in:
Stone Li 2023-03-16 10:26:32 +08:00 committed by Lane.Wei
parent e031708043
commit 1f1e5894bb
7 changed files with 21 additions and 14 deletions

View file

@ -268,7 +268,7 @@ namespace GUI {
agent->track_update_property("dev_ota_version", m_machine_info->get_ota_version());
m_simplebook->SetSelection(0);
m_bind_job = std::make_shared<BindJob>(m_status_bar, wxGetApp().plater(), m_machine_info->dev_id, m_machine_info->dev_ip);
m_bind_job = std::make_shared<BindJob>(m_status_bar, wxGetApp().plater(), m_machine_info->dev_id, m_machine_info->dev_ip, m_machine_info->bind_sec_link);
m_bind_job->set_event_handle(this);
m_bind_job->start();
}

View file

@ -3781,14 +3781,16 @@ void DeviceManager::on_machine_alive(std::string json_str)
std::string printer_signal = j["dev_signal"].get<std::string>();
std::string connect_type = j["connect_type"].get<std::string>();
std::string bind_state = j["bind_state"].get<std::string>();
std::string sec_link = j["sec_link"].get<std::string>();
MachineObject* obj;
/* update userMachineList info */
auto it = userMachineList.find(dev_id);
if (it != userMachineList.end()) {
it->second->dev_ip = dev_ip;
it->second->bind_state = bind_state;
it->second->dev_ip = dev_ip;
it->second->bind_state = bind_state;
it->second->bind_sec_link = sec_link;
}
/* update localMachineList */
@ -3802,9 +3804,10 @@ void DeviceManager::on_machine_alive(std::string json_str)
obj->dev_ip = dev_ip;
/* ip changed reconnect mqtt */
}
obj->wifi_signal = printer_signal;
obj->dev_connection_type = connect_type;
obj->bind_state = bind_state;
obj->wifi_signal = printer_signal;
obj->dev_connection_type= connect_type;
obj->bind_state = bind_state;
obj->bind_sec_link = sec_link;
obj->printer_type = MachineObject::parse_printer_type(printer_type_str);
// U0 firmware
@ -3827,6 +3830,7 @@ void DeviceManager::on_machine_alive(std::string json_str)
obj->wifi_signal = printer_signal;
obj->dev_connection_type = connect_type;
obj->bind_state = bind_state;
obj->bind_sec_link = sec_link;
//load access code
AppConfig* config = Slic3r::GUI::wxGetApp().app_config;

View file

@ -433,6 +433,7 @@ public:
std::string bind_user_name;
std::string bind_user_id;
std::string bind_state; /* free | occupied */
std::string bind_sec_link;
bool is_avaliable() { return bind_state == "free"; }
time_t last_alive;
bool m_is_online;

View file

@ -32,10 +32,11 @@ wxString get_login_fail_reason(std::string fail_reason)
return _L("Unknown Failure");
}
BindJob::BindJob(std::shared_ptr<ProgressIndicator> pri, Plater *plater, std::string dev_id, std::string dev_ip)
BindJob::BindJob(std::shared_ptr<ProgressIndicator> pri, Plater *plater, std::string dev_id, std::string dev_ip, std::string sec_link)
: PlaterJob{std::move(pri), plater},
m_dev_id(dev_id),
m_dev_ip(dev_ip)
m_dev_ip(dev_ip),
m_sec_link(sec_link)
{
;
}
@ -79,7 +80,7 @@ void BindJob::process()
long offset = tz.GetOffset();
std::string timezone = get_timezone_utc_hm(offset);
int result = m_agent->bind(m_dev_ip, m_dev_id, timezone,
int result = m_agent->bind(m_dev_ip, m_dev_id, m_sec_link, timezone,
[this, &curr_percent, &msg](int stage, int code, std::string info) {
if (stage == BBL::BindJobStage::LoginStageConnect) {
curr_percent = 15;

View file

@ -16,13 +16,14 @@ class BindJob : public PlaterJob
std::function<void()> m_success_fun{nullptr};
std::string m_dev_id;
std::string m_dev_ip;
std::string m_sec_link;
bool m_job_finished{ false };
int m_print_job_completed_id = 0;
protected:
void on_exception(const std::exception_ptr &) override;
public:
BindJob(std::shared_ptr<ProgressIndicator> pri, Plater *plater, std::string dev_id, std::string dev_ip);
BindJob(std::shared_ptr<ProgressIndicator> pri, Plater *plater, std::string dev_id, std::string dev_ip, std::string sec_link);
int status_range() const override
{