mirror of
https://github.com/janishutz/mqtt-remote-gpio.git
synced 2026-10-09 05:06:21 +02:00
feat: instruction handling
This commit is contained in:
1 parent
0d74c46b4e
commit
59021bb5a6
1 file changed
+7
-2
+7
-2
@@ -129,12 +129,17 @@ impl GPIOController {
|
||||
.out_pins
|
||||
.get(&instruction.topic)
|
||||
.expect("Failed to load pins data");
|
||||
println!("Hello World, pin {}", pin.id);
|
||||
let mut instr = "".to_string();
|
||||
for c in &instruction.payload {
|
||||
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 {
|
||||
self.timeout_topics
|
||||
.push((pin.topic.clone(), SystemTime::now(), pin.off_timeout));
|
||||
|
||||
Reference in new issue
Block a user