| 148 | } |
| 149 | |
| 150 | void 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 | |
| 185 | void EthernetManager::stop() { |
| 186 | m_console->warn("stop begin"); |
nothing calls this directly
no test coverage detected