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

Method OHDInterface

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

Source from the content-addressed store, hash-verified

63}
64
65OHDInterface::OHDInterface(OHDProfile profile1)
66 : m_profile(std::move(profile1)) {
67 m_console = openhd::log::create_or_get("interface");
68 assert(m_console);
69 m_monitor_mode_cards = {};
70 m_opt_hotspot_card = std::nullopt;
71 const auto config = openhd::load_config();
72 bool microhard_device_present = is_microhard_device_present();
73
74 if (OHDFilesystemUtil::exists(std::string(getConfigBasePath()) +
75 "ethernet.txt")) {
76 m_ethernet_link = std::make_shared<EthernetLink>(m_profile);
77 m_console->warn("eth found");
78 return;
79 }
80
81 if (microhard_device_present) {
82 m_microhard_link = std::make_shared<MicrohardLink>(m_profile);
83 m_console->warn("mc found");
84 return;
85 }
86
87 DWifiCards::main_discover_an_process_wifi_cards(
88 config, m_profile, m_console, m_monitor_mode_cards, m_opt_hotspot_card);
89 m_console->debug("monitor_mode card(s):{}",
90 debug_cards(m_monitor_mode_cards));
91 if (m_opt_hotspot_card.has_value()) {
92 m_console->debug("Hotspot card:{}", m_opt_hotspot_card.value().device_name);
93 } else {
94 m_console->debug("No WiFi hotspot card");
95 }
96 // We don't have at least one card for monitor mode, which means we cannot
97 // instantiate wb_link (no wifibroadcast connectivity at all)
98 if (m_monitor_mode_cards.empty()) {
99 m_console->warn(
100 "Cannot start ohd_interface, no wifi card for monitor mode");
101 const std::string message_for_user = "No WiFi card found, please reboot";
102 m_console->warn(message_for_user);
103 openhd::LEDManager::instance().set_status_error();
104 // TODO reason what to do. We do not support dynamically adding wifi cards
105 // at run time, so somehow we need to signal to the user that something is
106 // completely wrong. However, as an Ground pi, we can still run QOpenHD and
107 // OpenHD, just it will never connect to an Air PI
108 } else {
109 // Set the card(s) we have into monitor mode
110 openhd::wb::takeover_cards_monitor_mode(m_monitor_mode_cards, m_console);
111 m_wb_link = std::make_shared<WBLink>(m_profile, m_monitor_mode_cards);
112 }
113 // The USB tethering listener is always enabled on ground - it doesn't
114 // interfere with anything
115 if (m_profile.is_ground()) {
116 // The USB tethering listener is always enabled on ground - it doesn't
117 // interfere with anything
118 m_usb_tether_listener = std::make_unique<USBTetherListener>();
119 }
120 // Ethernet - optional, only on ground
121 if (m_profile.is_ground()) {
122 m_ethernet_manager = std::make_unique<EthernetManager>();

Callers

nothing calls this directly

Calls 9

getConfigBasePathFunction · 0.85
debug_cardsFunction · 0.85
debugMethod · 0.80
set_status_errorMethod · 0.80
is_groundMethod · 0.80
async_initializeMethod · 0.80
register_listenerMethod · 0.45

Tested by

no test coverage detected