ENH: printer compatible for tunnel protos

Change-Id: Ic409ad967da43ad696b75a6c97e90e1f70e7610d
This commit is contained in:
chunmao.guo 2023-05-12 08:45:28 +08:00 committed by Lane.Wei
parent d70a608921
commit 5a7aa74e62
6 changed files with 34 additions and 11 deletions

View file

@ -1367,6 +1367,7 @@ void MachineObject::parse_version_func()
{ {
auto ota_version = module_vers.find("ota"); auto ota_version = module_vers.find("ota");
auto esp32_version = module_vers.find("esp32"); auto esp32_version = module_vers.find("esp32");
auto rv1126_version = module_vers.find("rv1126");
if (printer_type == "BL-P001" || if (printer_type == "BL-P001" ||
printer_type == "BL-P002") { printer_type == "BL-P002") {
if (ota_version != module_vers.end()) { 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; local_use_ssl = ota_version->second.sw_ver.compare("01.03.01.04") >= 0;
} }
is_support_remote_tunnel = true; 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") { } else if (printer_type == "C11") {
if (firmware_type == PrinterFirmwareType::FIRMWARE_TYPE_ENGINEER) 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_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; 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()) { if (esp32_version != module_vers.end()) {
ams_support_auto_switch_filament_flag = esp32_version->second.sw_ver.compare("00.03.11.50") >= 0; 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; return false;
break; break;
case FUNC_LOCAL_TUNNEL: case FUNC_LOCAL_TUNNEL:
func_name = "FUNC_LOCAL_TUNNEL"; parse_version_func();
if (!local_camera_proto) return false;
break; break;
case FUNC_PRINT_WITHOUT_SD: case FUNC_PRINT_WITHOUT_SD:
func_name = "FUNC_PRINT_WITHOUT_SD"; func_name = "FUNC_PRINT_WITHOUT_SD";
@ -2332,6 +2338,12 @@ bool MachineObject::is_camera_busy_off()
return false; 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) int MachineObject::publish_json(std::string json_str, int qos)
{ {
if (is_lan_mode_printer()) { if (is_lan_mode_printer()) {

View file

@ -632,6 +632,7 @@ public:
std::string camera_resolution = ""; std::string camera_resolution = "";
bool xcam_first_layer_inspector { false }; bool xcam_first_layer_inspector { false };
int xcam_first_layer_hold_count = 0; int xcam_first_layer_hold_count = 0;
int local_camera_proto = 0;
bool is_support_remote_tunnel{false}; bool is_support_remote_tunnel{false};
bool xcam_ai_monitoring{ false }; bool xcam_ai_monitoring{ false };
@ -785,6 +786,7 @@ public:
std::vector<std::string> get_resolution_supported(); std::vector<std::string> get_resolution_supported();
bool is_support_print_with_timelapse(); bool is_support_print_with_timelapse();
bool is_camera_busy_off(); bool is_camera_busy_off();
int get_local_camera_proto();
/* Msg for display MsgFn */ /* Msg for display MsgFn */
typedef std::function<void(std::string topic, std::string payload)> MsgFn; typedef std::function<void(std::string topic, std::string payload)> MsgFn;

View file

@ -201,14 +201,16 @@ void MediaFilePanel::SetMachineObject(MachineObject* obj)
if (obj && obj->is_function_supported(PrinterFunction::FUNC_MEDIA_FILE)) { if (obj && obj->is_function_supported(PrinterFunction::FUNC_MEDIA_FILE)) {
m_supported = true; m_supported = true;
m_lan_mode = obj->is_lan_mode_printer(); 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_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); m_remote_support = obj->is_function_supported(PrinterFunction::FUNC_REMOTE_TUNNEL);
} else { } else {
m_supported = false; m_supported = false;
m_lan_mode = false; m_lan_mode = false;
m_lan_ip.clear(); m_lan_ip.clear();
m_lan_passwd.clear(); m_lan_passwd.clear();
m_local_support = false;
m_remote_support = false; m_remote_support = false;
} }
if (machine == m_machine) { if (machine == m_machine) {

View file

@ -78,15 +78,17 @@ void MediaPlayCtrl::SetMachineObject(MachineObject* obj)
{ {
std::string machine = obj ? obj->dev_id : ""; std::string machine = obj ? obj->dev_id : "";
if (obj && obj->is_function_supported(PrinterFunction::FUNC_CAMERA_VIDEO)) { if (obj && obj->is_function_supported(PrinterFunction::FUNC_CAMERA_VIDEO)) {
m_camera_exists = obj->has_ipcam; m_camera_exists = obj->has_ipcam;
m_lan_mode = obj->is_lan_mode_printer(); m_lan_mode = obj->is_lan_mode_printer();
m_lan_ip = obj->is_function_supported(PrinterFunction::FUNC_LOCAL_TUNNEL) ? obj->dev_ip : ""; m_lan_proto = obj->get_local_camera_proto();
m_lan_passwd = obj->is_function_supported(PrinterFunction::FUNC_LOCAL_TUNNEL) ? obj->get_access_code() : ""; 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_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 { } else {
m_camera_exists = false; m_camera_exists = false;
m_lan_mode = false; m_lan_mode = false;
m_lan_proto = 0;
m_lan_ip.clear(); m_lan_ip.clear();
m_lan_passwd.clear(); m_lan_passwd.clear();
m_remote_support = true; m_remote_support = true;
@ -150,9 +152,12 @@ void MediaPlayCtrl::Play()
NetworkAgent *agent = wxGetApp().getAgent(); NetworkAgent *agent = wxGetApp().getAgent();
std::string agent_version = agent ? agent->get_version() : ""; 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_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; m_last_state = MEDIASTATE_LOADING;
SetStatus(_L("Loading...")); SetStatus(_L("Loading..."));
if (wxGetApp().app_config->get("internal_developer_mode") == "true") { if (wxGetApp().app_config->get("internal_developer_mode") == "true") {
@ -188,7 +193,8 @@ void MediaPlayCtrl::Play()
: _L("Initialize failed (Not supported by printer)!")); : _L("Initialize failed (Not supported by printer)!"));
return; return;
} }
m_failed_code = 0;
if (agent) { 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](std::string url) {
if (boost::algorithm::starts_with(url, "bambu:///")) { if (boost::algorithm::starts_with(url, "bambu:///")) {

View file

@ -69,6 +69,7 @@ private:
wxMediaCtrl2 * m_media_ctrl; wxMediaCtrl2 * m_media_ctrl;
wxMediaState m_last_state = MEDIASTATE_IDLE; wxMediaState m_last_state = MEDIASTATE_IDLE;
std::string m_machine; std::string m_machine;
int m_lan_proto = 0;
std::string m_lan_ip; std::string m_lan_ip;
std::string m_lan_user; std::string m_lan_user;
std::string m_lan_passwd; std::string m_lan_passwd;

View file

@ -894,7 +894,7 @@ void PrinterFileSystem::SendChangedEvent(wxEventType type, size_t index, std::st
void PrinterFileSystem::DumpLog(void * thiz, int, tchar const *msg) 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<PrinterFileSystem*>(thiz)->Bambu_FreeLogMsg(msg); static_cast<PrinterFileSystem*>(thiz)->Bambu_FreeLogMsg(msg);
} }