NEW: install cert for printer
JIRA: STUDIO-7808 Change-Id: Ieba4db18a2735c6f301ac13ac5b89a4937f379f2 Signed-off-by: Stone Li <stone.li@bambulab.com>
This commit is contained in:
parent
f774fda6e6
commit
d9ead02cfa
|
@ -2672,29 +2672,29 @@ bool MachineObject::is_camera_busy_off()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int MachineObject::publish_json(std::string json_str, int qos)
|
int MachineObject::publish_json(std::string json_str, int qos, int flag)
|
||||||
{
|
{
|
||||||
if (is_lan_mode_printer()) {
|
if (is_lan_mode_printer()) {
|
||||||
return local_publish_json(json_str, qos);
|
return local_publish_json(json_str, qos, flag);
|
||||||
} else {
|
} else {
|
||||||
return cloud_publish_json(json_str, qos);
|
return cloud_publish_json(json_str, qos, flag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
int result = -1;
|
||||||
if (m_agent)
|
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;
|
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;
|
int result = -1;
|
||||||
if (m_agent) {
|
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;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -4923,7 +4923,7 @@ int MachineObject::publish_gcode(std::string gcode_str)
|
||||||
t["gcode"] = j.dump();
|
t["gcode"] = j.dump();
|
||||||
m_agent->track_event("cmd_gcode_line", t.dump());
|
m_agent->track_event("cmd_gcode_line", t.dump());
|
||||||
}
|
}
|
||||||
return publish_json(j.dump());
|
return publish_json(j.dump(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
BBLSubTask* MachineObject::get_subtask()
|
BBLSubTask* MachineObject::get_subtask()
|
||||||
|
@ -5719,13 +5719,13 @@ bool DeviceManager::set_selected_machine(std::string dev_id, bool need_disconnec
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
BOOST_LOG_TRIVIAL(info) << "static: set_selected_machine: same dev_id = empty";
|
BOOST_LOG_TRIVIAL(info) << "static: set_selected_machine: same dev_id = empty";
|
||||||
m_agent->set_user_selected_machine("");
|
|
||||||
it->second->reset();
|
it->second->reset();
|
||||||
#if !BBL_RELEASE_TO_PUBLIC
|
#if !BBL_RELEASE_TO_PUBLIC
|
||||||
it->second->connect(false, Slic3r::GUI::wxGetApp().app_config->get("enable_ssl_for_mqtt") == "true" ? true : false);
|
it->second->connect(false, Slic3r::GUI::wxGetApp().app_config->get("enable_ssl_for_mqtt") == "true" ? true : false);
|
||||||
#else
|
#else
|
||||||
it->second->connect(false, it->second->local_use_ssl_for_mqtt);
|
it->second->connect(false, it->second->local_use_ssl_for_mqtt);
|
||||||
#endif
|
#endif
|
||||||
|
m_agent->set_user_selected_machine(dev_id);
|
||||||
it->second->set_lan_mode_connection_state(true);
|
it->second->set_lan_mode_connection_state(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -957,9 +957,9 @@ public:
|
||||||
|
|
||||||
/* 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;
|
||||||
int 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 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 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 parse_json(std::string payload, bool key_filed_only = false);
|
||||||
int publish_gcode(std::string gcode_str);
|
int publish_gcode(std::string gcode_str);
|
||||||
|
|
||||||
|
|
|
@ -1311,6 +1311,8 @@ void GUI_App::post_init()
|
||||||
|
|
||||||
this->check_track_enable();
|
this->check_track_enable();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this->check_cert();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4761,6 +4763,15 @@ void GUI_App::check_beta_version()
|
||||||
}).perform();
|
}).perform();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GUI_App::check_cert()
|
||||||
|
{
|
||||||
|
m_check_cert_thread = Slic3r::create_thread(
|
||||||
|
[this]{
|
||||||
|
if (m_agent)
|
||||||
|
m_agent->check_cert();
|
||||||
|
});
|
||||||
|
BOOST_LOG_TRIVIAL(info) << "check_cert";
|
||||||
|
}
|
||||||
|
|
||||||
//BBS pop up a dialog and download files
|
//BBS pop up a dialog and download files
|
||||||
void GUI_App::request_new_version(int by_user)
|
void GUI_App::request_new_version(int by_user)
|
||||||
|
|
|
@ -308,7 +308,7 @@ private:
|
||||||
wxString m_info_dialog_content;
|
wxString m_info_dialog_content;
|
||||||
HttpServer m_http_server;
|
HttpServer m_http_server;
|
||||||
|
|
||||||
boost::thread m_check_network_thread;
|
boost::thread m_check_cert_thread;
|
||||||
public:
|
public:
|
||||||
//try again when subscription fails
|
//try again when subscription fails
|
||||||
void on_start_subscribe_again(std::string dev_id);
|
void on_start_subscribe_again(std::string dev_id);
|
||||||
|
@ -458,6 +458,7 @@ public:
|
||||||
void check_update(bool show_tips, int by_user);
|
void check_update(bool show_tips, int by_user);
|
||||||
void check_new_version(bool show_tips = false, int by_user = 0);
|
void check_new_version(bool show_tips = false, int by_user = 0);
|
||||||
void check_beta_version();
|
void check_beta_version();
|
||||||
|
void check_cert();
|
||||||
void request_new_version(int by_user);
|
void request_new_version(int by_user);
|
||||||
void enter_force_upgrade();
|
void enter_force_upgrade();
|
||||||
void set_skip_version(bool skip = true);
|
void set_skip_version(bool skip = true);
|
||||||
|
|
|
@ -375,6 +375,8 @@ void MonitorPanel::update_all()
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (obj)
|
||||||
|
m_agent->install_device_cert(obj->dev_id, obj->is_lan_mode_printer());
|
||||||
|
|
||||||
if (obj) {
|
if (obj) {
|
||||||
wxGetApp().reset_to_active();
|
wxGetApp().reset_to_active();
|
||||||
|
|
|
@ -3399,6 +3399,7 @@ void SelectMachineDialog::update_show_status()
|
||||||
}
|
}
|
||||||
if (!dev) return;
|
if (!dev) return;
|
||||||
dev->check_pushing();
|
dev->check_pushing();
|
||||||
|
|
||||||
PartPlate* plate = m_plater->get_partplate_list().get_curr_plate();
|
PartPlate* plate = m_plater->get_partplate_list().get_curr_plate();
|
||||||
|
|
||||||
// blank plate has no valid gcode file
|
// blank plate has no valid gcode file
|
||||||
|
@ -3421,6 +3422,7 @@ void SelectMachineDialog::update_show_status()
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
agent->install_device_cert(obj_->dev_id, obj_->is_lan_mode_printer());
|
||||||
|
|
||||||
/* check cloud machine connections */
|
/* check cloud machine connections */
|
||||||
if (!obj_->is_lan_mode_printer()) {
|
if (!obj_->is_lan_mode_printer()) {
|
||||||
|
|
|
@ -62,6 +62,8 @@ func_send_message NetworkAgent::send_message_ptr = nullptr;
|
||||||
func_connect_printer NetworkAgent::connect_printer_ptr = nullptr;
|
func_connect_printer NetworkAgent::connect_printer_ptr = nullptr;
|
||||||
func_disconnect_printer NetworkAgent::disconnect_printer_ptr = nullptr;
|
func_disconnect_printer NetworkAgent::disconnect_printer_ptr = nullptr;
|
||||||
func_send_message_to_printer NetworkAgent::send_message_to_printer_ptr = nullptr;
|
func_send_message_to_printer NetworkAgent::send_message_to_printer_ptr = nullptr;
|
||||||
|
func_check_cert NetworkAgent::check_cert_ptr = nullptr;
|
||||||
|
func_install_device_cert NetworkAgent::install_device_cert_ptr = nullptr;
|
||||||
func_start_discovery NetworkAgent::start_discovery_ptr = nullptr;
|
func_start_discovery NetworkAgent::start_discovery_ptr = nullptr;
|
||||||
func_change_user NetworkAgent::change_user_ptr = nullptr;
|
func_change_user NetworkAgent::change_user_ptr = nullptr;
|
||||||
func_is_user_login NetworkAgent::is_user_login_ptr = nullptr;
|
func_is_user_login NetworkAgent::is_user_login_ptr = nullptr;
|
||||||
|
@ -274,6 +276,8 @@ int NetworkAgent::initialize_network_module(bool using_backup)
|
||||||
connect_printer_ptr = reinterpret_cast<func_connect_printer>(get_network_function("bambu_network_connect_printer"));
|
connect_printer_ptr = reinterpret_cast<func_connect_printer>(get_network_function("bambu_network_connect_printer"));
|
||||||
disconnect_printer_ptr = reinterpret_cast<func_disconnect_printer>(get_network_function("bambu_network_disconnect_printer"));
|
disconnect_printer_ptr = reinterpret_cast<func_disconnect_printer>(get_network_function("bambu_network_disconnect_printer"));
|
||||||
send_message_to_printer_ptr = reinterpret_cast<func_send_message_to_printer>(get_network_function("bambu_network_send_message_to_printer"));
|
send_message_to_printer_ptr = reinterpret_cast<func_send_message_to_printer>(get_network_function("bambu_network_send_message_to_printer"));
|
||||||
|
check_cert_ptr = reinterpret_cast<func_check_cert>(get_network_function("bambu_network_update_cert"));
|
||||||
|
install_device_cert_ptr = reinterpret_cast<func_install_device_cert>(get_network_function("bambu_network_install_device_cert"));
|
||||||
start_discovery_ptr = reinterpret_cast<func_start_discovery>(get_network_function("bambu_network_start_discovery"));
|
start_discovery_ptr = reinterpret_cast<func_start_discovery>(get_network_function("bambu_network_start_discovery"));
|
||||||
change_user_ptr = reinterpret_cast<func_change_user>(get_network_function("bambu_network_change_user"));
|
change_user_ptr = reinterpret_cast<func_change_user>(get_network_function("bambu_network_change_user"));
|
||||||
is_user_login_ptr = reinterpret_cast<func_is_user_login>(get_network_function("bambu_network_is_user_login"));
|
is_user_login_ptr = reinterpret_cast<func_is_user_login>(get_network_function("bambu_network_is_user_login"));
|
||||||
|
@ -398,6 +402,7 @@ int NetworkAgent::unload_network_module()
|
||||||
connect_printer_ptr = nullptr;
|
connect_printer_ptr = nullptr;
|
||||||
disconnect_printer_ptr = nullptr;
|
disconnect_printer_ptr = nullptr;
|
||||||
send_message_to_printer_ptr = nullptr;
|
send_message_to_printer_ptr = nullptr;
|
||||||
|
check_cert_ptr = nullptr;
|
||||||
start_discovery_ptr = nullptr;
|
start_discovery_ptr = nullptr;
|
||||||
change_user_ptr = nullptr;
|
change_user_ptr = nullptr;
|
||||||
is_user_login_ptr = nullptr;
|
is_user_login_ptr = nullptr;
|
||||||
|
@ -853,11 +858,11 @@ int NetworkAgent::stop_device_subscribe()
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int NetworkAgent::send_message(std::string dev_id, std::string json_str, int qos)
|
int NetworkAgent::send_message(std::string dev_id, std::string json_str, int qos, int flag)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
if (network_agent && send_message_ptr) {
|
if (network_agent && send_message_ptr) {
|
||||||
ret = send_message_ptr(network_agent, dev_id, json_str, qos);
|
ret = send_message_ptr(network_agent, dev_id, json_str, qos, flag);
|
||||||
if (ret)
|
if (ret)
|
||||||
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << boost::format(" error: network_agent=%1%, ret=%2%, dev_id=%3%, json_str=%4%, qos=%5%")%network_agent %ret %dev_id %json_str %qos;
|
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << boost::format(" error: network_agent=%1%, ret=%2%, dev_id=%3%, json_str=%4%, qos=%5%")%network_agent %ret %dev_id %json_str %qos;
|
||||||
}
|
}
|
||||||
|
@ -887,11 +892,11 @@ int NetworkAgent::disconnect_printer()
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int NetworkAgent::send_message_to_printer(std::string dev_id, std::string json_str, int qos)
|
int NetworkAgent::send_message_to_printer(std::string dev_id, std::string json_str, int qos, int flag)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
if (network_agent && send_message_to_printer_ptr) {
|
if (network_agent && send_message_to_printer_ptr) {
|
||||||
ret = send_message_to_printer_ptr(network_agent, dev_id, json_str, qos);
|
ret = send_message_to_printer_ptr(network_agent, dev_id, json_str, qos, flag);
|
||||||
if (ret)
|
if (ret)
|
||||||
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << boost::format(" error: network_agent=%1%, ret=%2%, dev_id=%3%, json_str=%4%, qos=%5%")
|
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << boost::format(" error: network_agent=%1%, ret=%2%, dev_id=%3%, json_str=%4%, qos=%5%")
|
||||||
%network_agent %ret %dev_id %json_str %qos;
|
%network_agent %ret %dev_id %json_str %qos;
|
||||||
|
@ -899,6 +904,24 @@ int NetworkAgent::send_message_to_printer(std::string dev_id, std::string json_s
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int NetworkAgent::check_cert()
|
||||||
|
{
|
||||||
|
int ret = 0;
|
||||||
|
if (network_agent && check_cert_ptr) {
|
||||||
|
ret = check_cert_ptr(network_agent);
|
||||||
|
if (ret)
|
||||||
|
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << boost::format(" error: network_agent=%1%, ret=%2%") % network_agent % ret;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
void NetworkAgent::install_device_cert(std::string dev_id, bool lan_only)
|
||||||
|
{
|
||||||
|
if (network_agent && install_device_cert_ptr) {
|
||||||
|
install_device_cert_ptr(network_agent, dev_id, lan_only);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool NetworkAgent::start_discovery(bool start, bool sending)
|
bool NetworkAgent::start_discovery(bool start, bool sending)
|
||||||
{
|
{
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
|
|
|
@ -38,10 +38,12 @@ typedef int (*func_del_subscribe)(void *agent, std::vector<std::string> dev_list
|
||||||
typedef void (*func_enable_multi_machine)(void *agent, bool enable);
|
typedef void (*func_enable_multi_machine)(void *agent, bool enable);
|
||||||
typedef int (*func_start_device_subscribe)(void* agent);
|
typedef int (*func_start_device_subscribe)(void* agent);
|
||||||
typedef int (*func_stop_device_subscribe)(void* agent);
|
typedef int (*func_stop_device_subscribe)(void* agent);
|
||||||
typedef int (*func_send_message)(void *agent, std::string dev_id, std::string json_str, int qos);
|
typedef int (*func_send_message)(void *agent, std::string dev_id, std::string json_str, int qos, int flag);
|
||||||
typedef int (*func_connect_printer)(void *agent, std::string dev_id, std::string dev_ip, std::string username, std::string password, bool use_ssl);
|
typedef int (*func_connect_printer)(void *agent, std::string dev_id, std::string dev_ip, std::string username, std::string password, bool use_ssl);
|
||||||
typedef int (*func_disconnect_printer)(void *agent);
|
typedef int (*func_disconnect_printer)(void *agent);
|
||||||
typedef int (*func_send_message_to_printer)(void *agent, std::string dev_id, std::string json_str, int qos);
|
typedef int (*func_send_message_to_printer)(void *agent, std::string dev_id, std::string json_str, int qos, int flag);
|
||||||
|
typedef int (*func_check_cert)(void* agent);
|
||||||
|
typedef void (*func_install_device_cert)(void* agent, std::string dev_id, bool lan_only);
|
||||||
typedef bool (*func_start_discovery)(void *agent, bool start, bool sending);
|
typedef bool (*func_start_discovery)(void *agent, bool start, bool sending);
|
||||||
typedef int (*func_change_user)(void *agent, std::string user_info);
|
typedef int (*func_change_user)(void *agent, std::string user_info);
|
||||||
typedef bool (*func_is_user_login)(void *agent);
|
typedef bool (*func_is_user_login)(void *agent);
|
||||||
|
@ -112,6 +114,7 @@ typedef int (*func_get_model_mall_rating_result)(void *agent, int job_id, std::s
|
||||||
typedef int (*func_get_mw_user_preference)(void *agent, std::function<void(std::string)> callback);
|
typedef int (*func_get_mw_user_preference)(void *agent, std::function<void(std::string)> callback);
|
||||||
typedef int (*func_get_mw_user_4ulist)(void *agent, int seed, int limit, std::function<void(std::string)> callback);
|
typedef int (*func_get_mw_user_4ulist)(void *agent, int seed, int limit, std::function<void(std::string)> callback);
|
||||||
|
|
||||||
|
|
||||||
//the NetworkAgent class
|
//the NetworkAgent class
|
||||||
class NetworkAgent
|
class NetworkAgent
|
||||||
{
|
{
|
||||||
|
@ -157,10 +160,12 @@ public:
|
||||||
void enable_multi_machine(bool enable);
|
void enable_multi_machine(bool enable);
|
||||||
int start_device_subscribe();
|
int start_device_subscribe();
|
||||||
int stop_device_subscribe();
|
int stop_device_subscribe();
|
||||||
int send_message(std::string dev_id, std::string json_str, int qos);
|
int send_message(std::string dev_id, std::string json_str, int qos, int flag);
|
||||||
int connect_printer(std::string dev_id, std::string dev_ip, std::string username, std::string password, bool use_ssl);
|
int connect_printer(std::string dev_id, std::string dev_ip, std::string username, std::string password, bool use_ssl);
|
||||||
int disconnect_printer();
|
int disconnect_printer();
|
||||||
int send_message_to_printer(std::string dev_id, std::string json_str, int qos);
|
int send_message_to_printer(std::string dev_id, std::string json_str, int qos, int flag);
|
||||||
|
int check_cert();
|
||||||
|
void install_device_cert(std::string dev_id, bool lan_only);
|
||||||
bool start_discovery(bool start, bool sending);
|
bool start_discovery(bool start, bool sending);
|
||||||
int change_user(std::string user_info);
|
int change_user(std::string user_info);
|
||||||
bool is_user_login();
|
bool is_user_login();
|
||||||
|
@ -270,6 +275,8 @@ private:
|
||||||
static func_connect_printer connect_printer_ptr;
|
static func_connect_printer connect_printer_ptr;
|
||||||
static func_disconnect_printer disconnect_printer_ptr;
|
static func_disconnect_printer disconnect_printer_ptr;
|
||||||
static func_send_message_to_printer send_message_to_printer_ptr;
|
static func_send_message_to_printer send_message_to_printer_ptr;
|
||||||
|
static func_check_cert check_cert_ptr;
|
||||||
|
static func_install_device_cert install_device_cert_ptr;
|
||||||
static func_start_discovery start_discovery_ptr;
|
static func_start_discovery start_discovery_ptr;
|
||||||
static func_change_user change_user_ptr;
|
static func_change_user change_user_ptr;
|
||||||
static func_is_user_login is_user_login_ptr;
|
static func_is_user_login is_user_login_ptr;
|
||||||
|
|
|
@ -253,6 +253,13 @@ struct CertificateInformation {
|
||||||
std::string serial_number;
|
std::string serial_number;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum class MessageFlag : int
|
||||||
|
{
|
||||||
|
MSG_FLAG_NONE = 0,
|
||||||
|
MSG_SIGN = 1 << 0,
|
||||||
|
MSG_ENCRYPT = 1 << 1,
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue