OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::BBLPrinterAgent Class Reference

#include </home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/Utils/BBLPrinterAgent.hpp>

Inheritance diagram for Slic3r::BBLPrinterAgent:
Collaboration diagram for Slic3r::BBLPrinterAgent:

Public Member Functions

 BBLPrinterAgent ()
 ~BBLPrinterAgent () override
void set_cloud_agent (std::shared_ptr< ICloudServiceAgent > cloud) override
int send_message (std::string dev_id, std::string json_str, int qos, int flag) override
int command_ams_refresh_rfid (std::string dev_id, int ams_id, int slot_id, int sequence_id, bool lan_mode) override
int command_ams_calibrate (std::string dev_id, int ams_id, int sequence_id, bool lan_mode) override
int command_ams_select_tray (std::string dev_id, std::string tray_id, int sequence_id, bool lan_mode) override
int command_axis_control (std::string dev_id, std::string axis, double unit, double input_val, int speed, bool is_core_xy, bool supports_mqtt_axis_control, int sequence_id, bool lan_mode) override
std::string default_lan_username () const override
int connect_printer (const PrinterConnectionParams &params) override
int disconnect_printer () override
int send_message_to_printer (std::string dev_id, std::string json_str, int qos, int flag) override
int check_cert () override
void install_device_cert (std::string dev_id, bool lan_only) override
bool start_discovery (bool start, bool sending) override
int ping_bind (std::string ping_code) override
int bind_detect (std::string dev_ip, std::string sec_link, detectResult &detect) override
int bind (std::string dev_ip, std::string dev_id, std::string dev_model, std::string sec_link, std::string timezone, bool improved, OnUpdateStatusFn update_fn) override
int unbind (std::string dev_id) override
int request_bind_ticket (std::string *ticket) override
int get_hms_snapshot (std::string dev_id, std::string file_name, std::function< void(std::string, int)> callback) override
int set_server_callback (OnServerErrFn fn) override
std::string get_user_selected_machine () override
int set_user_selected_machine (std::string dev_id) override
int start_subscribe (std::string module) override
int stop_subscribe (std::string module) override
int add_subscribe (std::vector< std::string > dev_list) override
int del_subscribe (std::vector< std::string > dev_list) override
AgentInfo get_agent_info () override
int start_print (PrintParams params, OnUpdateStatusFn update_fn, WasCancelledFn cancel_fn, OnWaitFn wait_fn) override
int start_local_print_with_record (PrintParams params, OnUpdateStatusFn update_fn, WasCancelledFn cancel_fn, OnWaitFn wait_fn) override
int start_send_gcode_to_sdcard (PrintParams params, OnUpdateStatusFn update_fn, WasCancelledFn cancel_fn, OnWaitFn wait_fn) override
int start_local_print (PrintParams params, OnUpdateStatusFn update_fn, WasCancelledFn cancel_fn) override
int start_sdcard_print (PrintParams params, OnUpdateStatusFn update_fn, WasCancelledFn cancel_fn) override
int set_on_ssdp_msg_fn (OnMsgArrivedFn fn) override
int set_on_printer_connected_fn (OnPrinterConnectedFn fn) override
int set_on_subscribe_failure_fn (GetSubscribeFailureFn fn) override
int set_on_message_fn (OnMessageFn fn) override
int set_on_user_message_fn (OnMessageFn fn) override
int set_on_local_connect_fn (OnLocalConnectedFn fn) override
int set_on_local_message_fn (OnMessageFn fn) override
int set_queue_on_main_fn (QueueOnMainFn fn) override
FilamentSyncMode get_filament_sync_mode () const override
std::string to_orca_filament_id (const std::string &printer_filament_id) const override
std::string from_orca_filament_id (const std::string &orca_filament_id) const override
virtual int command_start_camera (std::string)
virtual int command_xyz_abs (std::string dev_id, int sequence_id, bool lan_mode)
virtual int command_auto_leveling (std::string dev_id, int sequence_id, bool lan_mode)
virtual int command_go_home (std::string dev_id, bool is_printing, bool supports_mqtt_homing, int sequence_id, bool lan_mode)
virtual int command_set_bed (std::string dev_id, int temp, bool supports_mqtt_bed_ctrl, int sequence_id, bool lan_mode)
virtual int command_set_nozzle (std::string dev_id, int temp, int sequence_id, bool lan_mode)
virtual CameraStreamMode get_camera_stream_mode () const
virtual bool fetch_filament_info (std::string dev_id, FilamentSyncMode sync_mode=FilamentSyncMode::pull)
virtual std::string get_camera_url () const

Static Public Member Functions

static AgentInfo get_agent_info_static ()
static std::string bambu_filament_id (const std::string &orca_filament_id)
static std::string to_orca_payload (std::string json_text)
static std::string from_orca_payload (std::string json_text)

Private Member Functions

int publish (const std::string &dev_id, const nlohmann::json &j, bool lan_mode)
int publish_command_json (std::string dev_id, const nlohmann::json &j, bool lan_mode)

Detailed Description

BBLPrinterAgent - BBL DLL wrapper implementation of IPrinterAgent.

Delegates all printer operations to the proprietary BBL network DLL through function pointers obtained from BBLNetworkPlugin singleton.

Constructor & Destructor Documentation

◆ BBLPrinterAgent()

Slic3r::BBLPrinterAgent::BBLPrinterAgent ( )
default

◆ ~BBLPrinterAgent()

Slic3r::BBLPrinterAgent::~BBLPrinterAgent ( )
overridedefault

Member Function Documentation

◆ add_subscribe()

int Slic3r::BBLPrinterAgent::add_subscribe ( std::vector< std::string > dev_list)
overridevirtual

Subscribe to push streams for specific device identifiers.

Reimplemented from Slic3r::IPrinterAgent.

525{
526 auto& plugin = BBLNetworkPlugin::instance();
527 auto agent = plugin.get_agent();
528 auto func = plugin.get_add_subscribe();
529 if (func && agent) {
530 return func(agent, dev_list);
531 }
532 return -1;
533}
static BBLNetworkPlugin & instance()
Definition BBLNetworkPlugin.cpp:56

References Slic3r::BBLNetworkPlugin::instance().

Here is the call graph for this function:

◆ bambu_filament_id()

std::string Slic3r::BBLPrinterAgent::bambu_filament_id ( const std::string & orca_filament_id)
static
141{
142 const auto& map = bambu_filament_id_map().to_bambu;
143 auto it = map.find(orca_filament_id);
144 return it != map.end() ? it->second : orca_filament_id;
145}
std::unordered_map< std::string, std::string > to_bambu
Definition BBLPrinterAgent.cpp:41
const BambuFilamentIdMap & bambu_filament_id_map()
Definition BBLPrinterAgent.cpp:43

References Slic3r::anonymous_namespace{BBLPrinterAgent.cpp}::BambuFilamentIdMap::to_bambu.

Referenced by from_orca_filament_id(), and Slic3r::FilamentColorCodeQuery::GetFilaInfoMap().

Here is the caller graph for this function:

◆ bind()

int Slic3r::BBLPrinterAgent::bind ( std::string dev_ip,
std::string dev_id,
std::string dev_model,
std::string sec_link,
std::string timezone,
bool improved,
OnUpdateStatusFn update_fn )
overridevirtual

Execute the multi-stage printer binding workflow.

Reimplemented from Slic3r::IPrinterAgent.

404{
405 auto& plugin = BBLNetworkPlugin::instance();
406 auto agent = plugin.get_agent();
407 auto func = plugin.get_bind();
408 if (func && agent) {
409 // dev_model was added in 02.08.01. Passing it to a plug-in that takes the 7-argument
410 // form shifts every following argument, so the older generations get the older call.
411 switch (plugin.network_abi()) {
413 case NetworkAbi::V0203: {
414 auto older_func = as_abi<func_bind_pre0208>(func);
415 return older_func(agent, dev_ip, dev_id, sec_link, timezone, improved, update_fn);
416 }
418 return func(agent, dev_ip, dev_id, dev_model, sec_link, timezone, improved, update_fn);
419 default:
420 return -1;
421 }
422 }
423 return -1;
424}
@ Legacy
Definition bambu_networking.hpp:414
@ V0203
Definition bambu_networking.hpp:415
@ Current
Definition bambu_networking.hpp:416

References Slic3r::Current, Slic3r::BBLNetworkPlugin::instance(), Slic3r::Legacy, and Slic3r::V0203.

Here is the call graph for this function:

◆ bind_detect()

int Slic3r::BBLPrinterAgent::bind_detect ( std::string dev_ip,
std::string sec_link,
detectResult & detect )
overridevirtual

Perform binding detection/handshake on a LAN printer.

Implements Slic3r::IPrinterAgent.

393{
394 auto& plugin = BBLNetworkPlugin::instance();
395 auto agent = plugin.get_agent();
396 auto func = plugin.get_bind_detect();
397 if (func && agent) {
398 return func(agent, dev_ip, sec_link, detect);
399 }
400 return -1;
401}

References Slic3r::BBLNetworkPlugin::instance().

Here is the call graph for this function:

◆ check_cert()

int Slic3r::BBLPrinterAgent::check_cert ( )
overridevirtual

Validate current user certificates for the printer.

Reimplemented from Slic3r::IPrinterAgent.

342{
343 auto& plugin = BBLNetworkPlugin::instance();
344 auto agent = plugin.get_agent();
345 auto func = plugin.get_check_cert();
346 if (func && agent) {
347 return func(agent);
348 }
349 return -1;
350}

References Slic3r::BBLNetworkPlugin::instance().

Here is the call graph for this function:

◆ command_ams_calibrate()

int Slic3r::BBLPrinterAgent::command_ams_calibrate ( std::string dev_id,
int ams_id,
int sequence_id,
bool lan_mode )
overridevirtual

Reimplemented from Slic3r::IPrinterAgent.

190{
191 const std::string gcode = (boost::format("M620 C%1% \n") % ams_id).str();
192 nlohmann::json j;
193 j["print"]["command"] = "gcode_line";
194 j["print"]["param"] = gcode;
195 j["print"]["sequence_id"] = std::to_string(sequence_id);
196 return publish(dev_id, j, lan_mode);
197}
int publish(const std::string &dev_id, const nlohmann::json &j, bool lan_mode)
Definition BBLPrinterAgent.cpp:249
@ gcode
Definition Time.hpp:14

References publish().

Here is the call graph for this function:

◆ command_ams_refresh_rfid()

int Slic3r::BBLPrinterAgent::command_ams_refresh_rfid ( std::string dev_id,
int ams_id,
int slot_id,
int sequence_id,
bool lan_mode )
overridevirtual

Reimplemented from Slic3r::IPrinterAgent.

172{
173 nlohmann::json j;
174 if (ams_id == -1) {
175 const std::string gcode = (boost::format("M620 R%1% \n") % slot_id).str();
176 j["print"]["command"] = "gcode_line";
177 j["print"]["param"] = gcode;
178 j["print"]["sequence_id"] = std::to_string(sequence_id);
179 return publish(dev_id, j, lan_mode);
180 }
181
182 j["print"]["command"] = "ams_get_rfid";
183 j["print"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++);
184 j["print"]["ams_id"] = ams_id;
185 j["print"]["slot_id"] = slot_id;
186 return publish(dev_id, j, lan_mode);
187}
static int m_sequence_id
Definition DeviceManager.hpp:197

References Slic3r::MachineObject::m_sequence_id, and publish().

Here is the call graph for this function:

◆ command_ams_select_tray()

int Slic3r::BBLPrinterAgent::command_ams_select_tray ( std::string dev_id,
std::string tray_id,
int sequence_id,
bool lan_mode )
overridevirtual

Reimplemented from Slic3r::IPrinterAgent.

200{
201 const std::string gcode = (boost::format("M620 P%1% \n") % tray_id).str();
202 nlohmann::json j;
203 j["print"]["command"] = "gcode_line";
204 j["print"]["param"] = gcode;
205 j["print"]["sequence_id"] = std::to_string(sequence_id);
206 return publish(dev_id, j, lan_mode);
207}

References publish().

Here is the call graph for this function:

◆ command_auto_leveling()

virtual int Slic3r::IPrinterAgent::command_auto_leveling ( std::string dev_id,
int sequence_id,
bool lan_mode )
inlinevirtualinherited

Reimplemented in Slic3r::PyPrinterAgentPluginCapabilityTrampoline.

141 {
142 nlohmann::json j;
143 j["print"]["command"] = "gcode_line";
144 j["print"]["param"] = "G29 \n";
145 j["print"]["sequence_id"] = std::to_string(sequence_id);
146 return publish_command_json(dev_id, j, lan_mode);
147 }
int publish_command_json(std::string dev_id, const nlohmann::json &j, bool lan_mode)
Definition IPrinterAgent.hpp:125

References publish_command_json().

Referenced by Slic3r::PrinterAgentPluginCapability::RegisterBindings().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ command_axis_control()

int Slic3r::BBLPrinterAgent::command_axis_control ( std::string dev_id,
std::string axis,
double unit,
double input_val,
int speed,
bool is_core_xy,
bool supports_mqtt_axis_control,
int sequence_id,
bool lan_mode )
overridevirtual

Reimplemented from Slic3r::IPrinterAgent.

211{
212 nlohmann::json j;
213 j["print"]["sequence_id"] = std::to_string(sequence_id);
214
215 if (supports_mqtt_axis_control) {
216 int dir = input_val > 0 ? 1 : -1;
217 // i3-arch printers move the bed for Y/Z, so the on-screen direction is
218 // reversed -- same negation the g-code fallback below applies.
219 if (!is_core_xy && (axis == "Y" || axis == "Z"))
220 dir = -dir;
221
222 j["print"]["command"] = "xyz_ctrl";
223 j["print"]["axis"] = axis;
224 j["print"]["dir"] = dir;
225 j["print"]["mode"] = (std::abs(input_val) >= 10) ? 1 : 0;
226 return publish(dev_id, j, lan_mode);
227 }
228
229 double value = input_val;
230 if (!is_core_xy && (axis == "Y" || axis == "Z"))
231 value = -input_val;
232
233 std::string value_str = (boost::format("%.1f") % (value * unit)).str();
234 std::string gcode;
235 if (axis == "X" || axis == "Y" || axis == "Z") {
236 gcode = (boost::format("M211 S \nM211 X1 Y1 Z1\nM1002 push_ref_mode\nG91 \nG1 %1%%2% F%3%\nM1002 pop_ref_mode\nM211 R\n")
237 % axis % value_str % speed).str();
238 } else if (axis == "E") {
239 gcode = (boost::format("M83 \nG0 %1%%2% F%3%\n") % axis % value_str % speed).str();
240 } else {
241 return -1;
242 }
243
244 j["print"]["command"] = "gcode_line";
245 j["print"]["param"] = gcode;
246 return publish(dev_id, j, lan_mode);
247}

References publish().

Here is the call graph for this function:

◆ command_go_home()

virtual int Slic3r::IPrinterAgent::command_go_home ( std::string dev_id,
bool is_printing,
bool supports_mqtt_homing,
int sequence_id,
bool lan_mode )
inlinevirtualinherited

Reimplemented in Slic3r::PyPrinterAgentPluginCapabilityTrampoline.

149 {
150 nlohmann::json j;
151 j["print"]["sequence_id"] = std::to_string(sequence_id);
152 if (supports_mqtt_homing) {
153 j["print"]["command"] = "back_to_center";
154 } else {
155 j["print"]["command"] = "gcode_line";
156 j["print"]["param"] = is_printing ? "G28 X\n" : "G28 \n";
157 }
158 return publish_command_json(dev_id, j, lan_mode);
159 }

References publish_command_json().

Referenced by Slic3r::PrinterAgentPluginCapability::RegisterBindings().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ command_set_bed()

virtual int Slic3r::IPrinterAgent::command_set_bed ( std::string dev_id,
int temp,
bool supports_mqtt_bed_ctrl,
int sequence_id,
bool lan_mode )
inlinevirtualinherited

Reimplemented in Slic3r::PyPrinterAgentPluginCapabilityTrampoline.

161 {
162 nlohmann::json j;
163 j["print"]["sequence_id"] = std::to_string(sequence_id);
164 if (supports_mqtt_bed_ctrl) {
165 j["print"]["command"] = "set_bed_temp";
166 j["print"]["temp"] = temp;
167 } else {
168 j["print"]["command"] = "gcode_line";
169 j["print"]["param"] = (boost::format("M140 S%1%\n") % temp).str();
170 }
171 return publish_command_json(dev_id, j, lan_mode);
172 }

References publish_command_json().

Referenced by Slic3r::PrinterAgentPluginCapability::RegisterBindings().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ command_set_nozzle()

virtual int Slic3r::IPrinterAgent::command_set_nozzle ( std::string dev_id,
int temp,
int sequence_id,
bool lan_mode )
inlinevirtualinherited

Reimplemented in Slic3r::PyPrinterAgentPluginCapabilityTrampoline.

174 {
175 nlohmann::json j;
176 j["print"]["command"] = "gcode_line";
177 j["print"]["param"] = (boost::format("M104 S%1%\n") % temp).str();
178 j["print"]["sequence_id"] = std::to_string(sequence_id);
179 return publish_command_json(dev_id, j, lan_mode);
180 }

References publish_command_json().

Referenced by Slic3r::PrinterAgentPluginCapability::RegisterBindings().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ command_start_camera()

virtual int Slic3r::IPrinterAgent::command_start_camera ( std::string )
inlinevirtualinherited

Reimplemented in Slic3r::PyPrinterAgentPluginCapabilityTrampoline.

#define ORCA_NETWORK_ERR_CMD_NOT_SUPPORTED
Definition IPrinterAgent.hpp:10

References ORCA_NETWORK_ERR_CMD_NOT_SUPPORTED.

Referenced by Slic3r::PrinterAgentPluginCapability::RegisterBindings().

Here is the caller graph for this function:

◆ command_xyz_abs()

virtual int Slic3r::IPrinterAgent::command_xyz_abs ( std::string dev_id,
int sequence_id,
bool lan_mode )
inlinevirtualinherited

Reimplemented in Slic3r::PyPrinterAgentPluginCapabilityTrampoline.

133 {
134 nlohmann::json j;
135 j["print"]["command"] = "gcode_line";
136 j["print"]["param"] = "G90 \n";
137 j["print"]["sequence_id"] = std::to_string(sequence_id);
138 return publish_command_json(dev_id, j, lan_mode);
139 }

References publish_command_json().

Referenced by Slic3r::PrinterAgentPluginCapability::RegisterBindings().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ connect_printer()

int Slic3r::BBLPrinterAgent::connect_printer ( const PrinterConnectionParams & params)
overridevirtual

Establish a direct LAN connection to a printer.

Implements Slic3r::IPrinterAgent.

284{
285 auto& plugin = BBLNetworkPlugin::instance();
286 auto agent = plugin.get_agent();
287 auto func = plugin.get_connect_printer();
288#if !BBL_RELEASE_TO_PUBLIC
289 const bool use_ssl_for_mqtt = GUI::wxGetApp().app_config &&
290 GUI::wxGetApp().app_config->get_bool("enable_ssl_for_mqtt");
291#else
292 bool use_ssl_for_mqtt = true;
293 if (auto* dev_manager = GUI::wxGetApp().getDeviceManager()) {
294 if (auto* machine = dev_manager->get_my_machine(params.dev_id))
295 use_ssl_for_mqtt = machine->local_use_ssl;
296 }
297#endif
298 if (func && agent) {
299 return func(agent, params.dev_id, params.host, params.username, params.password, use_ssl_for_mqtt);
300 }
301 return -1;
302}

References Slic3r::PrinterConnectionParams::dev_id, Slic3r::PrinterConnectionParams::host, Slic3r::BBLNetworkPlugin::instance(), Slic3r::PrinterConnectionParams::password, and Slic3r::PrinterConnectionParams::username.

Here is the call graph for this function:

◆ default_lan_username()

std::string Slic3r::BBLPrinterAgent::default_lan_username ( ) const
inlineoverridevirtual

Default LAN account username for this agent's protocol, if it has a fixed one. Returns an empty string if the agent has no fixed default (e.g. caller must supply one).

Reimplemented from Slic3r::IPrinterAgent.

41{ return "bblp"; }

◆ del_subscribe()

int Slic3r::BBLPrinterAgent::del_subscribe ( std::vector< std::string > dev_list)
overridevirtual

Remove device-level subscriptions.

Reimplemented from Slic3r::IPrinterAgent.

536{
537 auto& plugin = BBLNetworkPlugin::instance();
538 auto agent = plugin.get_agent();
539 auto func = plugin.get_del_subscribe();
540 if (func && agent) {
541 return func(agent, dev_list);
542 }
543 return -1;
544}

References Slic3r::BBLNetworkPlugin::instance().

Here is the call graph for this function:

◆ disconnect_printer()

int Slic3r::BBLPrinterAgent::disconnect_printer ( )
overridevirtual

Tear down the active LAN printer connection.

Implements Slic3r::IPrinterAgent.

305{
306 auto& plugin = BBLNetworkPlugin::instance();
307 auto agent = plugin.get_agent();
308 auto func = plugin.get_disconnect_printer();
309 if (func && agent) {
310 return func(agent);
311 }
312 return -1;
313}

References Slic3r::BBLNetworkPlugin::instance().

Here is the call graph for this function:

◆ fetch_filament_info()

virtual bool Slic3r::IPrinterAgent::fetch_filament_info ( std::string dev_id,
FilamentSyncMode sync_mode = FilamentSyncMode::pull )
inlinevirtualinherited

Refresh filament info from the printer synchronously. Should only be called when get_filament_sync_mode() returns FilamentSyncMode::pull. Populates the MachineObject's DevFilaSystem with fetched filament data.

Reimplemented in Slic3r::CrealityPrintAgent, Slic3r::MoonrakerPrinterAgent, Slic3r::PyPrinterAgentPluginCapabilityTrampoline, Slic3r::QidiPrinterAgent, and Slic3r::SnapmakerPrinterAgent.

462{ return false; }

References Slic3r::pull.

Referenced by Slic3r::PrinterAgentPluginCapability::RegisterBindings().

Here is the caller graph for this function:

◆ from_orca_filament_id()

std::string Slic3r::BBLPrinterAgent::from_orca_filament_id ( const std::string & orca_filament_id) const
overridevirtual

Reimplemented from Slic3r::IPrinterAgent.

136{
137 return bambu_filament_id(orca_filament_id);
138}
static std::string bambu_filament_id(const std::string &orca_filament_id)
Definition BBLPrinterAgent.cpp:140

References bambu_filament_id().

Referenced by Slic3r::CLI::run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ from_orca_payload()

std::string Slic3r::BBLPrinterAgent::from_orca_payload ( std::string json_text)
static
153{
154 return rewrite_filament_ids(std::move(json_text), bambu_filament_id_map().to_bambu);
155}
void rewrite_filament_ids(json &j, const std::unordered_map< std::string, std::string > &map)
Definition BBLPrinterAgent.cpp:75

Referenced by Slic3r::anonymous_namespace{BBLPrinterAgent.cpp}::dispatch_start(), send_message(), and send_message_to_printer().

Here is the caller graph for this function:

◆ get_agent_info()

AgentInfo Slic3r::BBLPrinterAgent::get_agent_info ( )
inlineoverridevirtual

Get agent information.

Implements Slic3r::IPrinterAgent.

78{ return get_agent_info_static(); }
static AgentInfo get_agent_info_static()
Definition BBLPrinterAgent.cpp:549

References get_agent_info_static().

Here is the call graph for this function:

◆ get_agent_info_static()

AgentInfo Slic3r::BBLPrinterAgent::get_agent_info_static ( )
static

Get agent information.

Returns
AgentInfo struct containing agent identification and descriptive information
550{
551 return AgentInfo{BBL_PRINTER_AGENT_ID, "Bambu Lab", "", "Bambu Lab printer agent"};
552}
static constexpr char BBL_PRINTER_AGENT_ID[]
Definition NetworkAgentFactory.hpp:20

References Slic3r::BBL_PRINTER_AGENT_ID.

Referenced by get_agent_info(), and Slic3r::NetworkAgentFactory::register_all_agents().

Here is the caller graph for this function:

◆ get_camera_stream_mode()

virtual CameraStreamMode Slic3r::IPrinterAgent::get_camera_stream_mode ( ) const
inlinevirtualinherited

Get the camera stream mode for this agent. This value can be deterministic and derived at runtime if the printer supports multiple camera stream modes. E.g. LAN => HTTP/HTTPS/RTSP, Cloud => WebRTC.

Returns
CameraStreamMode indicating how the camera stream is obtained or used:

Reimplemented in Slic3r::PyPrinterAgentPluginCapabilityTrampoline.

455{ return CameraStreamMode::none; }
@ none
Definition IPrinterAgent.hpp:63

References Slic3r::none.

Referenced by Slic3r::PrinterAgentPluginCapability::RegisterBindings().

Here is the caller graph for this function:

◆ get_camera_url()

virtual std::string Slic3r::IPrinterAgent::get_camera_url ( ) const
inlinevirtualinherited

Get the current camera stream URL for this agent's active machine. Only meaningful when get_camera_stream_mode() returns an HTTP, HTTPS, or RTSP mode.

Reimplemented in Slic3r::PyPrinterAgentPluginCapabilityTrampoline.

478{ return {}; }

Referenced by Slic3r::PrinterAgentPluginCapability::RegisterBindings().

Here is the caller graph for this function:

◆ get_filament_sync_mode()

FilamentSyncMode Slic3r::BBLPrinterAgent::get_filament_sync_mode ( ) const
overridevirtual

Get the filament synchronization mode for this agent.

Returns
FilamentSyncMode indicating how filament data is obtained:
  • subscription: Real-time push updates via MQTT (no fetch needed)
  • pull: On-demand fetch via REST API (call fetch_filament_info())
  • none: Filament synchronization not supported

Reimplemented from Slic3r::IPrinterAgent.

714{
715 // BBL uses MQTT subscription for real-time filament updates
717}
@ subscription
Real-time push updates via subscription (e.g., MQTT).
Definition IPrinterAgent.hpp:58

References Slic3r::subscription.

◆ get_hms_snapshot()

int Slic3r::BBLPrinterAgent::get_hms_snapshot ( std::string dev_id,
std::string file_name,
std::function< void(std::string, int)> callback )
overridevirtual

Fetch the cloud snapshot image captured at a print failure. Returns 0 if the request was dispatched; the image body arrives via callback(body, http_status).

Reimplemented from Slic3r::IPrinterAgent.

449{
450 auto& plugin = BBLNetworkPlugin::instance();
451 auto agent = plugin.get_agent();
452 auto func = plugin.get_get_hms_snapshot();
453 // dev_id/file_name are passed as lvalues to bind the plugin's std::string& params.
454 // A null func (older plugin without this symbol) falls through to -1 so callers degrade gracefully.
455 if (func && agent) {
456 return func(agent, dev_id, file_name, callback);
457 }
458 return -1;
459}

References Slic3r::BBLNetworkPlugin::instance().

Here is the call graph for this function:

◆ get_user_selected_machine()

std::string Slic3r::BBLPrinterAgent::get_user_selected_machine ( )
overridevirtual

Return the currently selected printer ID.

Implements Slic3r::IPrinterAgent.

477{
478 auto& plugin = BBLNetworkPlugin::instance();
479 auto agent = plugin.get_agent();
480 auto func = plugin.get_get_user_selected_machine();
481 if (func && agent) {
482 return func(agent);
483 }
484 return "";
485}

References Slic3r::BBLNetworkPlugin::instance().

Here is the call graph for this function:

◆ install_device_cert()

void Slic3r::BBLPrinterAgent::install_device_cert ( std::string dev_id,
bool lan_only )
overridevirtual

Install or refresh device certificate for LAN TLS.

Reimplemented from Slic3r::IPrinterAgent.

353{
354 auto& plugin = BBLNetworkPlugin::instance();
355 auto agent = plugin.get_agent();
356 auto func = plugin.get_install_device_cert();
357 if (func && agent) {
358 func(agent, dev_id, lan_only);
359 }
360}

References Slic3r::BBLNetworkPlugin::instance().

Here is the call graph for this function:

◆ ping_bind()

int Slic3r::BBLPrinterAgent::ping_bind ( std::string ping_code)
overridevirtual

Ping the binding endpoint to check printer readiness.

Reimplemented from Slic3r::IPrinterAgent.

382{
383 auto& plugin = BBLNetworkPlugin::instance();
384 auto agent = plugin.get_agent();
385 auto func = plugin.get_ping_bind();
386 if (func && agent) {
387 return func(agent, ping_code);
388 }
389 return -1;
390}

References Slic3r::BBLNetworkPlugin::instance().

Here is the call graph for this function:

◆ publish()

int Slic3r::BBLPrinterAgent::publish ( const std::string & dev_id,
const nlohmann::json & j,
bool lan_mode )
private
250{
251 const int rtn = lan_mode ? send_message_to_printer(dev_id, j.dump(), 0, 0) : send_message(dev_id, j.dump(), 0, 0);
252 if (rtn == 0)
253 BOOST_LOG_TRIVIAL(info) << "publish_json: " << j.dump() << " code: " << rtn;
254 else
255 BOOST_LOG_TRIVIAL(error) << "publish_json: " << j.dump() << " code: " << rtn;
256 return rtn;
257}
int send_message_to_printer(std::string dev_id, std::string json_str, int qos, int flag) override
Definition BBLPrinterAgent.cpp:315
int send_message(std::string dev_id, std::string json_str, int qos, int flag) override
Definition BBLPrinterAgent.cpp:259
size_t dump(const PresetBundle &bundle, const Sections &sections, std::ostream &out)
Definition profile_include_dump.cpp:96

References send_message(), and send_message_to_printer().

Referenced by command_ams_calibrate(), command_ams_refresh_rfid(), command_ams_select_tray(), and command_axis_control().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ publish_command_json()

int Slic3r::IPrinterAgent::publish_command_json ( std::string dev_id,
const nlohmann::json & j,
bool lan_mode )
inlineprivateinherited
126 {
127 return lan_mode ? send_message_to_printer(dev_id, j.dump(), 0, 0)
128 : send_message(dev_id, j.dump(), 0, 0);
129 }
virtual int send_message(std::string dev_id, std::string json_str, int qos, int flag)=0
virtual int send_message_to_printer(std::string dev_id, std::string json_str, int qos, int flag)=0

References send_message(), and send_message_to_printer().

Referenced by command_auto_leveling(), command_axis_control(), command_go_home(), command_set_bed(), command_set_nozzle(), and command_xyz_abs().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ request_bind_ticket()

int Slic3r::BBLPrinterAgent::request_bind_ticket ( std::string * ticket)
overridevirtual

Request a one-time bind ticket from the server.

Reimplemented from Slic3r::IPrinterAgent.

438{
439 auto& plugin = BBLNetworkPlugin::instance();
440 auto agent = plugin.get_agent();
441 auto func = plugin.get_request_bind_ticket();
442 if (func && agent) {
443 return func(agent, ticket);
444 }
445 return -1;
446}

References Slic3r::BBLNetworkPlugin::instance().

Here is the call graph for this function:

◆ send_message()

int Slic3r::BBLPrinterAgent::send_message ( std::string dev_id,
std::string json_str,
int qos,
int flag )
overridevirtual

Publish a JSON command to a printer through cloud relay.

Implements Slic3r::IPrinterAgent.

260{
261 json_str = from_orca_payload(std::move(json_str));
262 auto& plugin = BBLNetworkPlugin::instance();
263 auto agent = plugin.get_agent();
264 auto func = plugin.get_send_message();
265 if (func && agent) {
266 // Only the legacy plug-in lacks `flag`; 02.03.00 already takes it, and routing that
267 // series through the legacy form would silently drop MessageFlag sign/encrypt.
268 switch (plugin.network_abi()) {
269 case NetworkAbi::Legacy: {
270 auto legacy_func = as_abi<func_send_message_legacy>(func);
271 return legacy_func(agent, std::move(dev_id), std::move(json_str), qos);
272 }
275 return func(agent, std::move(dev_id), std::move(json_str), qos, flag);
276 default:
277 return -1;
278 }
279 }
280 return -1;
281}
static std::string from_orca_payload(std::string json_text)
Definition BBLPrinterAgent.cpp:152

References Slic3r::Current, from_orca_payload(), Slic3r::BBLNetworkPlugin::instance(), Slic3r::Legacy, and Slic3r::V0203.

Referenced by publish().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ send_message_to_printer()

int Slic3r::BBLPrinterAgent::send_message_to_printer ( std::string dev_id,
std::string json_str,
int qos,
int flag )
overridevirtual

Send a JSON command to a LAN printer (bypassing cloud).

Implements Slic3r::IPrinterAgent.

316{
317 json_str = from_orca_payload(std::move(json_str));
318 auto& plugin = BBLNetworkPlugin::instance();
319 auto agent = plugin.get_agent();
320 auto func = plugin.get_send_message_to_printer();
321 if (func && agent) {
322 switch (plugin.network_abi()) {
323 case NetworkAbi::Legacy: {
324 auto legacy_func = as_abi<func_send_message_to_printer_legacy>(func);
325 return legacy_func(agent, std::move(dev_id), std::move(json_str), qos);
326 }
329 return func(agent, std::move(dev_id), std::move(json_str), qos, flag);
330 default:
331 return -1;
332 }
333 }
334 return -1;
335}

References Slic3r::Current, from_orca_payload(), Slic3r::BBLNetworkPlugin::instance(), Slic3r::Legacy, and Slic3r::V0203.

Referenced by publish().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_cloud_agent()

void Slic3r::BBLPrinterAgent::set_cloud_agent ( std::shared_ptr< ICloudServiceAgent > cloud)
overridevirtual

Set the cloud agent used for token access. Must be called before any cloud-relay operations.

Implements Slic3r::IPrinterAgent.

162{
163 (void) cloud;
164 // BBL DLL manages tokens internally, so this is just for interface compliance
165}

◆ set_on_local_connect_fn()

int Slic3r::BBLPrinterAgent::set_on_local_connect_fn ( OnLocalConnectedFn fn)
overridevirtual

Register LAN connection status callback.

Implements Slic3r::IPrinterAgent.

677{
678 auto& plugin = BBLNetworkPlugin::instance();
679 auto agent = plugin.get_agent();
680 auto func = plugin.get_set_on_local_connect_fn();
681 if (func && agent) {
682 return func(agent, fn);
683 }
684 return -1;
685}

References Slic3r::BBLNetworkPlugin::instance().

Here is the call graph for this function:

◆ set_on_local_message_fn()

int Slic3r::BBLPrinterAgent::set_on_local_message_fn ( OnMessageFn fn)
overridevirtual

Register LAN message callback.

Implements Slic3r::IPrinterAgent.

688{
689 auto& plugin = BBLNetworkPlugin::instance();
690 auto agent = plugin.get_agent();
691 auto func = plugin.get_set_on_local_message_fn();
692 if (func && agent) {
693 return func(agent, to_orca_messages(std::move(fn)));
694 }
695 return -1;
696}
OnMessageFn to_orca_messages(OnMessageFn fn)
Definition BBLPrinterAgent.cpp:109

References Slic3r::BBLNetworkPlugin::instance().

Here is the call graph for this function:

◆ set_on_message_fn()

int Slic3r::BBLPrinterAgent::set_on_message_fn ( OnMessageFn fn)
overridevirtual

Register cloud device message callback.

Implements Slic3r::IPrinterAgent.

655{
656 auto& plugin = BBLNetworkPlugin::instance();
657 auto agent = plugin.get_agent();
658 auto func = plugin.get_set_on_message_fn();
659 if (func && agent) {
660 return func(agent, to_orca_messages(std::move(fn)));
661 }
662 return -1;
663}

References Slic3r::BBLNetworkPlugin::instance().

Here is the call graph for this function:

◆ set_on_printer_connected_fn()

int Slic3r::BBLPrinterAgent::set_on_printer_connected_fn ( OnPrinterConnectedFn fn)
overridevirtual

Register printer MQTT connection callback.

Implements Slic3r::IPrinterAgent.

633{
634 auto& plugin = BBLNetworkPlugin::instance();
635 auto agent = plugin.get_agent();
636 auto func = plugin.get_set_on_printer_connected_fn();
637 if (func && agent) {
638 return func(agent, fn);
639 }
640 return -1;
641}

References Slic3r::BBLNetworkPlugin::instance().

Here is the call graph for this function:

◆ set_on_ssdp_msg_fn()

int Slic3r::BBLPrinterAgent::set_on_ssdp_msg_fn ( OnMsgArrivedFn fn)
overridevirtual

Register SSDP discovery callback.

Implements Slic3r::IPrinterAgent.

622{
623 auto& plugin = BBLNetworkPlugin::instance();
624 auto agent = plugin.get_agent();
625 auto func = plugin.get_set_on_ssdp_msg_fn();
626 if (func && agent) {
627 return func(agent, fn);
628 }
629 return -1;
630}

References Slic3r::BBLNetworkPlugin::instance().

Here is the call graph for this function:

◆ set_on_subscribe_failure_fn()

int Slic3r::BBLPrinterAgent::set_on_subscribe_failure_fn ( GetSubscribeFailureFn fn)
overridevirtual

Register subscription failure callback.

Implements Slic3r::IPrinterAgent.

644{
645 auto& plugin = BBLNetworkPlugin::instance();
646 auto agent = plugin.get_agent();
647 auto func = plugin.get_set_on_subscribe_failure_fn();
648 if (func && agent) {
649 return func(agent, fn);
650 }
651 return -1;
652}

References Slic3r::BBLNetworkPlugin::instance().

Here is the call graph for this function:

◆ set_on_user_message_fn()

int Slic3r::BBLPrinterAgent::set_on_user_message_fn ( OnMessageFn fn)
overridevirtual

Register user-scoped message callback.

Implements Slic3r::IPrinterAgent.

666{
667 auto& plugin = BBLNetworkPlugin::instance();
668 auto agent = plugin.get_agent();
669 auto func = plugin.get_set_on_user_message_fn();
670 if (func && agent) {
671 return func(agent, fn);
672 }
673 return -1;
674}

References Slic3r::BBLNetworkPlugin::instance().

Here is the call graph for this function:

◆ set_queue_on_main_fn()

int Slic3r::BBLPrinterAgent::set_queue_on_main_fn ( QueueOnMainFn fn)
overridevirtual

Provide main thread queue callback.

Implements Slic3r::IPrinterAgent.

699{
700 auto& plugin = BBLNetworkPlugin::instance();
701 auto agent = plugin.get_agent();
702 auto func = plugin.get_set_queue_on_main_fn();
703 if (func && agent) {
704 return func(agent, fn);
705 }
706 return -1;
707}

References Slic3r::BBLNetworkPlugin::instance().

Here is the call graph for this function:

◆ set_server_callback()

int Slic3r::BBLPrinterAgent::set_server_callback ( OnServerErrFn fn)
overridevirtual

Register callback for fatal HTTP errors.

Implements Slic3r::IPrinterAgent.

462{
463 auto& plugin = BBLNetworkPlugin::instance();
464 auto agent = plugin.get_agent();
465 auto func = plugin.get_set_server_callback();
466 if (func && agent) {
467 return func(agent, fn);
468 }
469 return -1;
470}

References Slic3r::BBLNetworkPlugin::instance().

Here is the call graph for this function:

◆ set_user_selected_machine()

int Slic3r::BBLPrinterAgent::set_user_selected_machine ( std::string dev_id)
overridevirtual

Update the selected cloud machine preference.

Implements Slic3r::IPrinterAgent.

488{
489 auto& plugin = BBLNetworkPlugin::instance();
490 auto agent = plugin.get_agent();
491 auto func = plugin.get_set_user_selected_machine();
492 if (func && agent) {
493 return func(agent, dev_id);
494 }
495 return -1;
496}

References Slic3r::BBLNetworkPlugin::instance().

Here is the call graph for this function:

◆ start_discovery()

bool Slic3r::BBLPrinterAgent::start_discovery ( bool start,
bool sending )
overridevirtual

Start or stop SSDP discovery.

Implements Slic3r::IPrinterAgent.

367{
368 auto& plugin = BBLNetworkPlugin::instance();
369 auto agent = plugin.get_agent();
370 auto func = plugin.get_start_discovery();
371 if (func && agent) {
372 return func(agent, start, sending);
373 }
374 return false;
375}

References Slic3r::BBLNetworkPlugin::instance().

Here is the call graph for this function:

◆ start_local_print()

int Slic3r::BBLPrinterAgent::start_local_print ( PrintParams params,
OnUpdateStatusFn update_fn,
WasCancelledFn cancel_fn )
overridevirtual

Start a LAN-only print.

Implements Slic3r::IPrinterAgent.

606{
607 return dispatch_start<func_start_local_print_legacy, func_start_local_print_0203>(
608 BBLNetworkPlugin::instance().get_start_local_print(), params, update_fn, cancel_fn);
609}

References Slic3r::BBLNetworkPlugin::instance().

Here is the call graph for this function:

◆ start_local_print_with_record()

int Slic3r::BBLPrinterAgent::start_local_print_with_record ( PrintParams params,
OnUpdateStatusFn update_fn,
WasCancelledFn cancel_fn,
OnWaitFn wait_fn )
overridevirtual

Start a local print with cloud record.

Implements Slic3r::IPrinterAgent.

594{
595 return dispatch_start<func_start_local_print_with_record_legacy, func_start_local_print_with_record_0203>(
596 BBLNetworkPlugin::instance().get_start_local_print_with_record(), params, update_fn, cancel_fn, wait_fn);
597}

References Slic3r::BBLNetworkPlugin::instance().

Here is the call graph for this function:

◆ start_print()

int Slic3r::BBLPrinterAgent::start_print ( PrintParams params,
OnUpdateStatusFn update_fn,
WasCancelledFn cancel_fn,
OnWaitFn wait_fn )
overridevirtual

Start a fully managed cloud print.

Implements Slic3r::IPrinterAgent.

588{
589 return dispatch_start<func_start_print_legacy, func_start_print_0203>(
590 BBLNetworkPlugin::instance().get_start_print(), params, update_fn, cancel_fn, wait_fn);
591}

References Slic3r::BBLNetworkPlugin::instance().

Here is the call graph for this function:

◆ start_sdcard_print()

int Slic3r::BBLPrinterAgent::start_sdcard_print ( PrintParams params,
OnUpdateStatusFn update_fn,
WasCancelledFn cancel_fn )
overridevirtual

Start a print from printer's SD card.

Implements Slic3r::IPrinterAgent.

612{
613 return dispatch_start<func_start_sdcard_print_legacy, func_start_sdcard_print_0203>(
614 BBLNetworkPlugin::instance().get_start_sdcard_print(), params, update_fn, cancel_fn);
615}

References Slic3r::BBLNetworkPlugin::instance().

Here is the call graph for this function:

◆ start_send_gcode_to_sdcard()

int Slic3r::BBLPrinterAgent::start_send_gcode_to_sdcard ( PrintParams params,
OnUpdateStatusFn update_fn,
WasCancelledFn cancel_fn,
OnWaitFn wait_fn )
overridevirtual

Upload gcode to printer's SD card without starting.

Implements Slic3r::IPrinterAgent.

600{
601 return dispatch_start<func_start_send_gcode_to_sdcard_legacy, func_start_send_gcode_to_sdcard_0203>(
602 BBLNetworkPlugin::instance().get_start_send_gcode_to_sdcard(), params, update_fn, cancel_fn, wait_fn);
603}

References Slic3r::BBLNetworkPlugin::instance().

Here is the call graph for this function:

◆ start_subscribe()

int Slic3r::BBLPrinterAgent::start_subscribe ( std::string module)
overridevirtual

Subscribe to a logical module (for example app- or tunnel-scoped streams).

Reimplemented from Slic3r::IPrinterAgent.

503{
504 auto& plugin = BBLNetworkPlugin::instance();
505 auto agent = plugin.get_agent();
506 auto func = plugin.get_start_subscribe();
507 if (func && agent) {
508 return func(agent, module);
509 }
510 return -1;
511}
FileTransferModule & module()
Definition FileTransferUtils.hpp:248

References Slic3r::BBLNetworkPlugin::instance(), and Slic3r::module().

Here is the call graph for this function:

◆ stop_subscribe()

int Slic3r::BBLPrinterAgent::stop_subscribe ( std::string module)
overridevirtual

Stop listening to a formerly subscribed module.

Reimplemented from Slic3r::IPrinterAgent.

514{
515 auto& plugin = BBLNetworkPlugin::instance();
516 auto agent = plugin.get_agent();
517 auto func = plugin.get_stop_subscribe();
518 if (func && agent) {
519 return func(agent, module);
520 }
521 return -1;
522}

References Slic3r::BBLNetworkPlugin::instance(), and Slic3r::module().

Here is the call graph for this function:

◆ to_orca_filament_id()

std::string Slic3r::BBLPrinterAgent::to_orca_filament_id ( const std::string & printer_filament_id) const
overridevirtual

Translate one filament id across the printer boundary.

Orca content-addresses every system filament; a printer, its AMS and its vendor cloud know only that vendor's own catalog ids. An agent whose printers already speak Orca's ids leaves them alone, and so does an id with no mapping.

Reimplemented from Slic3r::IPrinterAgent.

129{
130 const auto& map = bambu_filament_id_map().to_orca;
131 auto it = map.find(printer_filament_id);
132 return it != map.end() ? it->second : printer_filament_id;
133}
std::unordered_map< std::string, std::string > to_orca
Definition BBLPrinterAgent.cpp:41

References Slic3r::anonymous_namespace{BBLPrinterAgent.cpp}::BambuFilamentIdMap::to_orca.

◆ to_orca_payload()

std::string Slic3r::BBLPrinterAgent::to_orca_payload ( std::string json_text)
static
148{
149 return rewrite_filament_ids(std::move(json_text), bambu_filament_id_map().to_orca);
150}

Referenced by Slic3r::anonymous_namespace{BBLPrinterAgent.cpp}::to_orca_messages().

Here is the caller graph for this function:

◆ unbind()

int Slic3r::BBLPrinterAgent::unbind ( std::string dev_id)
overridevirtual

Remove the association between account and printer.

Reimplemented from Slic3r::IPrinterAgent.

427{
428 auto& plugin = BBLNetworkPlugin::instance();
429 auto agent = plugin.get_agent();
430 auto func = plugin.get_unbind();
431 if (func && agent) {
432 return func(agent, dev_id);
433 }
434 return -1;
435}

References Slic3r::BBLNetworkPlugin::instance().

Here is the call graph for this function:

The documentation for this class was generated from the following files: