Expand description
NtpTimestampGenerator implementation backed by embassy_time for the sntpc SNTP client library.
This crate provides an EmbassyTimestampGenerator that uses the Embassy async runtime’s
monotonic clock to produce timestamps suitable for SNTP round-trip time measurements in
embedded no_std environments.
§Design Rationale
The timestamp generator is separated into its own crate to:
- Independent versioning: Update
embassy-timewithout requiringsntpccore updates - Version flexibility: Works with
embassy-time0.5.x (>=0.5, <0.6) - Embedded focus: Minimal dependencies suitable for
no_stdembedded systems - Clean separation: Core SNTP protocol logic remains independent of the async runtime
§Important
EmbassyTimestampGenerator provides monotonic timestamps based on embassy_time::Instant,
not wall-clock time. This is enough for SNTP request/response delay calculations, where
the client measures the elapsed time between sending a request and receiving a response.
The actual wall-clock offset is computed by the sntpc library using the server’s timestamps.
§Example
use sntpc::{get_time, NtpContext};
use sntpc_time_embassy::EmbassyTimestampGenerator;
// Create an NtpContext with the Embassy timestamp generator
let ntp_context = NtpContext::new(EmbassyTimestampGenerator::default());
// Use with an Embassy UDP socket adapter
let result = get_time(server_addr, &socket, ntp_context).await;For complete examples, see the sntpc examples.
Structs§
- Embassy
Timestamp Generator - Monotonic timestamp generator backed by
embassy_time::Instant.