MQTT paho publish is compiling

This commit is contained in:
Ollo 2025-04-16 21:52:09 +02:00
parent 922c023216
commit 8e3f4f4286

View File

@ -1,6 +1,5 @@
use std::{time::Duration, fmt::format}; use std::{time::Duration, fmt::format};
use std::sync::{RwLock, Mutex, Arc}; use std::sync::{RwLock, Mutex, Arc};
use openssl::string;
use paho_mqtt; use paho_mqtt;
use str; use str;
use bit::BitIndex; use bit::BitIndex;
@ -575,6 +574,22 @@ 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
{
let topicInStation = format!("{}{}", GlobalConfiguration.mqttPrefix, "/inbound/station");
let payload = straba_res.outbound_station.as_bytes(); //Get the payload as a &[u8]
let mc = mqtt_client.as_ref().unwrap();
let message = paho_mqtt::Message::new ( topicInStation.as_str(),
payload,
0
);
mc.publish(message);
println!("MQTT published {:?} = {:?}s", topicInStation, straba_res.outbound_station);
}
loop { loop {
let st_now = SystemTime::now(); let st_now = SystemTime::now();