Parsing ini file does not work
This commit is contained in:
parent
9d3dfda37e
commit
0041d1c30c
@ -499,8 +499,15 @@ fn main_function(parameter1: String, parameter2: Option<String>) -> ExitCode {
|
||||
let configOrMqttAddress: String = parameter2.unwrap();
|
||||
if Path::new(&configOrMqttAddress).exists()
|
||||
{
|
||||
read_ini_file(configOrMqttAddress).expect("Failed to load config file");
|
||||
println!("Config parsed");
|
||||
match read_ini_file(configOrMqttAddress).expect("Failed to load config file") {
|
||||
Ok(config) => {
|
||||
println!("File contents: {}", config);
|
||||
}
|
||||
Err(e) => {
|
||||
eprintln!("Error reading file: {}", e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -613,11 +620,6 @@ fn main_function(parameter1: String, parameter2: Option<String>) -> ExitCode {
|
||||
// Render start
|
||||
send_package(GlobalConfiguration.panelIPAddress.clone(), &last_data, &straba_res, Some("MQTT: room/ledboard".to_string()));
|
||||
}
|
||||
else if GlobalConfiguration.mqttPrefix.len() > 0
|
||||
{
|
||||
fun_publishinfoviamqtt(mqtt_client, &straba_res);
|
||||
}
|
||||
|
||||
|
||||
loop {
|
||||
let st_now = SystemTime::now();
|
||||
@ -643,12 +645,22 @@ fn main_function(parameter1: String, parameter2: Option<String>) -> ExitCode {
|
||||
device_online = check_connection(GlobalConfiguration.mqttIPAddress.clone());
|
||||
}
|
||||
|
||||
// request once a minute new data
|
||||
if device_online == true {
|
||||
straba_res = straba::fetch_data(None);
|
||||
println!("Update {:?} {:?}s", straba_res.outbound_station, straba_res.outbound_diff);
|
||||
println!("Update {:?} {:?}s", straba_res.inbound_station , straba_res.inbound_diff);
|
||||
if GlobalConfiguration.mqttPrefix.len() > 0
|
||||
{
|
||||
if mqtt_client.is_some()
|
||||
{
|
||||
fun_publishinfoviamqtt(mqtt_client.clone().unwrap(), &straba_res);
|
||||
}
|
||||
else
|
||||
{
|
||||
println!("Update MQTT not possible");
|
||||
}
|
||||
}
|
||||
|
||||
// request once a minute new data
|
||||
straba_res = straba::fetch_data(None);
|
||||
println!("Update {:?} {:?}s", straba_res.outbound_station, straba_res.outbound_diff);
|
||||
println!("Update {:?} {:?}s", straba_res.inbound_station , straba_res.inbound_diff);
|
||||
}
|
||||
|
||||
let lock = mqtt_message.lock().unwrap();
|
||||
@ -668,11 +680,11 @@ fn main_function(parameter1: String, parameter2: Option<String>) -> ExitCode {
|
||||
}
|
||||
}
|
||||
|
||||
fn fun_publishinfoviamqtt(mqtt_client: Option<AsyncClient>, straba_res: &NextDeparture) {
|
||||
fn fun_publishinfoviamqtt(mqtt_client: AsyncClient, straba_res: &NextDeparture) {
|
||||
let topic_in_station: String = format!("{}{}", GlobalConfiguration.mqttPrefix, "/inbound/station");
|
||||
let station_name: String = format!("{}", straba_res.inbound_station);
|
||||
if (mqtt_client.is_some()) {
|
||||
publish_message(mqtt_client.unwrap(), topic_in_station.as_str(), station_name.as_str());
|
||||
if mqtt_client.is_connected() {
|
||||
publish_message(mqtt_client, topic_in_station.as_str(), station_name.as_str());
|
||||
println!("MQTT published {:?} = {:?}s", topic_in_station, straba_res.outbound_station);
|
||||
} else {
|
||||
println!("MQTT not ready... {:?} = {:?}s", topic_in_station, straba_res.outbound_station);
|
||||
|
Loading…
x
Reference in New Issue
Block a user