diff --git a/src/aprs.rs b/src/aprs.rs index 13f048a8e8e1e09c3f7f059433bd133626f60a57..a72a5bde429799602d21f18763e40a40302a071b 100644 --- a/src/aprs.rs +++ b/src/aprs.rs @@ -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!