KissSession

Struct KissSession 

Source
pub struct KissSession<T: Transport> { /* private fields */ }
Expand description

A KISS TNC session that owns the radio transport.

While this session is active, the serial port speaks KISS binary framing instead of ASCII CAT commands. The Radio is consumed on entry and returned on exit.

§KISS commands supported by TH-D75

CommandCodeRangeDefault
Data Frame0x00AX.25 payload
TX Delay0x010-120 (10 ms units)Menu 508
Persistence0x020-255128
Slot Time0x030-250 (10 ms units)10
TX Tail0x040-2553
Full Duplex0x050=half, nonzero=full0
Set Hardware0x060/0x23=1200, 0x05/0x26=9600Menu 505
Return0xFF

Implementations§

Source§

impl<T: Transport> KissSession<T>

Source

pub const fn set_receive_timeout(&mut self, duration: Duration)

Set the timeout for receive_frame operations.

Defaults to 10 seconds. Set higher for quiet channels.

Source

pub async fn send_wire(&mut self, wire: &[u8]) -> Result<(), Error>

Write pre-encoded KISS wire bytes directly to the transport.

Use this when you already have a fully KISS-encoded frame (e.g., from build_aprs_message or AprsMessenger::next_frame_to_send). Unlike send_frame and send_data, this does not perform any additional encoding.

§Errors

Returns Error::Transport if the write fails.

Source

pub async fn send_frame(&mut self, frame: &KissFrame) -> Result<(), Error>

Send a KISS frame to the TNC.

The frame is KISS-encoded (with FEND delimiters and byte stuffing) before transmission.

§Errors

Returns Error::Transport if the write fails.

Source

pub async fn receive_frame(&mut self) -> Result<KissFrame, Error>

Receive a KISS frame from the TNC.

Blocks until a complete KISS frame is received or the receive timeout expires. Accumulates bytes from the transport and extracts frames delimited by FEND bytes.

§Errors

Returns Error::Timeout if no complete frame arrives within the configured receive timeout. Returns Error::Transport if the read fails.

Source

pub async fn set_tx_delay(&mut self, tens_of_ms: u8) -> Result<(), Error>

Set the TNC TX delay (KISS command 0x01).

The value is in units of 10 ms. The TH-D75 supports 0-120 (0 ms to 1200 ms). The default is configured via Menu No. 508.

§Errors

Returns Error::Transport if the write fails.

Source

pub async fn set_persistence(&mut self, value: u8) -> Result<(), Error>

Set the CSMA persistence parameter (KISS command 0x02).

Range 0-255. The probability of transmitting when the channel is clear is (persistence + 1) / 256. Default: 128 (50%).

§Errors

Returns Error::Transport if the write fails.

Source

pub async fn set_slot_time(&mut self, tens_of_ms: u8) -> Result<(), Error>

Set the CSMA slot time (KISS command 0x03).

The value is in units of 10 ms. Range 0-250. Default: 10 (100 ms).

§Errors

Returns Error::Transport if the write fails.

Source

pub async fn set_tx_tail(&mut self, tens_of_ms: u8) -> Result<(), Error>

Set the TX tail time (KISS command 0x04).

The value is in units of 10 ms. Range 0-255. Default: 3 (30 ms).

§Errors

Returns Error::Transport if the write fails.

Source

pub async fn set_full_duplex(&mut self, full_duplex: bool) -> Result<(), Error>

Set full or half duplex mode (KISS command 0x05).

true = full duplex, false = half duplex (default).

§Errors

Returns Error::Transport if the write fails.

Source

pub async fn set_hardware_baud(&mut self, baud_1200: bool) -> Result<(), Error>

Switch the TNC data speed via KISS hardware command (0x06).

On the TH-D75, true = 1200 bps (AFSK), false = 9600 bps (GMSK). The hardware command values are: 0 or 0x23 for 1200, 0x05 or 0x26 for 9600.

§Errors

Returns Error::Transport if the write fails.

Source

pub async fn send_data(&mut self, ax25_bytes: &[u8]) -> Result<(), Error>

Send an AX.25 data frame via KISS.

Wraps the raw AX.25 bytes in a KISS data frame (CMD_DATA = 0x00) and sends it.

§Errors

Returns Error::Transport if the write fails.

Source

pub async fn exit(self) -> Result<Radio<T>, Error>

Exit KISS mode by sending the CMD_RETURN (0xFF) frame.

Returns the Radio so CAT commands can be used again.

§Errors

Returns Error::Transport if the write fails.

Trait Implementations§

Source§

impl<T: Transport> Debug for KissSession<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T> Freeze for KissSession<T>
where T: Freeze,

§

impl<T> !RefUnwindSafe for KissSession<T>

§

impl<T> Send for KissSession<T>

§

impl<T> Sync for KissSession<T>

§

impl<T> Unpin for KissSession<T>
where T: Unpin,

§

impl<T> !UnwindSafe for KissSession<T>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more