Prepare ini parsing, but updating global variable is not possible

This commit is contained in:
Ollo 2025-04-20 21:45:43 +02:00
parent 0041d1c30c
commit a526e5fb22

View File

@ -312,7 +312,7 @@ struct Config {
// Function to read the INI file // Function to read the INI file
fn read_ini_file(filename: String) -> Result<Config, std::io::Error> { fn read_ini_file(filename: String) -> Config {
let mut config = Config { mqttPrefix: "room/ledboard".to_string(), let mut config = Config { mqttPrefix: "room/ledboard".to_string(),
mqttIPAddress: String::new(), mqttIPAddress: String::new(),
@ -345,7 +345,7 @@ fn read_ini_file(filename: String) -> Result<Config, std::io::Error> {
} }
} }
} }
Ok(config) return config;
} }
// Callback for a successful connection to the broker. // Callback for a successful connection to the broker.
@ -499,15 +499,11 @@ fn main_function(parameter1: String, parameter2: Option<String>) -> ExitCode {
let configOrMqttAddress: String = parameter2.unwrap(); let configOrMqttAddress: String = parameter2.unwrap();
if Path::new(&configOrMqttAddress).exists() if Path::new(&configOrMqttAddress).exists()
{ {
match read_ini_file(configOrMqttAddress).expect("Failed to load config file") { let c:Config = read_ini_file(configOrMqttAddress);
Ok(config) => {
println!("File contents: {}", config); //FIMXE update configuration
} //GlobalConfiguration.panelIPAddress = c.panelIPAddress;
Err(e) => { //println!("Global: {:} ", &GlobalConfiguration.panelIPAddress);
eprintln!("Error reading file: {}", e);
}
}
} }
else else
{ {