mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-08-05 09:07:39 +00:00
When a user adds a Creality K-series printer (host_type=crealityprint)
and clicks the existing "Browse" button in the Physical Printer dialog,
dispatch to a new CrealityDiscoveryDialog that finds K2 / K2 Plus /
K2 Pro printers on the LAN automatically. For other host types the
button keeps its existing BonjourDialog behaviour.
CrealityHostDiscovery (src/slic3r/Utils/CrealityHostDiscovery.{hpp,cpp})
Wraps the vendored cxmdns wrapper from the previous commit:
static std::vector<CrealityHost> scan(bool probe_info = true);
Calls cxnet::syncDiscoveryService({"Creality", "creality"}) to find
K-series printers via DNS-SD, dedupes by IP, then optionally HTTP
GETs http://<ip>/info on each match to fetch the model code
(F008 = K2 Plus, F012 = K2 Pro, F021 = K2) and MAC. Returns enriched
{ip, hostname, model_code, model_name, mac, cfs_capable} entries.
CrealityDiscoveryDialog (src/slic3r/GUI/CrealityDiscoveryDialog.{hpp,cpp})
Modal dialog with a wxListView showing Model / Hostname / IP per
discovered host. Runs CrealityHostDiscovery::scan() synchronously
with wxBusyCursor + wxWindowDisabler (5-10s total wait). User picks
one, dialog returns the IP via selected_ip().
PhysicalPrinterDialog (src/slic3r/GUI/PhysicalPrinterDialog.cpp)
The "Browse" button's click handler now reads host_type from the
edited config. If htCrealityPrint, opens CrealityDiscoveryDialog
and writes "http://<ip>" into the print_host field. Otherwise the
existing BonjourDialog path runs unchanged -- no behaviour change
for OctoPrint / Moonraker / Klipper users.
No new UI surface: one existing button now does the right thing per
host_type, mirroring how Creality Print discovers its own printers.
46 lines
1.8 KiB
C++
46 lines
1.8 KiB
C++
#ifndef slic3r_CrealityHostDiscovery_hpp_
|
|
#define slic3r_CrealityHostDiscovery_hpp_
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
namespace Slic3r {
|
|
|
|
// One discovered Creality K-series host on the LAN.
|
|
struct CrealityHost
|
|
{
|
|
std::string ip; // dotted-quad IPv4
|
|
std::string service_name; // raw mDNS service type, e.g. "_Creality-543324280CDB19._udp.local."
|
|
std::string hostname; // e.g. "K2-DB19" (derived from service-name suffix)
|
|
std::string model_code; // "F008" / "F012" / "F021" (empty if /info probe failed)
|
|
std::string model_name; // "K2 Plus" / "K2 Pro" / "K2" (empty if model not in our table)
|
|
std::string mac; // from /info if probed
|
|
bool cfs_capable = false; // true when model_code is in the K2 family
|
|
};
|
|
|
|
// Synchronous LAN discovery for Creality K-series printers via DNS-SD mDNS.
|
|
//
|
|
// Sends a meta-discovery query (_services._dns-sd._udp.local.) and listens
|
|
// for ~5 seconds for service announcements whose type-name contains the
|
|
// "Creality" / "creality" substring. K-series firmware announces each
|
|
// printer under a per-device-unique type _Creality-<MAC-derived-hex>._udp.local,
|
|
// so a fixed-name query does not work -- the meta-discovery is the only
|
|
// reliable way to find them.
|
|
//
|
|
// When probe_info is true, each discovered host is followed up with an HTTP
|
|
// GET http://<ip>/info call to fetch the printer's model code (F008/F012/F021)
|
|
// and MAC. The probe step adds ~2-4 seconds per host but yields enriched
|
|
// results that let the UI display "K2" / "K2 Plus" / "K2 Pro" instead of
|
|
// just an IP.
|
|
//
|
|
// Call from a background thread -- the function blocks for at least 5 seconds.
|
|
class CrealityHostDiscovery
|
|
{
|
|
public:
|
|
static std::vector<CrealityHost> scan(bool probe_info = true);
|
|
};
|
|
|
|
} // namespace Slic3r
|
|
|
|
#endif
|