From 8e3f4f42867bf0b7296c07e9d1b35f51c77ec8d2 Mon Sep 17 00:00:00 2001 From: Ollo Date: Wed, 16 Apr 2025 21:52:09 +0200 Subject: [PATCH] MQTT paho publish is compiling --- client/bin/src/main.rs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/client/bin/src/main.rs b/client/bin/src/main.rs index d3d99cc..4fdc26f 100644 --- a/client/bin/src/main.rs +++ b/client/bin/src/main.rs @@ -1,6 +1,5 @@ use std::{time::Duration, fmt::format}; use std::sync::{RwLock, Mutex, Arc}; -use openssl::string; use paho_mqtt; use str; use bit::BitIndex; @@ -575,6 +574,22 @@ fn main_function(parameter1: String, parameter2: Option) -> ExitCode { // Render start 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 { let st_now = SystemTime::now();