]> code.octet-stream.net Git - m17rt/blobdiff - tools/m17rt-txpacket/src/main.rs
New Soundcard struct, use it in test programs
[m17rt] / tools / m17rt-txpacket / src / main.rs
index 538291aecfd55fa3a5043fb7c91c41b2fc6496dd..fb6eda19368dc61ea73934c383a0a5be9b181171 100644 (file)
@@ -1,33 +1,26 @@
 use m17app::app::M17App;
 use m17app::link_setup::{LinkSetup, M17Address};
 use m17app::app::M17App;
 use m17app::link_setup::{LinkSetup, M17Address};
-use m17app::soundmodem::{
-    InputRrcFile, InputSoundcard, NullInputSource, NullOutputSink, NullPtt, OutputRrcFile,
-    OutputSoundcard, Soundmodem,
-};
+use m17app::serial::{PttPin, SerialPtt};
+use m17app::soundcard::Soundcard;
+use m17app::soundmodem::Soundmodem;
 use m17core::protocol::PacketType;
 use m17core::protocol::PacketType;
-use std::path::PathBuf;
 
 
-pub fn mod_test() {
-    let out_path = PathBuf::from("../../../Data/mypacket.rrc");
-    let output = OutputRrcFile::new(out_path);
-    //let output = OutputSoundcard::new();
-    let soundmodem = Soundmodem::new(NullInputSource::new(), output, NullPtt::new());
+fn main() {
+    let soundcard = Soundcard::new("plughw:CARD=Device,DEV=0").unwrap();
+    let ptt = SerialPtt::new("/dev/ttyUSB0", PttPin::Rts);
+    let soundmodem = Soundmodem::new(soundcard.input(), soundcard.output(), ptt);
     let app = M17App::new(soundmodem);
     let app = M17App::new(soundmodem);
+
     app.start();
     app.start();
-    std::thread::sleep(std::time::Duration::from_secs(1));
-    println!("Transmitting packet...");
 
 
-    let source = M17Address::from_callsign("VK7XT").unwrap();
+    println!("Transmitting packet...");
+    let source = M17Address::from_callsign("VK7XT-1").unwrap();
     let destination = M17Address::new_broadcast();
     let link_setup = LinkSetup::new_packet(&source, &destination);
     let payload = b"Hello, world!";
     app.tx()
     let destination = M17Address::new_broadcast();
     let link_setup = LinkSetup::new_packet(&source, &destination);
     let payload = b"Hello, world!";
     app.tx()
-        .transmit_packet(&link_setup, PacketType::Raw, payload);
+        .transmit_packet(&link_setup, PacketType::Sms, payload);
 
 
-    std::thread::sleep(std::time::Duration::from_secs(5));
-}
-
-fn main() {
-    env_logger::init();
-    mod_test();
+    std::thread::sleep(std::time::Duration::from_secs(1));
+    app.close();
 }
 }