sntpc-net-embassy

Crates.iosntpc-net-embassy
lib.rssntpc-net-embassy
version0.8.0
created_at2026-01-08 11:29:58.496418+00
updated_at2026-01-08 13:16:00.343478+00
descriptionEmbassy socket wrapper for sntpc library
homepage
repositoryhttps://github.com/vpetrigo/sntpc
max_upload_size
id2030013
size34,817
Vladimir Petrigo (vpetrigo)

documentation

README

GitHub Actions Workflow Status Crates.io docs.rs

sntpc-net-embassy

Embassy async runtime UDP socket adapter for the sntpc SNTP client library.

Design Goal

This crate provides a wrapper around embassy_net::udp::UdpSocket that implements the NtpUdpSocket trait from sntpc. This separation allows:

  • Independent versioning: Update embassy-net without requiring sntpc core updates
  • Version flexibility: Works with embassy-net 0.8.x (>=0.8, <0.9)
  • Embedded focus: Minimal dependencies suitable for no_std embedded systems
  • Future compatibility: When embassy-net 0.8+ releases, only this adapter needs updating

Usage

Add this to your Cargo.toml:

[dependencies]
sntpc = { version = "0.8", default-features = false }
sntpc-net-embassy = { version = "0.8", default-features = false }
embassy-net = { version = "0.8", features = ["udp", "proto-ipv4"] }

Features

  • ipv6: Enable IPv6 protocol support (propagates to embassy-net)
  • log: Enable logging support via the log crate
  • defmt: Enable logging support via the defmt crate (for embedded systems)

Note: log and defmt are mutually exclusive. If both are enabled, defmt takes priority.

Example

use sntpc::{get_time, NtpContext};
use sntpc_net_embassy::UdpSocketWrapper;
use embassy_net::udp::UdpSocket;

// Within an embassy async context
let socket = UdpSocket::new(stack, &mut rx_buffer, &mut tx_buffer);
// binding and other required steps
let socket = UdpSocketWrapper::from(socket);

let result = get_time(server_addr, &socket, ntp_context).await;

For complete examples, see the sntpc examples.

Compatibility

  • sntpc: 0.8.x
  • embassy-net: 0.8.x (any version >= 0.8, < 0.9)
  • no_std: Fully supported

License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this codebase by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
Commit count: 434

cargo fmt