Support both old and new version of BBL network plugin

This commit is contained in:
Noisyfox
2025-04-26 17:44:04 +08:00
parent 440d44340d
commit aef4dba512
7 changed files with 205 additions and 28 deletions

View File

@@ -2623,29 +2623,38 @@ 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)
{
int rtn = 0;
if (is_lan_mode_printer()) {
return local_publish_json(json_str, qos);
rtn = local_publish_json(json_str, qos, flag);
} else {
return cloud_publish_json(json_str, qos);
rtn = cloud_publish_json(json_str, qos, flag);
}
if (rtn == 0) {
BOOST_LOG_TRIVIAL(info) << "publish_json: " << json_str << " code: " << rtn;
} else {
BOOST_LOG_TRIVIAL(error) << "publish_json: " << json_str << " code: " << rtn;
}
return rtn;
}
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;
}

View File

@@ -958,9 +958,9 @@ public:
/* 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);

View File

@@ -1166,7 +1166,7 @@ std::string GUI_App::get_plugin_url(std::string name, std::string country_code)
{
std::string url = get_http_url(country_code);
std::string curr_version = SLIC3R_VERSION;
std::string curr_version = NetworkAgent::use_legacy_network ? BAMBU_NETWORK_AGENT_VERSION_LEGACY : BAMBU_NETWORK_AGENT_VERSION;
std::string using_version = curr_version.substr(0, 9) + "00";
if (name == "cameratools")
using_version = curr_version.substr(0, 6) + "00.00";
@@ -1542,7 +1542,7 @@ bool GUI_App::check_networking_version()
if (!network_ver.empty()) {
BOOST_LOG_TRIVIAL(info) << "get_network_agent_version=" << network_ver;
}
std::string studio_ver = SLIC3R_VERSION;
std::string studio_ver = NetworkAgent::use_legacy_network ? BAMBU_NETWORK_AGENT_VERSION_LEGACY : BAMBU_NETWORK_AGENT_VERSION;
if (network_ver.length() >= 8) {
if (network_ver.substr(0,8) == studio_ver.substr(0,8)) {
m_networking_compatible = true;