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>
impl<T: Transport> AprsClient<T>
Sourcepub async fn start(
radio: Radio<T>,
config: AprsClientConfig,
) -> Result<Self, (Radio<T>, Error)>
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.
Sourcepub async fn next_event(&mut self) -> Result<Option<AprsEvent>, Error>
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:
- Send any pending message retries via the
AprsMessenger. - Expire messages that have exhausted all retries.
- Attempt to receive a KISS frame (short timeout).
- If received: parse AX.25, parse APRS data, update station list.
- If it is a message addressed to us and
auto_ackis on, send ack. - If digipeater is configured, check whether we should relay.
- 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.
Sourcepub async fn send_message(
&mut self,
addressee: &str,
text: &str,
) -> Result<String, Error>
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.
Sourcepub async fn beacon_position(
&mut self,
lat: f64,
lon: f64,
comment: &str,
) -> Result<(), Error>
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.
Sourcepub async fn beacon_position_compressed(
&mut self,
lat: f64,
lon: f64,
comment: &str,
) -> Result<(), Error>
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.
Sourcepub const fn set_query_response_position(&mut self, lat: f64, lon: f64)
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.
Sourcepub async fn send_object(
&mut self,
name: &str,
live: bool,
lat: f64,
lon: f64,
comment: &str,
) -> Result<(), Error>
pub async fn send_object( &mut self, name: &str, live: bool, lat: f64, lon: f64, comment: &str, ) -> Result<(), Error>
Sourcepub async fn update_motion(
&mut self,
speed_kmh: f64,
course_deg: f64,
lat: f64,
lon: f64,
) -> Result<bool, Error>
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.
Sourcepub const fn stations(&self) -> &StationList
pub const fn stations(&self) -> &StationList
Get the station list (read-only reference).
Sourcepub const fn messenger(&self) -> &AprsMessenger
pub const fn messenger(&self) -> &AprsMessenger
Get the messenger state (pending message count, etc).
Sourcepub const fn config(&self) -> &AprsClientConfig
pub const fn config(&self) -> &AprsClientConfig
Get the current configuration.
Sourcepub fn format_for_is(&self, packet: &Ax25Packet) -> String
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.
Sourcepub async fn gate_from_is(&mut self, is_packet: &str) -> Result<bool, Error>
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.
Sourcepub fn should_gate_to_is(packet: &Ax25Packet) -> bool
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
Sourcepub fn should_gate_to_rf(&self, is_line: &str) -> bool
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