ENH: do not change ip when connection name is different

JIRA: STUDIO-4072

Change-Id: I6e72f894fa5eca91d5bbbfaca3e897be95c305e0
Signed-off-by: Stone Li <stone.li@bambulab.com>
This commit is contained in:
Stone Li 2023-08-25 09:10:14 +08:00 committed by Lane.Wei
parent 19ba3644ea
commit 5857025e8d
2 changed files with 9 additions and 1 deletions

View File

@ -4605,6 +4605,10 @@ void DeviceManager::on_machine_alive(std::string json_str)
if (j.contains("sec_link")) {
sec_link = j["sec_link"].get<std::string>();
}
std::string connection_name = "";
if (j.contains("connection_name")) {
connection_name = j["connection_name"].get<std::string>();
}
MachineObject* obj;
@ -4623,7 +4627,9 @@ void DeviceManager::on_machine_alive(std::string json_str)
// update properties
/* ip changed */
obj = it->second;
if (obj->dev_ip.compare(dev_ip) != 0 && !obj->dev_ip.empty()) {
if (obj->dev_ip.compare(dev_ip) != 0 && !obj->dev_ip.empty()
&& obj->dev_connection_name.compare(connection_name) != 0
) {
BOOST_LOG_TRIVIAL(info) << "MachineObject IP changed from " << obj->dev_ip << " to " << dev_ip;
obj->dev_ip = dev_ip;
/* ip changed reconnect mqtt */
@ -4655,6 +4661,7 @@ void DeviceManager::on_machine_alive(std::string json_str)
obj->dev_connection_type = connect_type;
obj->bind_state = bind_state;
obj->bind_sec_link = sec_link;
obj->dev_connection_name = connection_name;
//load access code
AppConfig* config = Slic3r::GUI::wxGetApp().app_config;

View File

@ -391,6 +391,7 @@ public:
float nozzle_diameter { 0.0f };
std::string dev_connection_type; /* lan | cloud */
std::string connection_type() { return dev_connection_type; }
std::string dev_connection_name; /* lan | eth */
void set_dev_ip(std::string ip) {dev_ip = ip;}
std::string get_ftp_folder();
bool has_access_right() { return !get_access_code().empty(); }