Skip to content
Snippets Groups Projects
Commit 9f8bbb76 authored by Stephen D's avatar Stephen D
Browse files

wire up commands

parent 964aab47
No related branches found
No related tags found
No related merge requests found
......@@ -123,8 +123,32 @@ impl CommandHandler {
}
let cmd = Command::decode(cmd.as_bytes()).context("Invalid command")?;
// TODO process command
dbg!(cmd);
match cmd {
Command::ReqImageId(id) => self.img_request.send(id)?,
Command::BurstBalloon => {
let (_, stderr) = subprocess::Exec::shell(&self.burst_command)
.communicate()?
.read()?;
if let Some(stderr) = stderr {
if !stderr.is_empty() {
eprintln!("{}", String::from_utf8_lossy(&stderr));
}
}
}
Command::CutPayload => {
let (_, stderr) = subprocess::Exec::shell(&self.cutdown_command)
.communicate()?
.read()?;
if let Some(stderr) = stderr {
if !stderr.is_empty() {
eprintln!("{}", String::from_utf8_lossy(&stderr));
}
}
}
}
Ok(())
}
......@@ -134,6 +158,7 @@ impl CommandHandler {
hasher.update(cmd);
hasher.update(b"|");
hasher.update(id.to_be_bytes());
hasher.update(&self.secret);
// safe to unwrap because we know 16=16,
// even if the compiler doesn't!
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment