diff --git a/src/MainController.cpp b/src/MainController.cpp index 29e30f5..534a69a 100644 --- a/src/MainController.cpp +++ b/src/MainController.cpp @@ -289,8 +289,15 @@ void MainController::initInterface() } this->wifiController.createMonitorInteface(); std::this_thread::sleep_for(std::chrono::milliseconds(500)); - this->wifiController.createApInteface(); - std::this_thread::sleep_for(std::chrono::milliseconds(500)); + // The AP interface is only used by FTM. measure/inject operate on the monitor interface, + // which createMonitorInteface() has already tuned to the requested frequency. Creating the + // AP unconditionally makes its bring-up fail on no-IR channels (e.g. 5/6 GHz under the world + // regdomain 00), which throws and aborts the whole run. + if (Arguments::arguments.ftm || Arguments::arguments.ftmResponder) + { + this->wifiController.createApInteface(); + std::this_thread::sleep_for(std::chrono::milliseconds(500)); + } } catch(const std::exception& e) { @@ -311,7 +318,11 @@ void *MainController::measureCsi(void *arg) { try { - MainController::getInstance()->wifiController.setInterfaceUpDown(AP_INTERFACE_NAME, false); + // The AP interface only exists for FTM (see initInterface); don't touch it otherwise. + if (Arguments::arguments.ftm || Arguments::arguments.ftmResponder) + { + MainController::getInstance()->wifiController.setInterfaceUpDown(AP_INTERFACE_NAME, false); + } MainController::getInstance()->wifiController.setInterfaceUpDown(MONITOR_INTERFACE_NAME, true); WiFiCsiController wcs; wcs.init(); @@ -488,7 +499,11 @@ void *MainController::injectPackets(void *arg) { try { - MainController::getInstance()->wifiController.setInterfaceUpDown(AP_INTERFACE_NAME, false); + // The AP interface only exists for FTM (see initInterface); don't touch it otherwise. + if (Arguments::arguments.ftm || Arguments::arguments.ftmResponder) + { + MainController::getInstance()->wifiController.setInterfaceUpDown(AP_INTERFACE_NAME, false); + } MainController::getInstance()->wifiController.setInterfaceUpDown(MONITOR_INTERFACE_NAME, true); PacketInjector pi; if (Arguments::arguments.injectRepeat)