]> code.octet-stream.net Git - m17rt/blob - tools/m17rt-rxpacket/src/main.rs
Fix timing bugs and add documentation
[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::soundcard::Soundcard;
5 use m17app::soundmodem::{NullOutputSink, NullPtt, Soundmodem};
6 use m17app::PacketType;
7 use std::sync::Arc;
8
9 fn main() {
10 let soundcard = Soundcard::new("plughw:CARD=Device,DEV=0").unwrap();
11 let soundmodem = Soundmodem::new(soundcard.input(), NullOutputSink::new(), NullPtt::new());
12 let app = M17App::new(soundmodem);
13 app.add_packet_adapter(PacketPrinter);
14 app.start();
15
16 loop {
17 std::thread::park();
18 }
19 }
20
21 struct PacketPrinter;
22 impl PacketAdapter for PacketPrinter {
23 fn packet_received(&self, link_setup: LinkSetup, packet_type: PacketType, content: Arc<[u8]>) {
24 println!(
25 "from {} to {} type {:?} len {}",
26 link_setup.source(),
27 link_setup.destination(),
28 packet_type,
29 content.len()
30 );
31 println!("{}", String::from_utf8_lossy(&content));
32 }
33 }