Synchronously execute MQTT publish with block_on
This commit is contained in:
parent
5c2f2f60ad
commit
ce7afca13c
@ -27,3 +27,4 @@ async-trait = "0.1"
|
|||||||
# Ini File parser
|
# Ini File parser
|
||||||
rust-ini = "0.21"
|
rust-ini = "0.21"
|
||||||
lazy_static = "1.4"
|
lazy_static = "1.4"
|
||||||
|
futures = "0.3"
|
||||||
|
@ -33,6 +33,7 @@ mod straba;
|
|||||||
|
|
||||||
use std::sync::Mutex;
|
use std::sync::Mutex;
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
|
use futures::executor::block_on;
|
||||||
// Load INI-File handling module
|
// Load INI-File handling module
|
||||||
mod config;
|
mod config;
|
||||||
use config::Config;
|
use config::Config;
|
||||||
@ -659,8 +660,8 @@ fn main_function(parameter1: String, parameter2: Option<String>) -> ExitCode {
|
|||||||
fn fun_publishinfoviamqtt(straba_res: &NextDeparture) {
|
fn fun_publishinfoviamqtt(straba_res: &NextDeparture) {
|
||||||
let topic_in_station: String = format!("{}{}", GlobalConfiguration.lock().unwrap().mqttPrefix, "/inbound/station");
|
let topic_in_station: String = format!("{}{}", GlobalConfiguration.lock().unwrap().mqttPrefix, "/inbound/station");
|
||||||
let station_name: String = format!("{}", straba_res.inbound_station);
|
let station_name: String = format!("{}", straba_res.inbound_station);
|
||||||
//FIXME if mqtt_client.is_connected() {
|
// Execute async publish synchronously
|
||||||
publish_message(topic_in_station.as_str(), station_name.as_str());
|
let _ = block_on(publish_message(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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user