From b09601777e73914d7ea4fcae9fa299491c9838c8 Mon Sep 17 00:00:00 2001 From: "chunmao.guo" Date: Thu, 3 Aug 2023 10:19:35 +0800 Subject: [PATCH] FIX: log device version for media connect Change-Id: I0eada63e3d8e25840a221263beac5a9104f43d0f --- src/slic3r/GUI/MediaFilePanel.cpp | 11 +++++++---- src/slic3r/GUI/MediaFilePanel.h | 1 + src/slic3r/GUI/MediaPlayCtrl.cpp | 17 ++++++++++++----- src/slic3r/GUI/MediaPlayCtrl.h | 1 + 4 files changed, 21 insertions(+), 9 deletions(-) diff --git a/src/slic3r/GUI/MediaFilePanel.cpp b/src/slic3r/GUI/MediaFilePanel.cpp index cd971cc81..28d1fad96 100644 --- a/src/slic3r/GUI/MediaFilePanel.cpp +++ b/src/slic3r/GUI/MediaFilePanel.cpp @@ -206,6 +206,7 @@ void MediaFilePanel::SetMachineObject(MachineObject* obj) m_lan_mode = obj->is_lan_mode_printer(); m_lan_ip = obj->dev_ip; m_lan_passwd = obj->get_access_code(); + m_dev_ver = obj->get_ota_version(); m_local_support = obj->has_local_file_proto(); m_remote_support = obj->has_remote_file_proto(); } else { @@ -213,6 +214,7 @@ void MediaFilePanel::SetMachineObject(MachineObject* obj) m_lan_mode = false; m_lan_ip.clear(); m_lan_passwd.clear(); + m_dev_ver.clear(); m_local_support = false; m_remote_support = false; } @@ -422,7 +424,8 @@ void MediaFilePanel::fetchUrl(boost::weak_ptr wfs) return; } if ((m_lan_mode || !m_remote_support) && m_local_support && !m_lan_ip.empty()) { - std::string url = "bambu:///local/" + m_lan_ip + ".?port=6000&user=" + m_lan_user + "&passwd=" + m_lan_passwd; + std::string url = "bambu:///local/" + m_lan_ip + ".?port=6000&user=" + m_lan_user + "&passwd=" + m_lan_passwd + + "&device=" + m_machine + "&dev_ver=" + m_dev_ver; fs->SetUrl(url); return; } @@ -439,13 +442,13 @@ void MediaFilePanel::fetchUrl(boost::weak_ptr wfs) NetworkAgent *agent = wxGetApp().getAgent(); if (agent) { agent->get_camera_url(m_machine, - [this, wfs](std::string url) { + [this, wfs, m = m_machine, v = m_dev_ver](std::string url) { BOOST_LOG_TRIVIAL(info) << "MediaFilePanel::fetchUrl: camera_url: " << url; - CallAfter([this, url, wfs] { + CallAfter([=] { boost::shared_ptr fs(wfs.lock()); if (!fs || fs != m_image_grid->GetFileSystem()) return; if (boost::algorithm::starts_with(url, "bambu:///")) { - fs->SetUrl(url); + fs->SetUrl(url + "&device=" + m + "&dev_ver=" + v); } else { m_image_grid->SetStatus(m_bmp_failed, wxString::Format(_L("Initialize failed (%s)!"), url.empty() ? _L("Network unreachable") : from_u8(url))); fs->SetUrl("3"); diff --git a/src/slic3r/GUI/MediaFilePanel.h b/src/slic3r/GUI/MediaFilePanel.h index 7e4e6451f..2edd13949 100644 --- a/src/slic3r/GUI/MediaFilePanel.h +++ b/src/slic3r/GUI/MediaFilePanel.h @@ -79,6 +79,7 @@ private: std::string m_lan_ip; std::string m_lan_user; std::string m_lan_passwd; + std::string m_dev_ver; bool m_supported = false; bool m_lan_mode = false; bool m_local_support = false; diff --git a/src/slic3r/GUI/MediaPlayCtrl.cpp b/src/slic3r/GUI/MediaPlayCtrl.cpp index 7f575a511..2372a03cb 100644 --- a/src/slic3r/GUI/MediaPlayCtrl.cpp +++ b/src/slic3r/GUI/MediaPlayCtrl.cpp @@ -83,6 +83,7 @@ void MediaPlayCtrl::SetMachineObject(MachineObject* obj) m_lan_proto = obj->get_local_camera_proto(); m_lan_ip = obj->dev_ip; m_lan_passwd = obj->get_access_code(); + m_dev_ver = obj->get_ota_version(); m_remote_support = obj->is_function_supported(PrinterFunction::FUNC_REMOTE_TUNNEL); m_device_busy = obj->is_camera_busy_off(); m_tutk_state = obj->tutk_state; @@ -92,6 +93,7 @@ void MediaPlayCtrl::SetMachineObject(MachineObject* obj) m_lan_proto = -1; m_lan_ip.clear(); m_lan_passwd.clear(); + m_dev_ver.clear(); m_tutk_state.clear(); m_remote_support = true; m_device_busy = false; @@ -156,11 +158,14 @@ void MediaPlayCtrl::Play() if (m_lan_proto > 0 && (m_lan_mode ||!m_remote_support) && !m_disable_lan && !m_lan_ip.empty()) { m_disable_lan = m_remote_support && !m_lan_mode; // try remote next time 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; + m_url = "bambu:///local/" + m_lan_ip + ".?port=6000&user=" + m_lan_user + "&passwd=" + m_lan_passwd; 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_url = "bambu:///rtsps___" + m_lan_user + ":" + m_lan_passwd + "@" + m_lan_ip + "/streaming/live/1?proto=rtsps"; else if (m_lan_proto == 3) - m_url = "bambu:///rtsp___" + m_lan_user + ":" + m_lan_passwd + "@" + m_lan_ip + "/streaming/live/1?device=" + m_machine + "&version=" + agent_version; + m_url = "bambu:///rtsp___" + m_lan_user + ":" + m_lan_passwd + "@" + m_lan_ip + "/streaming/live/1?proto=rtsp"; + m_url += "&device=" + m_machine; + m_url += "&version=" + agent_version; + m_url += "&dev_ver=" + m_dev_ver; BOOST_LOG_TRIVIAL(info) << "MediaPlayCtrl camera_url: " << m_url; m_last_state = MEDIASTATE_LOADING; SetStatus(_L("Loading...")); @@ -202,10 +207,11 @@ void MediaPlayCtrl::Play() SetStatus(_L("Initializing...")); if (agent) { - agent->get_camera_url(m_machine, [this, m = m_machine, v = agent_version](std::string url) { + agent->get_camera_url(m_machine, [this, m = m_machine, v = agent_version, dv = m_dev_ver](std::string url) { if (boost::algorithm::starts_with(url, "bambu:///")) { url += "&device=" + m; url += "&version=" + v; + url += "&dev_ver=" + dv; } BOOST_LOG_TRIVIAL(info) << "MediaPlayCtrl camera_url: " << url << ", machine: " << m_machine; CallAfter([this, m, url] { @@ -381,10 +387,11 @@ void MediaPlayCtrl::ToggleStream() } NetworkAgent *agent = wxGetApp().getAgent(); if (!agent) return; - agent->get_camera_url(m_machine, [this, m = m_machine, v = agent->get_version()](std::string url) { + agent->get_camera_url(m_machine, [this, m = m_machine, v = agent->get_version(), dv = m_dev_ver](std::string url) { if (boost::algorithm::starts_with(url, "bambu:///")) { url += "&device=" + m; url += "&version=" + v; + url += "&dev_ver=" + dv; } BOOST_LOG_TRIVIAL(info) << "camera_url: " << url; CallAfter([this, m, url] { diff --git a/src/slic3r/GUI/MediaPlayCtrl.h b/src/slic3r/GUI/MediaPlayCtrl.h index 14ab40af5..4117443f4 100644 --- a/src/slic3r/GUI/MediaPlayCtrl.h +++ b/src/slic3r/GUI/MediaPlayCtrl.h @@ -73,6 +73,7 @@ private: std::string m_lan_ip; std::string m_lan_user; std::string m_lan_passwd; + std::string m_dev_ver; std::string m_tutk_state; bool m_camera_exists = false; bool m_lan_mode = false;