From 32eb1a1237bef6fa92b5484ac5c0fea14fe14de5 Mon Sep 17 00:00:00 2001 From: Matias Denda Date: Mon, 14 Sep 2026 12:39:25 +0000 Subject: [PATCH] Honor an explicit -c config path when -s is given (#11348) The simradio flag (-s) is the first branch of an if/else-if chain that also handles config loading, so it short-circuits every later branch -- including the one for an explicit -c . Skipping config discovery under -s is intended, but a config path the user passed by hand is not discovery, and it is silently ignored today. Move the -s check after the -c branch so an explicit path is always parsed, and skip only the implicit discovery (./config.yaml, /etc/meshtasticd/config.yaml) when -s is given without -c. The radio override then runs after every config source, since -c and its ConfigDirectory entries can both set Lora.Module and -s has to win over them. Doing it there also fixes --check and --output-yaml, which reported the configured module rather than the simulated one because the old override sat behind an early return. Behaviour with a bare -s is unchanged: no YAML is loaded and the radio is the simulator. Co-authored-by: Jonathan Bennett --- src/platform/portduino/PortduinoGlue.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/platform/portduino/PortduinoGlue.cpp b/src/platform/portduino/PortduinoGlue.cpp index 7ac778e3c4..f7aa2726ae 100644 --- a/src/platform/portduino/PortduinoGlue.cpp +++ b/src/platform/portduino/PortduinoGlue.cpp @@ -331,9 +331,9 @@ void portduinoSetup() return; #endif - if (portduino_config.force_simradio == true) { - portduino_config.lora_module = use_simradio; - } else if (configPath != nullptr) { + // An explicit -c is honored even under -s: it also carries non-radio settings + // (EnableUDP, display, GPIO) that have to survive simulated mode. + if (configPath != nullptr) { if (loadConfig(configPath)) { if (!yamlOnly && !configCheck) std::cout << "Using " << configPath << " as config file" << std::endl; @@ -343,6 +343,8 @@ void portduinoSetup() std::cout << "Unable to use " << configPath << " as config file" << std::endl; exit(EXIT_FAILURE); } + } else if (portduino_config.force_simradio) { + // -s with no -c: the simulator brings its own defaults, so skip config discovery. } else if (access("config.yaml", R_OK) == 0) { if (loadConfig("config.yaml")) { if (!yamlOnly && !configCheck) @@ -390,6 +392,12 @@ void portduinoSetup() } } + // Applied after every config source: ConfigDirectory entries can set Lora.Module + // too, and -s must win over all of them, including in --check / --output-yaml. + if (portduino_config.force_simradio) { + portduino_config.lora_module = use_simradio; + } + #ifndef ARCH_PORTDUINO_WASM // --check wins over --output-yaml: asking for validation and getting a config dump // with no report at all would be the more surprising of the two outcomes.