feat: improved payload infra

This commit is contained in:
janishutz committed 2026-08-25 10:20:21 +02:00
1 parent cd0f894e73
commit 5ab9056b55
2 files changed
+6 -3

No files matched your search

+5 -1
View File
@@ -132,7 +132,11 @@ impl GPIOController {
.get(&instruction.topic) .get(&instruction.topic)
.expect("Failed to load pins data"); .expect("Failed to load pins data");
println!("Hello World, pin {}", pin.id); 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 { if pin.off_timeout > 0 {
self.timeout_topics self.timeout_topics
.push((pin.topic.clone(), SystemTime::now(), pin.off_timeout)); .push((pin.topic.clone(), SystemTime::now(), pin.off_timeout));
+1 -2
View File
@@ -39,11 +39,10 @@ pub fn handler(config: Config) {
// TODO: handle fails // TODO: handle fails
let val = read_pin(&mut topic.gpio); let val = read_pin(&mut topic.gpio);
if val != pin_state[i] { if val != pin_state[i] {
println!("Value change for pin {} detected", topic.id);
pin_state[i] = val; pin_state[i] = val;
client client
.publish( .publish(
String::from(&topic.topic) + &format!("/{}", topic.id), String::from(&topic.topic),
QoS::AtLeastOnce, QoS::AtLeastOnce,
false, false,
if val == 0 { off.clone() } else { on.clone() }, if val == 0 { off.clone() } else { on.clone() },