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

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

Static Public Member Functions

static std::vector< CrealityHost > scan (bool probe_info=true)

Detailed Description

Member Function Documentation

◆ scan()

std::vector< CrealityHost > Slic3r::CrealityHostDiscovery::scan ( bool probe_info = true)
static
83{
84 const std::vector<std::string> prefixes{ "Creality", "creality" };
85
86 BOOST_LOG_TRIVIAL(info)
87 << "CrealityHostDiscovery: starting DNS-SD discovery (prefixes: Creality, creality)";
88
89 auto raw = cxnet::syncDiscoveryService(prefixes);
90
91 BOOST_LOG_TRIVIAL(info)
92 << "CrealityHostDiscovery: mDNS returned " << raw.size() << " match(es)";
93
94 std::vector<CrealityHost> hosts;
95 hosts.reserve(raw.size());
96
97 // Dedupe by IP -- one printer may announce twice if multi-homed or if
98 // we capture both IPv4/IPv6 replies.
99 std::vector<std::string> seen_ips;
100 for (const auto& m : raw) {
101 if (m.machineIp.empty()) continue;
102 if (std::find(seen_ips.begin(), seen_ips.end(), m.machineIp) != seen_ips.end())
103 continue;
104 seen_ips.push_back(m.machineIp);
105
106 CrealityHost h;
107 h.ip = m.machineIp;
108 h.service_name = m.answer;
109 h.hostname = hostname_from_service(m.answer);
110
111 if (probe) {
112 probe_info(h);
113 }
114
115 hosts.push_back(std::move(h));
116 }
117
118 BOOST_LOG_TRIVIAL(info)
119 << "CrealityHostDiscovery: " << hosts.size() << " unique host(s) after dedup";
120
121 return hosts;
122}
std::string hostname_from_service(const std::string &service_name)
Definition CrealityHostDiscovery.cpp:34
void probe_info(CrealityHost &host)
Definition CrealityHostDiscovery.cpp:49

References Slic3r::CrealityHost::hostname, Slic3r::CrealityHost::ip, and Slic3r::CrealityHost::service_name.

Referenced by Slic3r::GUI::CrealityDiscoveryDialog::run_discovery().

Here is the caller graph for this function:

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