pub struct NtripClient { /* private fields */ }Expand description
NTRIP client for streaming corrections from a caster. Supports both v1 (ICY) and v2 (HTTP/1.1) protocols.
Implementations§
Source§impl NtripClient
impl NtripClient
Sourcepub fn new(config: NtripConfig) -> Result<Self, Error>
pub fn new(config: NtripConfig) -> Result<Self, Error>
Create a new NTRIP client with the given configuration.
Sourcepub async fn connect(&mut self) -> Result<(), Error>
pub async fn connect(&mut self) -> Result<(), Error>
Connect to the NTRIP caster and start streaming.
For NTRIP v2, consider using connect_with_gga() to send an initial
position in the request headers for faster VRS/nearest-base selection.
Sourcepub async fn connect_with_gga(
&mut self,
initial_gga: Option<&GgaSentence>,
) -> Result<(), Error>
pub async fn connect_with_gga( &mut self, initial_gga: Option<&GgaSentence>, ) -> Result<(), Error>
Connect to the NTRIP caster with an optional initial GGA position.
For NTRIP v2, the GGA sentence is sent in the Ntrip-GGA header,
allowing the caster to select the appropriate VRS or nearest base
immediately, without waiting for a post-connection GGA report.
For NTRIP v1, the initial_gga is ignored (GGA must be sent post-connection).
Sourcepub async fn read_chunk(&mut self, buf: &mut [u8]) -> Result<usize, Error>
pub async fn read_chunk(&mut self, buf: &mut [u8]) -> Result<usize, Error>
Read a chunk of RTCM data from the stream with timeout. Automatically handles chunked transfer encoding for NTRIP v2.
§Reconnection Behavior
If automatic reconnection is enabled (default: 3 attempts), this method will attempt to reconnect on timeout or disconnect errors before returning an error to the caller.
Important: When reconnection is enabled, this method may block for up to
(max_reconnect_attempts × reconnect_delay_ms) + connection_timeout milliseconds
while attempting to restore the connection. During this time:
- The original error (timeout/disconnect) is not immediately returned
- If a previous GGA position was set (via
send_gga()orconnect_with_gga()), it will be automatically resent after successful reconnection
To disable this behavior, use config.without_reconnect().
Sourcepub fn is_connected(&self) -> bool
pub fn is_connected(&self) -> bool
Check if connected.
Sourcepub fn disconnect(&mut self)
pub fn disconnect(&mut self)
Disconnect from the caster.
Sourcepub async fn send_gga(&mut self, gga: &GgaSentence) -> Result<(), Error>
pub async fn send_gga(&mut self, gga: &GgaSentence) -> Result<(), Error>
Send a GGA position report to the caster on the existing stream.
Sourcepub fn config(&self) -> &NtripConfig
pub fn config(&self) -> &NtripConfig
Get the configuration.
Sourcepub async fn get_sourcetable(config: &NtripConfig) -> Result<Sourcetable, Error>
pub async fn get_sourcetable(config: &NtripConfig) -> Result<Sourcetable, Error>
Fetch the sourcetable from the NTRIP caster.
This is a one-shot operation that connects, retrieves the sourcetable, and disconnects. It does not affect the current streaming connection.