pub struct NtpClient {
pub filter: ClockFilter,
pub drift: DriftEstimator,
pub poll_interval: u32,
pub stratum: u8,
pub step_applied: bool,
pub start_ms: u64,
}Expand description
NTP client managing time synchronization with one or more servers.
Fields§
§filter: ClockFilterClock filter for selecting best sample
drift: DriftEstimatorDrift estimator for frequency compensation
poll_interval: u32Current poll interval in seconds
stratum: u8Our stratum level (one more than best server’s stratum)
step_applied: boolWhether a step correction has been applied since boot
start_ms: u64Measurement start time in ms (for drift tracking)
Implementations§
Source§impl NtpClient
impl NtpClient
Sourcepub fn create_request(&self, transmit_ts: NtpTimestamp) -> [u8; 48]
pub fn create_request(&self, transmit_ts: NtpTimestamp) -> [u8; 48]
Create a client request packet for the given transmit timestamp.
Sourcepub fn process_response(
&mut self,
response: &[u8],
t1: &NtpTimestamp,
t4: &NtpTimestamp,
) -> Option<NtpMeasurement>
pub fn process_response( &mut self, response: &[u8], t1: &NtpTimestamp, t4: &NtpTimestamp, ) -> Option<NtpMeasurement>
Process a server response and return the computed measurement.
response: the raw 48-byte NTP responset1: our original transmit timestampt4: our receive timestamp (when we got the response)
Sourcepub fn adjust_clock(&mut self) -> i64
pub fn adjust_clock(&mut self) -> i64
Decide whether to step (instant jump) or slew (gradual adjust) the clock, and apply the correction via the RTC integration point.
Returns the applied correction in milliseconds.
Sourcepub fn get_poll_interval(&self) -> u32
pub fn get_poll_interval(&self) -> u32
Get the current poll interval in seconds.