AprsClient

Struct AprsClient 

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

Complete APRS client for the TH-D75.

Combines KISS session management, position beaconing (SmartBeaconing), reliable messaging (ack/retry), station tracking, and optional digipeater forwarding into a single, easy-to-use async interface.

See the module-level documentation for a full usage example.

Implementations§

Source§

impl<T: Transport> AprsClient<T>

Source

pub async fn start( radio: Radio<T>, config: AprsClientConfig, ) -> Result<Self, (Radio<T>, Error)>

Start the APRS client, entering KISS mode on the radio.

Consumes the Radio and returns an AprsClient that owns the transport. Call stop to exit KISS mode and reclaim the Radio.

§Errors

On failure, returns the Radio alongside the error so the caller can continue using CAT mode.

Source

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

Stop the APRS client, exiting KISS mode and returning the Radio.

§Errors

Returns an error if the KISS exit command fails.

Source

pub async fn next_event(&mut self) -> Result<Option<AprsEvent>, Error>

Process pending I/O and return the next event.

Each call performs one cycle:

  1. Send any pending message retries via the AprsMessenger.
  2. Expire messages that have exhausted all retries.
  3. Attempt to receive a KISS frame (short timeout).
  4. If received: parse AX.25, parse APRS data, update station list.
  5. If it is a message addressed to us and auto_ack is on, send ack.
  6. If digipeater is configured, check whether we should relay.
  7. Return the appropriate AprsEvent.

Returns Ok(None) when no activity occurs within the poll timeout. Callers should loop on this method.

§Errors

Returns an error on transport failures.

Source

pub async fn send_message( &mut self, addressee: &str, text: &str, ) -> Result<String, Error>

Send an APRS message to a station. Returns the message ID for tracking.

The message is queued with the AprsMessenger for automatic retry until acknowledged, rejected, or expired.

§Errors

Returns an error if the initial transmission fails.

Source

pub async fn beacon_position( &mut self, lat: f64, lon: f64, comment: &str, ) -> Result<(), Error>

Beacon current position using uncompressed format.

Builds an APRS position report and transmits it via KISS. Updates the SmartBeaconing timer.

§Errors

Returns an error if the transmission fails.

Source

pub async fn beacon_position_compressed( &mut self, lat: f64, lon: f64, comment: &str, ) -> Result<(), Error>

Beacon position using compressed format (smaller packet).

Uses base-91 encoding per APRS101 Chapter 9. Produces smaller packets than beacon_position.

§Errors

Returns an error if the transmission fails.

Source

pub async fn send_status(&mut self, text: &str) -> Result<(), Error>

Send a status report.

§Errors

Returns an error if the transmission fails.

Source

pub const fn set_query_response_position(&mut self, lat: f64, lon: f64)

Set the cached position for auto query responses.

When a station sends ?APRSP and auto query response is enabled, the client replies with a position beacon using this position.

Source

pub async fn send_object( &mut self, name: &str, live: bool, lat: f64, lon: f64, comment: &str, ) -> Result<(), Error>

Send an object report.

§Errors

Returns an error if the transmission fails.

Source

pub async fn update_motion( &mut self, speed_kmh: f64, course_deg: f64, lat: f64, lon: f64, ) -> Result<bool, Error>

Update speed and course for SmartBeaconing.

If the SmartBeaconing algorithm determines a beacon is due (based on speed, course change, and elapsed time), a position report is transmitted and this method returns Ok(true). Otherwise returns Ok(false).

§Errors

Returns an error if the beacon transmission fails.

Source

pub const fn stations(&self) -> &StationList

Get the station list (read-only reference).

Source

pub const fn messenger(&self) -> &AprsMessenger

Get the messenger state (pending message count, etc).

Source

pub const fn config(&self) -> &AprsClientConfig

Get the current configuration.

Source

pub fn format_for_is(&self, packet: &Ax25Packet) -> String

Format a received RF packet for transmission to APRS-IS.

Converts the AX.25 packet to APRS-IS text format: SOURCE>DEST,PATH,qAR,MYCALL:data

The qAR construct identifies this as an RF-gated packet per the APRS-IS q-construct specification.

Source

pub async fn gate_from_is(&mut self, is_packet: &str) -> Result<bool, Error>

Parse an APRS-IS packet and transmit it on RF via KISS.

Only transmits if the packet passes the third-party header check (avoids RF loops). The packet is wrapped in a third-party header } before transmission per APRS101 Chapter 17.

Returns true if the packet was transmitted, false if it was filtered out.

§Errors

Returns an error if the KISS transmission fails.

Source

pub fn should_gate_to_is(packet: &Ax25Packet) -> bool

Check if a packet should be gated to APRS-IS.

Applies standard IGate rules:

  • Don’t gate packets from TCPIP/TCPXX sources
  • Don’t gate third-party packets (}prefix)
  • Don’t gate packets with NOGATE/RFONLY in path
Source

pub fn should_gate_to_rf(&self, is_line: &str) -> bool

Check if an APRS-IS packet should be gated to RF.

Applies standard IGate rules:

  • Only gate messages addressed to stations heard on RF recently
  • Don’t gate general position reports to RF (would flood)
  • Don’t gate packets containing TCPIP/TCPXX/NOGATE/RFONLY in path

Trait Implementations§

Source§

impl<T: Transport> Debug for AprsClient<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 AprsClient<T>
where T: Freeze,

§

impl<T> !RefUnwindSafe for AprsClient<T>

§

impl<T> Send for AprsClient<T>

§

impl<T> Sync for AprsClient<T>

§

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

§

impl<T> !UnwindSafe for AprsClient<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