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();
|
let configOrMqttAddress: String = parameter2.unwrap();
|
||||||
if Path::new(&configOrMqttAddress).exists()
|
if Path::new(&configOrMqttAddress).exists()
|
||||||
{
|
{
|
||||||
read_ini_file(configOrMqttAddress).expect("Failed to load config file");
|
match read_ini_file(configOrMqttAddress).expect("Failed to load config file") {
|
||||||
println!("Config parsed");
|
Ok(config) => {
|
||||||
|
println!("File contents: {}", config);
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
eprintln!("Error reading file: {}", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -613,11 +620,6 @@ fn main_function(parameter1: String, parameter2: Option<String>) -> ExitCode {
|
|||||||
// Render start
|
// Render start
|
||||||
send_package(GlobalConfiguration.panelIPAddress.clone(), &last_data, &straba_res, Some("MQTT: room/ledboard".to_string()));
|
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 {
|
loop {
|
||||||
let st_now = SystemTime::now();
|
let st_now = SystemTime::now();
|
||||||
@ -643,13 +645,23 @@ fn main_function(parameter1: String, parameter2: Option<String>) -> ExitCode {
|
|||||||
device_online = check_connection(GlobalConfiguration.mqttIPAddress.clone());
|
device_online = check_connection(GlobalConfiguration.mqttIPAddress.clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
// request once a minute new data
|
||||||
if device_online == true {
|
|
||||||
straba_res = straba::fetch_data(None);
|
straba_res = straba::fetch_data(None);
|
||||||
println!("Update {:?} {:?}s", straba_res.outbound_station, straba_res.outbound_diff);
|
println!("Update {:?} {:?}s", straba_res.outbound_station, straba_res.outbound_diff);
|
||||||
println!("Update {:?} {:?}s", straba_res.inbound_station , straba_res.inbound_diff);
|
println!("Update {:?} {:?}s", straba_res.inbound_station , straba_res.inbound_diff);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
let lock = mqtt_message.lock().unwrap();
|
let lock = mqtt_message.lock().unwrap();
|
||||||
let mqtt_message: Option<String>;
|
let mqtt_message: Option<String>;
|
||||||
@ -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 topic_in_station: String = format!("{}{}", GlobalConfiguration.mqttPrefix, "/inbound/station");
|
||||||
let station_name: String = format!("{}", straba_res.inbound_station);
|
let station_name: String = format!("{}", straba_res.inbound_station);
|
||||||
if (mqtt_client.is_some()) {
|
if mqtt_client.is_connected() {
|
||||||
publish_message(mqtt_client.unwrap(), topic_in_station.as_str(), station_name.as_str());
|
publish_message(mqtt_client, topic_in_station.as_str(), station_name.as_str());
|
||||||
println!("MQTT published {:?} = {:?}s", topic_in_station, straba_res.outbound_station);
|
println!("MQTT published {:?} = {:?}s", topic_in_station, straba_res.outbound_station);
|
||||||
} else {
|
} else {
|
||||||
println!("MQTT not ready... {:?} = {:?}s", topic_in_station, straba_res.outbound_station);
|
println!("MQTT not ready... {:?} = {:?}s", topic_in_station, straba_res.outbound_station);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user