style: fmt
This commit is contained in:
+5
-2
@@ -1,10 +1,10 @@
|
|||||||
use core::net::SocketAddr;
|
use core::net::SocketAddr;
|
||||||
use embassy_net::udp::{PacketMetadata, UdpSocket};
|
use embassy_net::udp::{PacketMetadata, UdpSocket};
|
||||||
use embassy_time::{Duration, Timer};
|
use embassy_time::{Duration, Timer};
|
||||||
|
use portable_atomic::{AtomicU64, Ordering};
|
||||||
use sntpc::{NtpContext, get_time};
|
use sntpc::{NtpContext, get_time};
|
||||||
use sntpc_net_embassy::UdpSocketWrapper;
|
use sntpc_net_embassy::UdpSocketWrapper;
|
||||||
use sntpc_time_embassy::EmbassyTimestampGenerator;
|
use sntpc_time_embassy::EmbassyTimestampGenerator;
|
||||||
use portable_atomic::{AtomicU64, Ordering};
|
|
||||||
|
|
||||||
// NTP server (pool.ntp.org is the usual choice)
|
// NTP server (pool.ntp.org is the usual choice)
|
||||||
const NTP_SERVER: &str = "pool.ntp.org";
|
const NTP_SERVER: &str = "pool.ntp.org";
|
||||||
@@ -57,7 +57,10 @@ pub async fn ntp_upkeep_service(stack: embassy_net::Stack<'static>) {
|
|||||||
loop {
|
loop {
|
||||||
match fetch_ntp_time(stack).await {
|
match fetch_ntp_time(stack).await {
|
||||||
Ok(unix_secs) => {
|
Ok(unix_secs) => {
|
||||||
NTP_BOOT_OFFSET.store(unix_secs - embassy_time::Instant::now().as_secs(), portable_atomic::Ordering::Relaxed);
|
NTP_BOOT_OFFSET.store(
|
||||||
|
unix_secs - embassy_time::Instant::now().as_secs(),
|
||||||
|
portable_atomic::Ordering::Relaxed,
|
||||||
|
);
|
||||||
Timer::after(Duration::from_secs(6 * 60 * 60)).await
|
Timer::after(Duration::from_secs(6 * 60 * 60)).await
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user