]> code.octet-stream.net Git - m17rt/blob - tools/m17rt-rxpacket/src/main.rs
1cdd1d89ef054fe418398b15fd9866a765421ae1
[m17rt] / tools / m17rt-rxpacket / src / main.rs
1 use m17app::adapter::PacketAdapter;
2 use m17app::app::M17App;
3 use m17app::link_setup::LinkSetup;
4 use m17app::soundmodem::{InputRrcFile, NullOutputSink, NullPtt, Soundmodem};
5 use m17core::protocol::PacketType;
6 use std::path::PathBuf;
7 use std::sync::Arc;
8
9 fn main() {
10 let path = PathBuf::from("../../../Data/mypacket.rrc");
11 let soundmodem = Soundmodem::new(
12 InputRrcFile::new(path),
13 NullOutputSink::new(),
14 NullPtt::new(),
15 );
16 let app = M17App::new(soundmodem);
17 app.add_packet_adapter(PacketPrinter);
18 app.start();
19
20 loop {
21 std::thread::park();
22 }
23 }
24
25 struct PacketPrinter;
26 impl PacketAdapter for PacketPrinter {
27 fn packet_received(&self, link_setup: LinkSetup, packet_type: PacketType, content: Arc<[u8]>) {
28 println!(
29 "from {} to {} type {:?} len {}",
30 link_setup.source(),
31 link_setup.destination(),
32 packet_type,
33 content.len()
34 );
35 println!("{}", String::from_utf8_lossy(&content));
36 }
37 }