Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support bambulab's new security functions #8103

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions resources/printers/BL-P001.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
"resolution_supported": [ "720p", "1080p" ],
"virtual_camera": "enabled",
"liveview": {
"remote": "enabled"
"remote": "tutk"
},
"file": {
"remote": "enabled",
"remote": "tutk",
"model_download": "enabled"
}
},
Expand Down
4 changes: 2 additions & 2 deletions resources/printers/BL-P002.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
"resolution_supported": [ "720p", "1080p" ],
"virtual_camera": "enabled",
"liveview": {
"remote": "enabled"
"remote": "tutk"
},
"file": {
"remote": "enabled",
"remote": "tutk",
"model_download": "enabled"
}
},
Expand Down
4 changes: 2 additions & 2 deletions resources/printers/C11.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"print": {
"ipcam": {
"liveview": {
"remote": "enabled"
"remote": "tutk"
}
}
}
Expand All @@ -79,7 +79,7 @@
"print": {
"ipcam": {
"file": {
"remote": "enabled"
"remote": "tutk"
}
},
"support_user_preset":true
Expand Down
4 changes: 2 additions & 2 deletions resources/printers/C12.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"print": {
"ipcam": {
"liveview": {
"remote": "enabled"
"remote": "tutk"
}
},
"support_mqtt_alive":true,
Expand All @@ -71,7 +71,7 @@
"print": {
"ipcam": {
"file": {
"remote": "enabled"
"remote": "tutk"
}
},
"support_user_preset":true
Expand Down
4 changes: 2 additions & 2 deletions resources/printers/C13.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
"resolution_supported": [ "720p", "1080p" ],
"virtual_camera": "enabled",
"liveview": {
"remote": "enabled"
"remote": "tutk"
},
"file": {
"remote": "enabled",
"remote": "tutk",
"model_download": "enabled"
}
},
Expand Down
4 changes: 2 additions & 2 deletions resources/printers/N1.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"resolution_supported": [ "720p" ],
"liveview": {
"local": "local",
"remote": "enabled"
"remote": "tutk"
}
},
"support_motor_noise_cali":true,
Expand Down Expand Up @@ -53,7 +53,7 @@
"print": {
"ipcam": {
"file": {
"remote": "enabled"
"remote": "tutk"
}
},
"support_user_preset":true
Expand Down
4 changes: 2 additions & 2 deletions resources/printers/N2S.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"resolution_supported": [ "720p" ],
"liveview": {
"local": "local",
"remote": "enabled"
"remote": "tutk"
}
},
"support_motor_noise_cali":true,
Expand Down Expand Up @@ -53,7 +53,7 @@
"print": {
"ipcam": {
"file": {
"remote": "enabled"
"remote": "tutk"
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions src/libslic3r/PresetBundle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1983,6 +1983,11 @@ void PresetBundle::set_calibrate_printer(std::string name)
std::set<std::string> PresetBundle::get_printer_names_by_printer_type_and_nozzle(const std::string &printer_type, std::string nozzle_diameter_str)
{
std::set<std::string> printer_names;

/* unknown or empty printer type */
if (printer_type.empty())
return printer_names;

if ("0.0" == nozzle_diameter_str || nozzle_diameter_str.empty()) {
nozzle_diameter_str = "0.4";
}
Expand Down
51 changes: 37 additions & 14 deletions src/slic3r/GUI/DeviceManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1431,6 +1431,9 @@ void MachineObject::parse_status(int flag)
sdcard_state = MachineObject::SdcardState((flag >> 8) & 0x11);

network_wired = ((flag >> 18) & 0x1) != 0;
is_support_agora = ((flag >> 30) & 0x1) != 0;
if (is_support_agora)
is_support_tunnel_mqtt = false;
}

PrintingSpeedLevel MachineObject::_parse_printing_speed_lvl(int lvl)
Expand Down Expand Up @@ -2617,29 +2620,29 @@ bool MachineObject::is_camera_busy_off()
return false;
}

int MachineObject::publish_json(std::string json_str, int qos)
int MachineObject::publish_json(std::string json_str, int qos, int flag)
{
if (is_lan_mode_printer()) {
return local_publish_json(json_str, qos);
return local_publish_json(json_str, qos, flag);
} else {
return cloud_publish_json(json_str, qos);
return cloud_publish_json(json_str, qos, flag);
}
}

int MachineObject::cloud_publish_json(std::string json_str, int qos)
int MachineObject::cloud_publish_json(std::string json_str, int qos, int flag)
{
int result = -1;
if (m_agent)
result = m_agent->send_message(dev_id, json_str, qos);
result = m_agent->send_message(dev_id, json_str, qos, flag);

return result;
}

int MachineObject::local_publish_json(std::string json_str, int qos)
int MachineObject::local_publish_json(std::string json_str, int qos, int flag)
{
int result = -1;
if (m_agent) {
result = m_agent->send_message_to_printer(dev_id, json_str, qos);
result = m_agent->send_message_to_printer(dev_id, json_str, qos, flag);
}
return result;
}
Expand Down Expand Up @@ -2902,7 +2905,7 @@ int MachineObject::parse_json(std::string payload, bool key_field_only)
}

if (!key_field_only) {
if (!DeviceManager::EnableMultiMachine) {
if (!DeviceManager::EnableMultiMachine && !is_support_agora) {
if (jj.contains("support_tunnel_mqtt")) {
if (jj["support_tunnel_mqtt"].is_boolean()) {
is_support_tunnel_mqtt = jj["support_tunnel_mqtt"].get<bool>();
Expand Down Expand Up @@ -3687,11 +3690,18 @@ int MachineObject::parse_json(std::string payload, bool key_field_only)
if (ipcam.contains("liveview")) {
char const *local_protos[] = {"none", "disabled", "local", "rtsps", "rtsp"};
liveview_local = enum_index_of(ipcam["liveview"].value<std::string>("local", "none").c_str(), local_protos, 5, LiveviewLocal::LVL_None);
liveview_remote = ipcam["liveview"].value<std::string>("remote", "disabled") == "enabled";
char const *remote_protos[] = {"none", "tutk", "agora", "tutk_agaro"};
liveview_remote = enum_index_of(ipcam["liveview"].value<std::string>("remote", "none").c_str(), remote_protos, 4, LiveviewRemote::LVR_None);
if (is_support_agora)
liveview_remote = liveview_remote == LVR_None ? LVR_Agora : liveview_remote == LVR_Tutk ? LVR_TutkAgora : liveview_remote;
}
if (ipcam.contains("file")) {
file_local = ipcam["file"].value<std::string>("local", "disabled") == "enabled";
file_remote = ipcam["file"].value<std::string>("remote", "disabled") == "enabled";
char const *local_protos[] = {"none", "local"};
file_local = enum_index_of(ipcam["file"].value<std::string>("local", "none").c_str(), local_protos, 2, FileLocal::FL_None);
char const *remote_protos[] = {"none", "tutk", "agora", "tutk_agaro"};
file_remote = enum_index_of(ipcam["file"].value<std::string>("remote", "none").c_str(), remote_protos, 4, FileRemote::FR_None);
if (is_support_agora)
file_remote = file_remote == FR_None ? FR_Agora : file_remote == FR_Tutk ? FR_TutkAgora : file_remote;
file_model_download = ipcam["file"].value<std::string>("model_download", "disabled") == "enabled";
}
virtual_camera = ipcam.value<std::string>("virtual_camera", "disabled") == "enabled";
Expand Down Expand Up @@ -5265,8 +5275,6 @@ void DeviceManager::on_machine_alive(std::string json_str)
Slic3r::GUI::wxGetApp().app_config->set_str("ip_address", obj->dev_id, obj->dev_ip);
Slic3r::GUI::wxGetApp().app_config->save();
}*/


BOOST_LOG_TRIVIAL(info) << "SsdpDiscovery::New Machine, ip = " << Slic3r::GUI::wxGetApp().format_IP(dev_ip) << ", printer_name= " << dev_name << ", printer_type = " << printer_type_str << ", signal = " << printer_signal;
}
}
Expand All @@ -5275,6 +5283,21 @@ void DeviceManager::on_machine_alive(std::string json_str)
}
}

MachineObject* DeviceManager::insert_local_device(std::string dev_name, std::string dev_id, std::string dev_ip, std::string connection_type, std::string bind_state, std::string version, std::string access_code)
{
MachineObject* obj;
obj = new MachineObject(m_agent, dev_name, dev_id, dev_ip);
obj->printer_type = MachineObject::parse_printer_type("C11");
obj->dev_connection_type = connection_type;
obj->bind_state = bind_state;
obj->bind_sec_link = "secure";
obj->bind_ssdp_version = version;
obj->m_is_online = true;
obj->set_access_code(access_code, false);
obj->set_user_access_code(access_code, false);
return obj;
}

void DeviceManager::disconnect_all()
{

Expand Down Expand Up @@ -5458,13 +5481,13 @@ bool DeviceManager::set_selected_machine(std::string dev_id, bool need_disconnec
}
} else {
BOOST_LOG_TRIVIAL(info) << "static: set_selected_machine: same dev_id = empty";
m_agent->set_user_selected_machine("");
it->second->reset();
#if !BBL_RELEASE_TO_PUBLIC
it->second->connect(false, Slic3r::GUI::wxGetApp().app_config->get("enable_ssl_for_mqtt") == "true" ? true : false);
#else
it->second->connect(false, it->second->local_use_ssl_for_mqtt);
#endif
m_agent->set_user_selected_machine(dev_id);
it->second->set_lan_mode_connection_state(true);
}
}
Expand Down
29 changes: 22 additions & 7 deletions src/slic3r/GUI/DeviceManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -708,9 +708,22 @@ class MachineObject
LVL_Rtsps,
LVL_Rtsp
} liveview_local{ LVL_None };
bool liveview_remote{false};
bool file_local{false};
bool file_remote{false};
enum LiveviewRemote {
LVR_None,
LVR_Tutk,
LVR_Agora,
LVR_TutkAgora
} liveview_remote{ LVR_None };
enum FileLocal {
FL_None,
FL_Local
} file_local{ FL_None };
enum FileRemote {
FR_None,
FR_Tutk,
FR_Agora,
FR_TutkAgora
} file_remote{ FR_None };
bool file_model_download{false};
bool virtual_camera{false};

Expand Down Expand Up @@ -762,6 +775,8 @@ class MachineObject
bool is_support_p1s_plus{false};
bool is_support_nozzle_blob_detection{false};
bool is_support_air_print_detection{false};
bool is_support_filament_setting_inprinting{false};
bool is_support_agora{false};

int nozzle_max_temperature = -1;
int bed_temperature_limit = -1;
Expand Down Expand Up @@ -940,9 +955,9 @@ class MachineObject

/* Msg for display MsgFn */
typedef std::function<void(std::string topic, std::string payload)> MsgFn;
int publish_json(std::string json_str, int qos = 0);
int cloud_publish_json(std::string json_str, int qos = 0);
int local_publish_json(std::string json_str, int qos = 0);
int publish_json(std::string json_str, int qos = 0, int flag = 0);
int cloud_publish_json(std::string json_str, int qos = 0, int flag = 0);
int local_publish_json(std::string json_str, int qos = 0, int flag = 0);
int parse_json(std::string payload, bool key_filed_only = false);
int publish_gcode(std::string gcode_str);

Expand Down Expand Up @@ -1006,7 +1021,7 @@ class DeviceManager

/* create machine or update machine properties */
void on_machine_alive(std::string json_str);

MachineObject* insert_local_device(std::string dev_name, std::string dev_id, std::string dev_ip, std::string connection_type, std::string bind_state, std::string version, std::string access_code);
/* disconnect all machine connections */
void disconnect_all();
int query_bind_status(std::string &msg);
Expand Down
1 change: 1 addition & 0 deletions src/slic3r/GUI/GLToolbar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ wxDEFINE_EVENT(EVT_GLTOOLBAR_PRINT_SELECT, SimpleEvent);
wxDEFINE_EVENT(EVT_GLTOOLBAR_SEND_TO_PRINTER, SimpleEvent);
wxDEFINE_EVENT(EVT_GLTOOLBAR_SEND_TO_PRINTER_ALL, SimpleEvent);
wxDEFINE_EVENT(EVT_GLTOOLBAR_PRINT_MULTI_MACHINE, SimpleEvent);
wxDEFINE_EVENT(EVT_GLTOOLBAR_SEND_BAMBU_CONNECT, SimpleEvent);


wxDEFINE_EVENT(EVT_GLTOOLBAR_ADD, SimpleEvent);
Expand Down
1 change: 1 addition & 0 deletions src/slic3r/GUI/GLToolbar.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ wxDECLARE_EVENT(EVT_GLTOOLBAR_PRINT_SELECT, SimpleEvent);
wxDECLARE_EVENT(EVT_GLTOOLBAR_SEND_TO_PRINTER, SimpleEvent);
wxDECLARE_EVENT(EVT_GLTOOLBAR_SEND_TO_PRINTER_ALL, SimpleEvent);
wxDECLARE_EVENT(EVT_GLTOOLBAR_PRINT_MULTI_MACHINE, SimpleEvent);
wxDECLARE_EVENT(EVT_GLTOOLBAR_SEND_BAMBU_CONNECT, SimpleEvent);


wxDECLARE_EVENT(EVT_GLTOOLBAR_ADD, SimpleEvent);
Expand Down
Loading
Loading