From: Thomas Karpiniec Date: Tue, 21 Jan 2025 10:47:49 +0000 (+1100) Subject: Handle KISS configuration commands, crate metadata X-Git-Tag: v0.1.0~7 X-Git-Url: https://code.octet-stream.net/m17rt/commitdiff_plain/488cd0f950a1754f8c5a34dc2617c927e466cc3b Handle KISS configuration commands, crate metadata --- diff --git a/m17app/Cargo.toml b/m17app/Cargo.toml index 4a083bd..bbd07f4 100755 --- a/m17app/Cargo.toml +++ b/m17app/Cargo.toml @@ -6,6 +6,9 @@ keywords = ["amateur", "radio", "m17", "ham"] license = "MIT" authors = ["Thomas Karpiniec { - if self.dcd { - self.next_csma_check = Some(self.now + 1920); - return None; - } else { - // channel is idle at the moment we get a frame to send - // go right ahead - } - } - Some(at_time) => { - if self.now < at_time { - return None; + + // TODO: Proper full duplex support + // A true full duplex TNC should be able to rx and tx concurrently, implying + // separate states. + if !self.full_duplex { + match self.next_csma_check { + None => { + if self.dcd { + self.next_csma_check = Some(self.now + 1920); + return None; + } else { + // channel is idle at the moment we get a frame to send + // go right ahead + } } - // 25% chance that we'll transmit this slot. - // Using self.now as random is probably fine so long as it's not being set in - // a lumpy manner. m17app's soundmodem should be fine. - // TODO: bring in prng to help in cases where `now` never ends in 0b11 - let p1_4 = (self.now & 3) == 3; - if !self.dcd || !p1_4 { - self.next_csma_check = Some(self.now + 1920); - return None; - } else { - self.next_csma_check = None; + Some(at_time) => { + if self.now < at_time { + return None; + } + // 25% chance that we'll transmit this slot. + // Using self.now as random is probably fine so long as it's not being set in + // a lumpy manner. m17app's soundmodem should be fine. + // TODO: bring in prng to help in cases where `now` never ends in 0b11 + let p1_4 = (self.now & 3) == 3; + if !self.dcd || !p1_4 { + self.next_csma_check = Some(self.now + 1920); + return None; + } else { + self.next_csma_check = None; + } } } } @@ -269,8 +285,9 @@ impl SoftTnc { self.state = State::TxPacket; } self.ptt = true; - // TODO: true txdelay - Some(ModulatorFrame::Preamble { tx_delay: 0 }) + Some(ModulatorFrame::Preamble { + tx_delay: self.tx_delay, + }) } State::TxStream => { if !self.stream_full && self.stream_next == self.stream_curr { @@ -348,6 +365,31 @@ impl SoftTnc { let Ok(port) = kiss_frame.port() else { continue; }; + let Ok(command) = kiss_frame.command() else { + continue; + }; + if port != PORT_PACKET_BASIC && port != PORT_PACKET_FULL && port != PORT_STREAM { + continue; + } + if command == KissCommand::TxDelay { + let mut new_delay = [0u8; 1]; + if kiss_frame.decode_payload(&mut new_delay) == Ok(1) { + self.tx_delay = new_delay[0]; + } + continue; + } + if command == KissCommand::FullDuplex { + let mut new_duplex = [0u8; 1]; + if kiss_frame.decode_payload(&mut new_duplex) == Ok(1) { + self.full_duplex = new_duplex[0] != 0; + } + continue; + } + if command != KissCommand::DataFrame { + // Not supporting any other settings yet + // TODO: allow adjusting P persistence parameter for CSMA + continue; + } if port == PORT_PACKET_BASIC { if self.packet_full { continue;