feat: instruction handling

This commit is contained in:
janishutz committed 2026-08-25 10:30:37 +02:00
1 parent 0d74c46b4e
commit 59021bb5a6
1 file changed
+7 -2
+7 -2
View File
@@ -129,12 +129,17 @@ impl GPIOController {
.out_pins .out_pins
.get(&instruction.topic) .get(&instruction.topic)
.expect("Failed to load pins data"); .expect("Failed to load pins data");
println!("Hello World, pin {}", pin.id);
let mut instr = "".to_string(); let mut instr = "".to_string();
for c in &instruction.payload { for c in &instruction.payload {
instr.push(*c as char) instr.push(*c as char)
} }
println!("{}", instr); if instr == "ON" {
pin.gpio.set_high();
} else if instr == "OFF" {
pin.gpio.set_low();
} else {
println!("Received unknown instruction", 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));