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()); agent->track_update_property("dev_ota_version", m_machine_info->get_ota_version());
m_simplebook->SetSelection(0); 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->set_event_handle(this);
m_bind_job->start(); m_bind_job->start();
} }

View file

@ -3781,6 +3781,7 @@ void DeviceManager::on_machine_alive(std::string json_str)
std::string printer_signal = j["dev_signal"].get<std::string>(); std::string printer_signal = j["dev_signal"].get<std::string>();
std::string connect_type = j["connect_type"].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 bind_state = j["bind_state"].get<std::string>();
std::string sec_link = j["sec_link"].get<std::string>();
MachineObject* obj; MachineObject* obj;
@ -3789,6 +3790,7 @@ void DeviceManager::on_machine_alive(std::string json_str)
if (it != userMachineList.end()) { if (it != userMachineList.end()) {
it->second->dev_ip = dev_ip; it->second->dev_ip = dev_ip;
it->second->bind_state = bind_state; it->second->bind_state = bind_state;
it->second->bind_sec_link = sec_link;
} }
/* update localMachineList */ /* update localMachineList */
@ -3805,6 +3807,7 @@ void DeviceManager::on_machine_alive(std::string json_str)
obj->wifi_signal = printer_signal; obj->wifi_signal = printer_signal;
obj->dev_connection_type= connect_type; obj->dev_connection_type= connect_type;
obj->bind_state = bind_state; obj->bind_state = bind_state;
obj->bind_sec_link = sec_link;
obj->printer_type = MachineObject::parse_printer_type(printer_type_str); obj->printer_type = MachineObject::parse_printer_type(printer_type_str);
// U0 firmware // U0 firmware
@ -3827,6 +3830,7 @@ void DeviceManager::on_machine_alive(std::string json_str)
obj->wifi_signal = printer_signal; obj->wifi_signal = printer_signal;
obj->dev_connection_type = connect_type; obj->dev_connection_type = connect_type;
obj->bind_state = bind_state; obj->bind_state = bind_state;
obj->bind_sec_link = sec_link;
//load access code //load access code
AppConfig* config = Slic3r::GUI::wxGetApp().app_config; AppConfig* config = Slic3r::GUI::wxGetApp().app_config;

View file

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

View file

@ -32,10 +32,11 @@ wxString get_login_fail_reason(std::string fail_reason)
return _L("Unknown Failure"); 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}, : PlaterJob{std::move(pri), plater},
m_dev_id(dev_id), 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(); long offset = tz.GetOffset();
std::string timezone = get_timezone_utc_hm(offset); 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) { [this, &curr_percent, &msg](int stage, int code, std::string info) {
if (stage == BBL::BindJobStage::LoginStageConnect) { if (stage == BBL::BindJobStage::LoginStageConnect) {
curr_percent = 15; curr_percent = 15;

View file

@ -16,13 +16,14 @@ class BindJob : public PlaterJob
std::function<void()> m_success_fun{nullptr}; std::function<void()> m_success_fun{nullptr};
std::string m_dev_id; std::string m_dev_id;
std::string m_dev_ip; std::string m_dev_ip;
std::string m_sec_link;
bool m_job_finished{ false }; bool m_job_finished{ false };
int m_print_job_completed_id = 0; int m_print_job_completed_id = 0;
protected: protected:
void on_exception(const std::exception_ptr &) override; void on_exception(const std::exception_ptr &) override;
public: 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 int status_range() const override
{ {

View file

@ -799,11 +799,11 @@ std::string NetworkAgent::build_login_info()
return ret; return ret;
} }
int NetworkAgent::bind(std::string dev_ip, std::string dev_id, std::string timezone, OnUpdateStatusFn update_fn) int NetworkAgent::bind(std::string dev_ip, std::string dev_id, std::string sec_link, std::string timezone, OnUpdateStatusFn update_fn)
{ {
int ret = 0; int ret = 0;
if (network_agent && bind_ptr) { if (network_agent && bind_ptr) {
ret = bind_ptr(network_agent, dev_ip, dev_id, timezone, update_fn); ret = bind_ptr(network_agent, dev_ip, dev_id, sec_link, timezone, update_fn);
if (ret) if (ret)
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << boost::format(" error: network_agent=%1%, ret=%2%, dev_ip=%3%, timezone=%4%") BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << boost::format(" error: network_agent=%1%, ret=%2%, dev_ip=%3%, timezone=%4%")
%network_agent %ret %dev_ip %timezone; %network_agent %ret %dev_ip %timezone;

View file

@ -45,7 +45,7 @@ typedef std::string (*func_get_user_nickanme)(void *agent);
typedef std::string (*func_build_login_cmd)(void *agent); typedef std::string (*func_build_login_cmd)(void *agent);
typedef std::string (*func_build_logout_cmd)(void *agent); typedef std::string (*func_build_logout_cmd)(void *agent);
typedef std::string (*func_build_login_info)(void *agent); typedef std::string (*func_build_login_info)(void *agent);
typedef int (*func_bind)(void *agent, std::string dev_ip, std::string dev_id, std::string timezone, OnUpdateStatusFn update_fn); typedef int (*func_bind)(void *agent, std::string dev_ip, std::string dev_id, std::string sec_link, std::string timezone, OnUpdateStatusFn update_fn);
typedef int (*func_unbind)(void *agent, std::string dev_id); typedef int (*func_unbind)(void *agent, std::string dev_id);
typedef std::string (*func_get_bambulab_host)(void *agent); typedef std::string (*func_get_bambulab_host)(void *agent);
typedef std::string (*func_get_user_selected_machine)(void *agent); typedef std::string (*func_get_user_selected_machine)(void *agent);
@ -134,7 +134,7 @@ public:
std::string build_login_cmd(); std::string build_login_cmd();
std::string build_logout_cmd(); std::string build_logout_cmd();
std::string build_login_info(); std::string build_login_info();
int bind(std::string dev_ip, std::string dev_id, std::string timezone, OnUpdateStatusFn update_fn); int bind(std::string dev_ip, std::string dev_id, std::string sec_link, std::string timezone, OnUpdateStatusFn update_fn);
int unbind(std::string dev_id); int unbind(std::string dev_id);
std::string get_bambulab_host(); std::string get_bambulab_host();
std::string get_user_selected_machine(); std::string get_user_selected_machine();