aboutsummaryrefslogtreecommitdiff
path: root/examples/rp/src
diff options
context:
space:
mode:
authorskkeye <[email protected]>2025-02-09 02:11:15 -0500
committerUlf Lilleengen <[email protected]>2025-02-13 10:27:30 +0100
commitbdb1b812135b7cb22f65009242d5b61712e8e9d7 (patch)
treed0b0af875006b05eb38bf54408fb9feff745a2cc /examples/rp/src
parent38b5f8bd0afd9669e638b8d83210427d2d372a96 (diff)
fix: nightly fmt
Diffstat (limited to 'examples/rp/src')
-rw-r--r--examples/rp/src/bin/ethernet_w5500_icmp.rs25
-rw-r--r--examples/rp/src/bin/ethernet_w5500_icmp_ping.rs4
2 files changed, 15 insertions, 14 deletions
diff --git a/examples/rp/src/bin/ethernet_w5500_icmp.rs b/examples/rp/src/bin/ethernet_w5500_icmp.rs
index a07cdf88d..5f336b579 100644
--- a/examples/rp/src/bin/ethernet_w5500_icmp.rs
+++ b/examples/rp/src/bin/ethernet_w5500_icmp.rs
@@ -1,5 +1,5 @@
1//! This example implements an echo (ping) with an ICMP Socket and using defmt to report the results. 1//! This example implements an echo (ping) with an ICMP Socket and using defmt to report the results.
2//! 2//!
3//! Although there is a better way to execute pings using the child module ping of the icmp module, 3//! Although there is a better way to execute pings using the child module ping of the icmp module,
4//! this example allows for other icmp messages like `Destination unreachable` to be sent aswell. 4//! this example allows for other icmp messages like `Destination unreachable` to be sent aswell.
5//! 5//!
@@ -106,16 +106,12 @@ async fn main(spawner: Spawner) {
106 106
107 // Send the packet and store the starting instant to mesure latency later 107 // Send the packet and store the starting instant to mesure latency later
108 let start = socket 108 let start = socket
109 .send_to_with( 109 .send_to_with(icmp_repr.buffer_len(), cfg.gateway.unwrap(), |buf| {
110 icmp_repr.buffer_len(), 110 // Create and populate the packet buffer allocated by `send_to_with`
111 cfg.gateway.unwrap(), 111 let mut icmp_packet = Icmpv4Packet::new_unchecked(buf);
112 |buf| { 112 icmp_repr.emit(&mut icmp_packet, &ChecksumCapabilities::default());
113 // Create and populate the packet buffer allocated by `send_to_with` 113 Instant::now() // Return the instant where the packet was sent
114 let mut icmp_packet = Icmpv4Packet::new_unchecked(buf); 114 })
115 icmp_repr.emit(&mut icmp_packet, &ChecksumCapabilities::default());
116 Instant::now() // Return the instant where the packet was sent
117 },
118 )
119 .await 115 .await
120 .unwrap(); 116 .unwrap();
121 117
@@ -123,7 +119,12 @@ async fn main(spawner: Spawner) {
123 socket 119 socket
124 .recv_with(|(buf, addr)| { 120 .recv_with(|(buf, addr)| {
125 let packet = Icmpv4Packet::new_checked(buf).unwrap(); 121 let packet = Icmpv4Packet::new_checked(buf).unwrap();
126 info!("Recieved {:?} from {} in {}ms", packet.data(), addr, start.elapsed().as_millis()); 122 info!(
123 "Recieved {:?} from {} in {}ms",
124 packet.data(),
125 addr,
126 start.elapsed().as_millis()
127 );
127 }) 128 })
128 .await 129 .await
129 .unwrap(); 130 .unwrap();
diff --git a/examples/rp/src/bin/ethernet_w5500_icmp_ping.rs b/examples/rp/src/bin/ethernet_w5500_icmp_ping.rs
index 0d83e3831..0724311f9 100644
--- a/examples/rp/src/bin/ethernet_w5500_icmp_ping.rs
+++ b/examples/rp/src/bin/ethernet_w5500_icmp_ping.rs
@@ -100,7 +100,7 @@ async fn main(spawner: Spawner) {
100 // Create the ping manager instance 100 // Create the ping manager instance
101 let mut ping_manager = PingManager::new(stack, &mut rx_meta, &mut rx_buffer, &mut tx_meta, &mut tx_buffer); 101 let mut ping_manager = PingManager::new(stack, &mut rx_meta, &mut rx_buffer, &mut tx_meta, &mut tx_buffer);
102 let addr = "192.168.8.1"; // Address to ping to 102 let addr = "192.168.8.1"; // Address to ping to
103 // Create the PingParams with the target address 103 // Create the PingParams with the target address
104 let mut ping_params = PingParams::new(Ipv4Addr::from_str(addr).unwrap()); 104 let mut ping_params = PingParams::new(Ipv4Addr::from_str(addr).unwrap());
105 // (optional) Set custom properties of the ping 105 // (optional) Set custom properties of the ping
106 ping_params.set_payload(b"Hello, Ping!"); // custom payload 106 ping_params.set_payload(b"Hello, Ping!"); // custom payload
@@ -118,7 +118,7 @@ async fn main(spawner: Spawner) {
118 Ok(time) => { 118 Ok(time) => {
119 info!("{} is online\n- latency: {}ms\n", ip_addr, time.as_millis()); 119 info!("{} is online\n- latency: {}ms\n", ip_addr, time.as_millis());
120 total_online_hosts += 1; 120 total_online_hosts += 1;
121 }, 121 }
122 _ => continue, 122 _ => continue,
123 } 123 }
124 } 124 }