51 #include <wx/window.h> 55 std::vector<wxVector<wxVariant>> device_list;
62 std::chrono::steady_clock::time_point tstart=std::chrono::steady_clock::now();
63 std::chrono::steady_clock::time_point tend=tstart;
65 std::vector<rcdiscover::DeviceInfo> infos;
68 std::chrono::duration<double, std::milli>(tend-tstart).count() < 1000)
70 tend=std::chrono::steady_clock::now();
73 std::sort(infos.begin(), infos.end());
74 const auto it = std::unique(infos.begin(), infos.end(),
78 return lhs.
getMAC() == rhs.getMAC() &&
82 infos.erase(it, infos.end());
84 std::vector<std::future<bool>> reachable(infos.size());
86 infos.begin(), infos.end(), reachable.begin(),
92 : std::future<bool>{};
98 for (
auto info_it = infos.cbegin(); info_it != infos.cend(); ++info_it, ++i)
100 const auto& info = *info_it;
106 if (last_info && last_info->getMAC() == info.getMAC())
110 info.getIfaceName());
116 const std::string &name = info.
getUserName().empty()
117 ? info.getModelName()
118 : info.getUserName();
120 const std::string &manufacturer = info.getManufacturerName();
131 reachable[i].
get() ? L
"\u2713" : L
"\u2717");
133 device_list.push_back(std::move(data));
136 catch (
const std::exception &ex)
138 wxThreadEvent event(wxEVT_COMMAND_DISCOVERY_ERROR);
139 event.SetString(ex.what());
140 parent_->GetEventHandler()->QueueEvent(event.Clone());
145 wxThreadEvent event(wxEVT_COMMAND_DISCOVERY_COMPLETED);
146 event.SetPayload(device_list);
147 parent_->GetEventHandler()->QueueEvent(event.Clone());
const std::string & getIfaceName() const
Returns the name of the interface on which this device was found.
std::string ip2string(const uint32_t ip)
uint64_t getMAC() const
Returns 6 bytes with the MAC address of the device.
void broadcastRequest()
Broadcasts a discovery command request.
std::string mac2string(const uint64_t mac)
virtual ExitCode Entry() override
bool getResponse(std::vector< DeviceInfo > &info, int timeout_per_socket=1000)
Returns a discovery response.
const std::string & getUserName() const
Returns the user name.
bool checkReachabilityOfSensor(const DeviceInfo &info)
Check whether an device is reachable via ICMP.