| 309 | } |
| 310 | |
| 311 | DWifiCards::ProcessedWifiCards DWifiCards::process_and_evaluate_cards( |
| 312 | const std::vector<WiFiCard>& discovered_cards, const OHDProfile& profile) { |
| 313 | // We need to figure out what's the best usage for the card(s) connected to |
| 314 | // the system based on their capabilities. |
| 315 | std::vector<WiFiCard> monitor_mode_cards{}; |
| 316 | std::optional<WiFiCard> hotspot_card = std::nullopt; |
| 317 | const int n_openhd_wifibroadcast_supported_cards = |
| 318 | n_cards_openhd_wifibroadcast_supported(discovered_cards); |
| 319 | if (n_openhd_wifibroadcast_supported_cards <= 0) { |
| 320 | // no monitor mode cards - use any other card(s) for hotspot |
| 321 | if (!discovered_cards.empty()) { |
| 322 | hotspot_card = discovered_cards.at(0); |
| 323 | } |
| 324 | } else { |
| 325 | for (auto& card : discovered_cards) { |
| 326 | if (card.supports_openhd_wifibroadcast()) { |
| 327 | monitor_mode_cards.push_back(card); |
| 328 | } else { |
| 329 | if (hotspot_card == std::nullopt) { |
| 330 | hotspot_card = card; |
| 331 | } |
| 332 | } |
| 333 | } |
| 334 | } |
| 335 | if (profile.is_air && monitor_mode_cards.size() > 1) { |
| 336 | monitor_mode_cards.resize(1); |
| 337 | } |
| 338 | return {reorder_monitor_mode_cards(monitor_mode_cards), hotspot_card}; |
| 339 | } |
| 340 | |
| 341 | static WiFiCard wait_for_card(const std::string& interface_name) { |
| 342 | while (true) { |
nothing calls this directly
no test coverage detected