From 5ab9056b555b470c59bf9f40fe43633acffda44d Mon Sep 17 00:00:00 2001 From: Janis Hutz Date: Tue, 25 Aug 2026 10:20:21 +0200 Subject: [PATCH] feat: improved payload infra --- src/gpio_utils.rs | 6 +++++- src/mqtt.rs | 3 +-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/gpio_utils.rs b/src/gpio_utils.rs index 22e5877..658ce71 100644 --- a/src/gpio_utils.rs +++ b/src/gpio_utils.rs @@ -132,7 +132,11 @@ impl GPIOController { .get(&instruction.topic) .expect("Failed to load pins data"); println!("Hello World, pin {}", pin.id); - println!("Payload {}", instruction.payload.first().unwrap()); + let mut instr = "".to_string(); + for char in instruction.payload { + instr.push_str(&char.to_string()) + } + println!(instr); if pin.off_timeout > 0 { self.timeout_topics .push((pin.topic.clone(), SystemTime::now(), pin.off_timeout)); diff --git a/src/mqtt.rs b/src/mqtt.rs index 082700b..29e4c12 100644 --- a/src/mqtt.rs +++ b/src/mqtt.rs @@ -39,11 +39,10 @@ pub fn handler(config: Config) { // TODO: handle fails let val = read_pin(&mut topic.gpio); if val != pin_state[i] { - println!("Value change for pin {} detected", topic.id); pin_state[i] = val; client .publish( - String::from(&topic.topic) + &format!("/{}", topic.id), + String::from(&topic.topic), QoS::AtLeastOnce, false, if val == 0 { off.clone() } else { on.clone() },