Skip to main content

Crate sntpc_time_embassy

Crate sntpc_time_embassy 

Source
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-time without requiring sntpc core updates
  • Version flexibility: Works with embassy-time 0.5.x (>=0.5, <0.6)
  • Embedded focus: Minimal dependencies suitable for no_std embedded 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§

EmbassyTimestampGenerator
Monotonic timestamp generator backed by embassy_time::Instant.