Update all fields of ini configuration
This commit is contained in:
parent
cef76ad9aa
commit
2fcf37bfdc
@ -47,11 +47,7 @@ impl Config {
|
||||
// Function to read the INI file
|
||||
pub fn read_ini_file(filename: String) -> Config {
|
||||
|
||||
let mut config = Config { mqttPrefix: "room/ledboard".to_string(),
|
||||
mqttIPAddress: String::new(),
|
||||
panelIPAddress: String::new(),
|
||||
refreshInterval: DEFAULT_REFRESH_INTERVAL
|
||||
};
|
||||
let mut config = Config::newDefault();
|
||||
let i = Ini::load_from_file(filename).unwrap();
|
||||
for (sec, prop) in i.iter() {
|
||||
|
||||
@ -79,4 +75,4 @@ pub fn read_ini_file(filename: String) -> Config {
|
||||
}
|
||||
}
|
||||
return config;
|
||||
}
|
||||
}
|
||||
|
@ -453,22 +453,27 @@ fn main_function(parameter1: String, parameter2: Option<String>) -> ExitCode {
|
||||
let configOrMqttAddress: String = parameter2.unwrap();
|
||||
if Path::new(&configOrMqttAddress).exists()
|
||||
{
|
||||
let c:Config = read_ini_file(configOrMqttAddress);
|
||||
|
||||
//FIMXE update configuration
|
||||
let mut gc = GlobalConfiguration.lock().unwrap();
|
||||
println!("Global: {:?} ", &c.panelIPAddress);
|
||||
let c = read_ini_file(configOrMqttAddress);
|
||||
|
||||
//update configuration
|
||||
gc.mqttIPAddress = c.mqttIPAddress;
|
||||
gc.panelIPAddress = c.panelIPAddress;
|
||||
gc.mqttPrefix = c.mqttPrefix;
|
||||
println!("Read INI {:} @ {:}", gc.mqttPrefix, gc.mqttIPAddress);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Panel and MQTT Configured*/
|
||||
|
||||
println!("INI file not found");
|
||||
return ExitCode::FAILURE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
let mut gc = GlobalConfiguration.lock().unwrap();
|
||||
gc.panelIPAddress = parameter1;
|
||||
gc.mqttIPAddress = parameter2.unwrap();
|
||||
}
|
||||
|
||||
let mut device_online = false;
|
||||
|
Loading…
x
Reference in New Issue
Block a user