X-Git-Url: https://code.octet-stream.net/m17rt/blobdiff_plain/18349069c27a0b4fb2e39669fb535600805ad160..1a444762d8fd7d48e4f56a87c6bd77f837522d5d:/tools/m17rt-rxpacket/src/main.rs diff --git a/tools/m17rt-rxpacket/src/main.rs b/tools/m17rt-rxpacket/src/main.rs new file mode 100755 index 0000000..1cdd1d8 --- /dev/null +++ b/tools/m17rt-rxpacket/src/main.rs @@ -0,0 +1,37 @@ +use m17app::adapter::PacketAdapter; +use m17app::app::M17App; +use m17app::link_setup::LinkSetup; +use m17app::soundmodem::{InputRrcFile, NullOutputSink, NullPtt, Soundmodem}; +use m17core::protocol::PacketType; +use std::path::PathBuf; +use std::sync::Arc; + +fn main() { + let path = PathBuf::from("../../../Data/mypacket.rrc"); + let soundmodem = Soundmodem::new( + InputRrcFile::new(path), + NullOutputSink::new(), + NullPtt::new(), + ); + let app = M17App::new(soundmodem); + app.add_packet_adapter(PacketPrinter); + app.start(); + + loop { + std::thread::park(); + } +} + +struct PacketPrinter; +impl PacketAdapter for PacketPrinter { + fn packet_received(&self, link_setup: LinkSetup, packet_type: PacketType, content: Arc<[u8]>) { + println!( + "from {} to {} type {:?} len {}", + link_setup.source(), + link_setup.destination(), + packet_type, + content.len() + ); + println!("{}", String::from_utf8_lossy(&content)); + } +}