MCPcopy Create free account
hub / github.com/OpenHD/OpenHD / loop

Method loop

OpenHD/ohd_interface/src/ethernet_manager.cpp:150–183  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

148}
149
150void EthernetManager::loop(int operating_mode) {
151 if (operating_mode == ETHERNET_OPERATING_MODE_UNTOUCHED) {
152 delete_existing_hotspot_connection();
153 return;
154 }
155 // First, we need to find the ethernet adapter. On some platforms, it's name
156 // is fixed (built in) If a usb to ethernet is used, that's not the case
157 std::optional<std::string> opt_ethernet_card = std::nullopt;
158 const auto platform = OHDPlatform::instance();
159 const auto config = openhd::load_config();
160 if (openhd::nw_ethernet_card_manual_active(config)) {
161 opt_ethernet_card = config.NW_ETHERNET_CARD;
162 } else if (platform.is_rpi()) {
163 opt_ethernet_card = std::string("eth0");
164 } else if (platform.is_rock5_b()) {
165 opt_ethernet_card = "enP4p65s0";
166 } else if (platform.is_rock5_a()) {
167 opt_ethernet_card = "eth0";
168 }
169 if (opt_ethernet_card == std::nullopt) {
170 // We need to figure out the ethernet card ourselves
171 while (!m_terminate) {
172 auto card = find_ethernet_device_name();
173 if (card.has_value()) {
174 opt_ethernet_card = card;
175 break;
176 }
177 std::this_thread::sleep_for(std::chrono::seconds(1));
178 }
179 }
180 if (opt_ethernet_card) {
181 configure(operating_mode, opt_ethernet_card.value());
182 }
183}
184
185void EthernetManager::stop() {
186 m_console->warn("stop begin");

Callers

nothing calls this directly

Calls 5

is_rpiMethod · 0.80
is_rock5_bMethod · 0.80
is_rock5_aMethod · 0.80

Tested by

no test coverage detected