mirror of
https://github.com/meshtastic/firmware.git
synced 2026-09-17 00:52:45 -04:00
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 <path>. 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 <jbennett@incomsystems.biz>
This commit is contained in:
1 parent
ee15508494
commit
32eb1a1237
1 file changed
+11
-3
@@ -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.
|
||||
|
||||
Reference in new issue
Block a user