From 5a7aa74e62804b8fad858ac2f0846064218e930b Mon Sep 17 00:00:00 2001 From: "chunmao.guo" Date: Fri, 12 May 2023 08:45:28 +0800 Subject: [PATCH] ENH: printer compatible for tunnel protos Change-Id: Ic409ad967da43ad696b75a6c97e90e1f70e7610d --- src/slic3r/GUI/DeviceManager.cpp | 14 ++++++++++++- src/slic3r/GUI/DeviceManager.hpp | 2 ++ src/slic3r/GUI/MediaFilePanel.cpp | 4 +++- src/slic3r/GUI/MediaPlayCtrl.cpp | 22 +++++++++++++------- src/slic3r/GUI/MediaPlayCtrl.h | 1 + src/slic3r/GUI/Printer/PrinterFileSystem.cpp | 2 +- 6 files changed, 34 insertions(+), 11 deletions(-) diff --git a/src/slic3r/GUI/DeviceManager.cpp b/src/slic3r/GUI/DeviceManager.cpp index 154ab8aae..37f92ddfe 100644 --- a/src/slic3r/GUI/DeviceManager.cpp +++ b/src/slic3r/GUI/DeviceManager.cpp @@ -1367,6 +1367,7 @@ void MachineObject::parse_version_func() { auto ota_version = module_vers.find("ota"); auto esp32_version = module_vers.find("esp32"); + auto rv1126_version = module_vers.find("rv1126"); if (printer_type == "BL-P001" || printer_type == "BL-P002") { if (ota_version != module_vers.end()) { @@ -1395,6 +1396,8 @@ void MachineObject::parse_version_func() local_use_ssl = ota_version->second.sw_ver.compare("01.03.01.04") >= 0; } is_support_remote_tunnel = true; + local_camera_proto = (ota_version->second.sw_ver.compare("01.03.01.04") >= 0 + || (rv1126_version != module_vers.end() && rv1126_version->second.sw_ver.compare("00.00.20.39") >= 0)) ? 2 : 0; } } else if (printer_type == "C11") { if (firmware_type == PrinterFirmwareType::FIRMWARE_TYPE_ENGINEER) @@ -1407,6 +1410,8 @@ void MachineObject::parse_version_func() is_support_send_to_sdcard = ota_version->second.sw_ver.compare("01.02.00.00") >= 0; is_support_remote_tunnel = ota_version->second.sw_ver.compare("01.02.99.00") >= 0; } + local_camera_proto = 1; + if (esp32_version != module_vers.end()) { ams_support_auto_switch_filament_flag = esp32_version->second.sw_ver.compare("00.03.11.50") >= 0; } @@ -2263,7 +2268,8 @@ bool MachineObject::is_function_supported(PrinterFunction func) return false; break; case FUNC_LOCAL_TUNNEL: - func_name = "FUNC_LOCAL_TUNNEL"; + parse_version_func(); + if (!local_camera_proto) return false; break; case FUNC_PRINT_WITHOUT_SD: func_name = "FUNC_PRINT_WITHOUT_SD"; @@ -2332,6 +2338,12 @@ bool MachineObject::is_camera_busy_off() return false; } +int MachineObject::get_local_camera_proto() +{ + if (!is_function_supported(PrinterFunction::FUNC_REMOTE_TUNNEL)) return 0; + return local_camera_proto; +} + int MachineObject::publish_json(std::string json_str, int qos) { if (is_lan_mode_printer()) { diff --git a/src/slic3r/GUI/DeviceManager.hpp b/src/slic3r/GUI/DeviceManager.hpp index 45a59b933..44b4c0152 100644 --- a/src/slic3r/GUI/DeviceManager.hpp +++ b/src/slic3r/GUI/DeviceManager.hpp @@ -632,6 +632,7 @@ public: std::string camera_resolution = ""; bool xcam_first_layer_inspector { false }; int xcam_first_layer_hold_count = 0; + int local_camera_proto = 0; bool is_support_remote_tunnel{false}; bool xcam_ai_monitoring{ false }; @@ -785,6 +786,7 @@ public: std::vector get_resolution_supported(); bool is_support_print_with_timelapse(); bool is_camera_busy_off(); + int get_local_camera_proto(); /* Msg for display MsgFn */ typedef std::function MsgFn; diff --git a/src/slic3r/GUI/MediaFilePanel.cpp b/src/slic3r/GUI/MediaFilePanel.cpp index a12044f4e..4a32fcfd0 100644 --- a/src/slic3r/GUI/MediaFilePanel.cpp +++ b/src/slic3r/GUI/MediaFilePanel.cpp @@ -201,14 +201,16 @@ void MediaFilePanel::SetMachineObject(MachineObject* obj) if (obj && obj->is_function_supported(PrinterFunction::FUNC_MEDIA_FILE)) { m_supported = true; m_lan_mode = obj->is_lan_mode_printer(); - m_lan_ip = obj->is_function_supported(PrinterFunction::FUNC_LOCAL_TUNNEL) ? obj->dev_ip : ""; + m_lan_ip = obj->dev_ip; m_lan_passwd = obj->get_access_code(); + m_local_support = obj->is_function_supported(PrinterFunction::FUNC_LOCAL_TUNNEL); m_remote_support = obj->is_function_supported(PrinterFunction::FUNC_REMOTE_TUNNEL); } else { m_supported = false; m_lan_mode = false; m_lan_ip.clear(); m_lan_passwd.clear(); + m_local_support = false; m_remote_support = false; } if (machine == m_machine) { diff --git a/src/slic3r/GUI/MediaPlayCtrl.cpp b/src/slic3r/GUI/MediaPlayCtrl.cpp index 723f844a8..b3d5647c2 100644 --- a/src/slic3r/GUI/MediaPlayCtrl.cpp +++ b/src/slic3r/GUI/MediaPlayCtrl.cpp @@ -78,15 +78,17 @@ void MediaPlayCtrl::SetMachineObject(MachineObject* obj) { std::string machine = obj ? obj->dev_id : ""; if (obj && obj->is_function_supported(PrinterFunction::FUNC_CAMERA_VIDEO)) { - m_camera_exists = obj->has_ipcam; - m_lan_mode = obj->is_lan_mode_printer(); - m_lan_ip = obj->is_function_supported(PrinterFunction::FUNC_LOCAL_TUNNEL) ? obj->dev_ip : ""; - m_lan_passwd = obj->is_function_supported(PrinterFunction::FUNC_LOCAL_TUNNEL) ? obj->get_access_code() : ""; + m_camera_exists = obj->has_ipcam; + m_lan_mode = obj->is_lan_mode_printer(); + m_lan_proto = obj->get_local_camera_proto(); + m_lan_ip = obj->dev_ip; + m_lan_passwd = obj->get_access_code(); m_remote_support = obj->is_function_supported(PrinterFunction::FUNC_REMOTE_TUNNEL); - m_device_busy = obj->is_camera_busy_off(); + m_device_busy = obj->is_camera_busy_off(); } else { m_camera_exists = false; m_lan_mode = false; + m_lan_proto = 0; m_lan_ip.clear(); m_lan_passwd.clear(); m_remote_support = true; @@ -150,9 +152,12 @@ void MediaPlayCtrl::Play() NetworkAgent *agent = wxGetApp().getAgent(); std::string agent_version = agent ? agent->get_version() : ""; - if (!m_disable_lan && !m_lan_ip.empty() && (!m_lan_mode || !m_lan_passwd.empty())) { + if (m_lan_proto && !m_disable_lan && !m_lan_ip.empty() && (!m_lan_mode || !m_lan_passwd.empty())) { m_disable_lan = m_remote_support && !m_lan_mode; // try remote next time - m_url = "bambu:///local/" + m_lan_ip + ".?port=6000&user=" + m_lan_user + "&passwd=" + m_lan_passwd + "&device=" + m_machine + "&version=" + agent_version; + if (m_lan_proto == 1) + m_url = "bambu:///local/" + m_lan_ip + ".?port=6000&user=" + m_lan_user + "&passwd=" + m_lan_passwd + "&device=" + m_machine + "&version=" + agent_version; + else if (m_lan_proto == 2) + m_url = "bambu:///rtsps___" + m_lan_user +":" + m_lan_passwd + "@" + m_lan_ip + "/streaming/live/1?device=" + m_machine + "&version=" + agent_version; m_last_state = MEDIASTATE_LOADING; SetStatus(_L("Loading...")); if (wxGetApp().app_config->get("internal_developer_mode") == "true") { @@ -188,7 +193,8 @@ void MediaPlayCtrl::Play() : _L("Initialize failed (Not supported by printer)!")); return; } - + + m_failed_code = 0; if (agent) { agent->get_camera_url(m_machine, [this, m = m_machine, v = agent_version](std::string url) { if (boost::algorithm::starts_with(url, "bambu:///")) { diff --git a/src/slic3r/GUI/MediaPlayCtrl.h b/src/slic3r/GUI/MediaPlayCtrl.h index 72034bcbd..3710e268a 100644 --- a/src/slic3r/GUI/MediaPlayCtrl.h +++ b/src/slic3r/GUI/MediaPlayCtrl.h @@ -69,6 +69,7 @@ private: wxMediaCtrl2 * m_media_ctrl; wxMediaState m_last_state = MEDIASTATE_IDLE; std::string m_machine; + int m_lan_proto = 0; std::string m_lan_ip; std::string m_lan_user; std::string m_lan_passwd; diff --git a/src/slic3r/GUI/Printer/PrinterFileSystem.cpp b/src/slic3r/GUI/Printer/PrinterFileSystem.cpp index 006f9ceec..829b0a262 100644 --- a/src/slic3r/GUI/Printer/PrinterFileSystem.cpp +++ b/src/slic3r/GUI/Printer/PrinterFileSystem.cpp @@ -894,7 +894,7 @@ void PrinterFileSystem::SendChangedEvent(wxEventType type, size_t index, std::st void PrinterFileSystem::DumpLog(void * thiz, int, tchar const *msg) { - BOOST_LOG_TRIVIAL(info) << "PrinterFileSystem: " << msg; + BOOST_LOG_TRIVIAL(info) << "PrinterFileSystem: " << wxString(msg).ToUTF8().data(); static_cast(thiz)->Bambu_FreeLogMsg(msg); }