50 #include <wx/window.h> 54 std::vector<wxVector<wxVariant>> device_list;
61 std::vector<rcdiscover::DeviceInfo> infos;
66 std::sort(infos.begin(), infos.end());
67 const auto it = std::unique(infos.begin(), infos.end(),
71 return lhs.
getMAC() == rhs.getMAC() &&
75 infos.erase(it, infos.end());
77 std::vector<std::future<bool>> reachable(infos.size());
79 infos.begin(), infos.end(), reachable.begin(),
85 : std::future<bool>{};
91 for (
auto info_it = infos.cbegin(); info_it != infos.cend(); ++info_it, ++i)
93 const auto& info = *info_it;
99 if (last_info && last_info->getMAC() == info.getMAC())
103 info.getIfaceName());
109 const std::string &name = info.
getUserName().empty()
110 ? info.getModelName()
111 : info.getUserName();
113 const std::string &manufacturer = info.getManufacturerName();
124 reachable[i].
get() ? L
"\u2713" : L
"\u2717");
126 device_list.push_back(std::move(data));
129 catch (
const std::exception &ex)
131 wxThreadEvent event(wxEVT_COMMAND_DISCOVERY_ERROR);
132 event.SetString(ex.what());
133 parent_->GetEventHandler()->QueueEvent(event.Clone());
138 wxThreadEvent event(wxEVT_COMMAND_DISCOVERY_COMPLETED);
139 event.SetPayload(device_list);
140 parent_->GetEventHandler()->QueueEvent(event.Clone());
std::string ip2string(const uint32_t ip)
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.
uint64_t getMAC() const
Returns 6 bytes with the MAC address of the device.
bool checkReachabilityOfSensor(const DeviceInfo &info)
Check whether an device is reachable via ICMP.
const std::string & getUserName() const
Returns the user name.
const std::string & getIfaceName() const
Returns the name of the interface on which this device was found.