X-Git-Url: https://code.octet-stream.net/m17rt/blobdiff_plain/6437aa4e3e028e05ea84af469b15ed91ba0d8cc2..4cfda08117c4288a5408d45db1ef4be82f4facaa:/m17app/src/app.rs?ds=sidebyside diff --git a/m17app/src/app.rs b/m17app/src/app.rs index 6d056f9..561a2b7 100644 --- a/m17app/src/app.rs +++ b/m17app/src/app.rs @@ -1,7 +1,7 @@ use crate::adapter::{PacketAdapter, StreamAdapter}; use crate::tnc::Tnc; use m17core::kiss::{KissBuffer, KissCommand, KissFrame}; -use m17core::protocol::{EncryptionType, LsfFrame, PacketType}; +use m17core::protocol::{EncryptionType, LsfFrame, PacketType, StreamFrame}; use log::debug; use std::collections::HashMap; @@ -91,11 +91,19 @@ impl TxHandle { // add more methods here for stream outgoing - pub fn transmit_stream_start(&self /* lsf?, payload? what needs to be configured ?! */) {} + pub fn transmit_stream_start(&self, lsf: LsfFrame) { + // TODO: is asking for an LsfFrame a good idea or unfriendly API? + // What I should do here is create a LinkSetup struct which wraps an LsfFrame and can be loaded with a raw one + let kiss_frame = KissFrame::new_stream_setup(&lsf.0).unwrap(); + let _ = self.event_tx.send(TncControlEvent::Kiss(kiss_frame)); + } // as long as there is only one TNC it is implied there is only ever one stream transmission in flight - pub fn transmit_stream_next(&self, /* next payload, */ end_of_stream: bool) {} + pub fn transmit_stream_next(&self, stream: StreamFrame) { + let kiss_frame = KissFrame::new_stream_data(&stream).unwrap(); + let _ = self.event_tx.send(TncControlEvent::Kiss(kiss_frame)); + } } /// Synchronised structure for listeners subscribing to packets and streams. @@ -125,7 +133,7 @@ enum TncControlEvent { Close, } -fn spawn_reader(mut tnc: T, adapters: Arc>) { +fn spawn_reader(mut tnc: T, adapters: Arc>) { std::thread::spawn(move || { let mut kiss_buffer = KissBuffer::new(); let mut stream_running = false; @@ -156,7 +164,7 @@ fn spawn_reader(mut tnc: T, adapters: Arc(mut tnc: T, adapters: Arc(mut tnc: T, adapters: Arc(mut tnc: T, event_rx: mpsc::Receiver) { +fn spawn_writer(mut tnc: T, event_rx: mpsc::Receiver) { std::thread::spawn(move || { while let Ok(ev) = event_rx.recv() { match ev {