diff --git a/src/aprs.rs b/src/aprs.rs index a72a5bde429799602d21f18763e40a40302a071b..0194f44a4489084c2047aa335f922373abed795c 100644 --- a/src/aprs.rs +++ b/src/aprs.rs @@ -61,7 +61,7 @@ impl CommandHandler { } } - pub fn process_forever(&self) { + pub fn process_forever(&mut self) { tokio::runtime::Builder::new_current_thread() .enable_all() .build() @@ -76,7 +76,7 @@ impl CommandHandler { }); } - async fn connect_and_process(&self) -> anyhow::Result<()> { + async fn connect_and_process(&mut self) -> anyhow::Result<()> { // TODO don't hardcode this let mut tnc = Tnc::connect_tcp("localhost:8001").await?; @@ -89,7 +89,7 @@ impl CommandHandler { Ok(()) } - fn process_packet(&self, packet: &AprsPacket) { + fn process_packet(&mut self, packet: &AprsPacket) { if let AprsData::Message(msg) = &packet.data { if msg.addressee == self.callsign.as_bytes() { if let Err(e) = self.process_msg(&msg.text) { @@ -99,7 +99,7 @@ impl CommandHandler { } } - fn process_msg(&self, msg: &[u8]) -> anyhow::Result<()> { + fn process_msg(&mut self, msg: &[u8]) -> anyhow::Result<()> { let msg = String::from_utf8(msg.to_vec())?; let mut iter = msg.split('|'); @@ -122,6 +122,8 @@ impl CommandHandler { bail!("Given ID too small"); } + self.min_id = id + 1; + let cmd = Command::decode(cmd.as_bytes()).context("Invalid command")?; match cmd { diff --git a/src/control.rs b/src/control.rs index 3b7af035c613e5b81b4ec23468b2078f67c40a27..7a21b0ecbe369119e7c08fb3fdffd562894ac121 100644 --- a/src/control.rs +++ b/src/control.rs @@ -66,7 +66,7 @@ impl Controller { // used to request HD images, as well as // to initiate burst/cutdown fn aprs_thread(config: Config, tx: Sender<u8>) { - let handler = CommandHandler::new( + let mut handler = CommandHandler::new( config.callsign, config.secret, config.burst_command,