| 46 | int complainOnce = 0; |
| 47 | |
| 48 | WBLink::WBLink(OHDProfile profile, std::vector<WiFiCard> broadcast_cards) |
| 49 | : m_profile(std::move(profile)), |
| 50 | m_broadcast_cards(std::move(broadcast_cards)), |
| 51 | m_recommended_max_fec_blk_size_for_this_platform( |
| 52 | get_fec_max_block_size_for_platform()) { |
| 53 | m_console = openhd::log::create_or_get("wb_streams"); |
| 54 | assert(m_console); |
| 55 | m_frame_drop_helper.set_console(m_console); |
| 56 | m_console->info("Broadcast cards:{}", debug_cards(m_broadcast_cards)); |
| 57 | // sanity checks |
| 58 | if (m_broadcast_cards.empty() || |
| 59 | (m_profile.is_air && m_broadcast_cards.size() > 1)) { |
| 60 | // NOTE: Here we crash, since it would be a programmer(s) error |
| 61 | // Air needs exactly one wifi card |
| 62 | // ground supports rx diversity, therefore can have more than one card |
| 63 | m_console->error( |
| 64 | "Without at least one wifi card, the stream(s) cannot be started"); |
| 65 | exit(1); |
| 66 | } |
| 67 | // this fetches the last settings, otherwise creates default ones |
| 68 | m_settings = std::make_unique<openhd::WBLinkSettingsHolder>( |
| 69 | m_profile, m_broadcast_cards); |
| 70 | WBTxRx::Options txrx_options{}; |
| 71 | txrx_options.session_key_packet_interval = SESSION_KEY_PACKETS_INTERVAL; |
| 72 | txrx_options.use_gnd_identifier = m_profile.is_ground(); |
| 73 | txrx_options.debug_rssi = 0; |
| 74 | txrx_options.debug_multi_rx_packets_variance = false; |
| 75 | txrx_options.tx_without_pcap = true; |
| 76 | txrx_options.set_tx_sock_qdisc_bypass = true; |
| 77 | txrx_options.enable_auto_switch_tx_card = false; // TODO remove me |
| 78 | txrx_options.max_sane_injection_time = std::chrono::milliseconds(1); |
| 79 | txrx_options.rx_radiotap_debug_level = |
| 80 | openhd::load_config().GEN_RF_METRICS_LEVEL; |
| 81 | // txrx_options.advanced_debugging_rx= true; |
| 82 | // txrx_options.debug_decrypt_time= true; |
| 83 | // txrx_options.debug_encrypt_time= true; |
| 84 | // txrx_options.debug_packet_gaps= true; |
| 85 | if (OHDFilesystemUtil::exists(openhd::SECURITY_KEYPAIR_FILENAME)) { |
| 86 | txrx_options.secure_keypair = |
| 87 | wb::read_keypair_from_file(openhd::SECURITY_KEYPAIR_FILENAME); |
| 88 | m_console->debug("Using key from file {}", |
| 89 | openhd::SECURITY_KEYPAIR_FILENAME); |
| 90 | } else { |
| 91 | txrx_options.secure_keypair = std::nullopt; |
| 92 | m_console->debug("Using key from default bind phrase"); |
| 93 | } |
| 94 | // txrx_options.log_all_received_packets= true; |
| 95 | // txrx_options.log_all_received_validated_packets= true; |
| 96 | // txrx_options.advanced_latency_debugging_rx=true; |
| 97 | // const auto card_names = openhd::wb::get_card_names(m_broadcast_cards); |
| 98 | // assert(!card_names.empty()); |
| 99 | std::vector<wifibroadcast::WifiCard> tmp_wifi_cards; |
| 100 | for (const auto& card : m_broadcast_cards) { |
| 101 | if (card.type == WiFiCardType::OPENHD_EMULATED) { |
| 102 | assert(m_broadcast_cards.size() == 1); |
| 103 | tmp_wifi_cards.push_back( |
| 104 | wifibroadcast::create_card_emulate(m_profile.is_air)); |
| 105 | } else { |
nothing calls this directly
no test coverage detected