]> code.octet-stream.net Git - m17rt/blobdiff - m17app/src/app.rs
RTLSDR input via rtl_fm
[m17rt] / m17app / src / app.rs
index a7bb3cd291b18efbf154ec5d54807fe32faf408a..ae019768fe97876bf8960c25f0243e42186e1044 100644 (file)
@@ -84,12 +84,7 @@ pub struct TxHandle {
 }
 
 impl TxHandle {
-    pub fn transmit_packet(
-        &self,
-        link_setup: &LinkSetup,
-        packet_type: &PacketType,
-        payload: &[u8],
-    ) {
+    pub fn transmit_packet(&self, link_setup: &LinkSetup, packet_type: PacketType, payload: &[u8]) {
         let (pack_type, pack_type_len) = packet_type.as_proto();
         if pack_type_len + payload.len() > 823 {
             // TODO: error for invalid transmission type
@@ -97,7 +92,7 @@ impl TxHandle {
         }
         let mut full_payload = vec![];
         full_payload.extend_from_slice(&pack_type[0..pack_type_len]);
-        full_payload.extend_from_slice(&payload);
+        full_payload.extend_from_slice(payload);
         let crc = m17core::crc::m17_crc(&full_payload);
         full_payload.extend_from_slice(&crc.to_be_bytes());
         let kiss_frame = KissFrame::new_full_packet(&link_setup.raw.0, &full_payload).unwrap();
@@ -112,7 +107,7 @@ impl TxHandle {
     // 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, stream: &StreamFrame) {
-        let kiss_frame = KissFrame::new_stream_data(&stream).unwrap();
+        let kiss_frame = KissFrame::new_stream_data(stream).unwrap();
         let _ = self.event_tx.send(TncControlEvent::Kiss(kiss_frame));
     }
 }
@@ -138,6 +133,7 @@ impl Adapters {
 }
 
 /// Carries a request from a method on M17App to the TNC's writer thread, which will execute it.
+#[allow(clippy::large_enum_variant)]
 enum TncControlEvent {
     Kiss(KissFrame),
     Start,
@@ -149,8 +145,8 @@ fn spawn_reader<T: Tnc>(mut tnc: T, adapters: Arc<RwLock<Adapters>>) {
         let mut kiss_buffer = KissBuffer::new();
         let mut stream_running = false;
         loop {
-            let mut buf = kiss_buffer.buf_remaining();
-            let n = match tnc.read(&mut buf) {
+            let buf = kiss_buffer.buf_remaining();
+            let n = match tnc.read(buf) {
                 Ok(n) => n,
                 Err(_) => break,
             };
@@ -204,8 +200,8 @@ fn spawn_reader<T: Tnc>(mut tnc: T, adapters: Arc<RwLock<Adapters>>) {
                             adapters.read().unwrap().packet.values().cloned().collect();
                         for s in subs {
                             s.packet_received(
-                                lsf.clone(),
-                                packet_type.clone(),
+                                LinkSetup::new_raw(lsf.clone()),
+                                packet_type,
                                 packet_payload.clone(),
                             );
                         }
@@ -226,7 +222,7 @@ fn spawn_reader<T: Tnc>(mut tnc: T, adapters: Arc<RwLock<Adapters>>) {
                             let subs: Vec<_> =
                                 adapters.read().unwrap().stream.values().cloned().collect();
                             for s in subs {
-                                s.stream_began(lsf.clone());
+                                s.stream_began(LinkSetup::new_raw(lsf.clone()));
                             }
                         } else if n == 26 {
                             if !stream_running {
@@ -265,7 +261,7 @@ fn spawn_writer<T: Tnc>(mut tnc: T, event_rx: mpsc::Receiver<TncControlEvent>) {
         while let Ok(ev) = event_rx.recv() {
             match ev {
                 TncControlEvent::Kiss(k) => {
-                    if let Err(e) = tnc.write_all(&k.as_bytes()) {
+                    if let Err(e) = tnc.write_all(k.as_bytes()) {
                         debug!("kiss send err: {:?}", e);
                         return;
                     }