mirror of
https://github.com/embassy-rs/embassy.git
synced 2025-10-02 14:44:32 +00:00
fix: nightly fmt
This commit is contained in:
parent
38b5f8bd0a
commit
bdb1b81213
@ -280,10 +280,12 @@ pub mod ping {
|
||||
//! };
|
||||
//! ```
|
||||
|
||||
use super::*;
|
||||
use core::net::{IpAddr, Ipv6Addr};
|
||||
|
||||
use embassy_time::{Duration, Instant, Timer, WithTimeout};
|
||||
|
||||
use super::*;
|
||||
|
||||
/// Error returned by [`ping()`](PingManager::ping).
|
||||
#[derive(PartialEq, Eq, Clone, Copy, Debug)]
|
||||
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
|
||||
@ -564,7 +566,6 @@ pub mod ping {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Parameters for configuring the ping operation.
|
||||
///
|
||||
/// This struct provides various configuration options for performing ICMP ping operations,
|
||||
|
@ -15,6 +15,8 @@ pub(crate) mod fmt;
|
||||
#[cfg(feature = "dns")]
|
||||
pub mod dns;
|
||||
mod driver_util;
|
||||
#[cfg(feature = "icmp")]
|
||||
pub mod icmp;
|
||||
#[cfg(feature = "raw")]
|
||||
pub mod raw;
|
||||
#[cfg(feature = "tcp")]
|
||||
@ -22,8 +24,6 @@ pub mod tcp;
|
||||
mod time;
|
||||
#[cfg(feature = "udp")]
|
||||
pub mod udp;
|
||||
#[cfg(feature = "icmp")]
|
||||
pub mod icmp;
|
||||
|
||||
use core::cell::RefCell;
|
||||
use core::future::{poll_fn, Future};
|
||||
|
@ -106,16 +106,12 @@ async fn main(spawner: Spawner) {
|
||||
|
||||
// Send the packet and store the starting instant to mesure latency later
|
||||
let start = socket
|
||||
.send_to_with(
|
||||
icmp_repr.buffer_len(),
|
||||
cfg.gateway.unwrap(),
|
||||
|buf| {
|
||||
// Create and populate the packet buffer allocated by `send_to_with`
|
||||
let mut icmp_packet = Icmpv4Packet::new_unchecked(buf);
|
||||
icmp_repr.emit(&mut icmp_packet, &ChecksumCapabilities::default());
|
||||
Instant::now() // Return the instant where the packet was sent
|
||||
},
|
||||
)
|
||||
.send_to_with(icmp_repr.buffer_len(), cfg.gateway.unwrap(), |buf| {
|
||||
// Create and populate the packet buffer allocated by `send_to_with`
|
||||
let mut icmp_packet = Icmpv4Packet::new_unchecked(buf);
|
||||
icmp_repr.emit(&mut icmp_packet, &ChecksumCapabilities::default());
|
||||
Instant::now() // Return the instant where the packet was sent
|
||||
})
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@ -123,7 +119,12 @@ async fn main(spawner: Spawner) {
|
||||
socket
|
||||
.recv_with(|(buf, addr)| {
|
||||
let packet = Icmpv4Packet::new_checked(buf).unwrap();
|
||||
info!("Recieved {:?} from {} in {}ms", packet.data(), addr, start.elapsed().as_millis());
|
||||
info!(
|
||||
"Recieved {:?} from {} in {}ms",
|
||||
packet.data(),
|
||||
addr,
|
||||
start.elapsed().as_millis()
|
||||
);
|
||||
})
|
||||
.await
|
||||
.unwrap();
|
||||
|
@ -100,7 +100,7 @@ async fn main(spawner: Spawner) {
|
||||
// Create the ping manager instance
|
||||
let mut ping_manager = PingManager::new(stack, &mut rx_meta, &mut rx_buffer, &mut tx_meta, &mut tx_buffer);
|
||||
let addr = "192.168.8.1"; // Address to ping to
|
||||
// Create the PingParams with the target address
|
||||
// Create the PingParams with the target address
|
||||
let mut ping_params = PingParams::new(Ipv4Addr::from_str(addr).unwrap());
|
||||
// (optional) Set custom properties of the ping
|
||||
ping_params.set_payload(b"Hello, Ping!"); // custom payload
|
||||
@ -118,7 +118,7 @@ async fn main(spawner: Spawner) {
|
||||
Ok(time) => {
|
||||
info!("{} is online\n- latency: {}ms\n", ip_addr, time.as_millis());
|
||||
total_online_hosts += 1;
|
||||
},
|
||||
}
|
||||
_ => continue,
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user