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
sntpccore updates - Version flexibility: Works with embassy-net 0.8.x (
>=0.8, <0.9) - Embedded focus: Minimal dependencies suitable for
no_stdembedded systems - Future compatibility: When embassy-net 0.8+ releases, only this adapter needs updating
Usage
Add this to your Cargo.toml:
[]
= { = "0.8", = false }
= { = "0.8", = false }
= { = "0.8", = ["udp", "proto-ipv4"] }
Features
ipv6: Enable IPv6 protocol support (propagates toembassy-net)log: Enable logging support via thelogcratedefmt: Enable logging support via thedefmtcrate (for embedded systems)
Note: log and defmt are mutually exclusive. If both are enabled, defmt takes priority.
Example
use ;
use UdpSocketWrapper;
use UdpSocket;
// Within an embassy async context
let socket = new;
// binding and other required steps
let socket = from;
let result = get_time.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