FIX: log device version for media connect

Change-Id: I0eada63e3d8e25840a221263beac5a9104f43d0f
This commit is contained in:
chunmao.guo 2023-08-03 10:19:35 +08:00 committed by Lane.Wei
parent fb528c67b7
commit b09601777e
4 changed files with 21 additions and 9 deletions

View File

@ -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<PrinterFileSystem> 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<PrinterFileSystem> 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");

View File

@ -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;

View File

@ -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] {

View File

@ -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;