Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
MabezDev committed Nov 1, 2023
1 parent f56a5dd commit 306ac19
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 21 deletions.
24 changes: 15 additions & 9 deletions esp-wifi/examples/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ fn main() -> ! {
let mut socket = wifi_stack.get_socket(&mut rx_buffer, &mut tx_buffer);

let delay = hal::Delay::new(&clocks);

loop {
test_download(server_address, &mut socket);
delay.delay(3_000_000);
Expand All @@ -135,15 +135,17 @@ fn main() -> ! {
}
}

fn test_download<'a>(server_address: Ipv4Address, socket: &mut esp_wifi::wifi_interface::Socket<'a, 'a>) {
fn test_download<'a>(
server_address: Ipv4Address,
socket: &mut esp_wifi::wifi_interface::Socket<'a, 'a>,
) {
println!("Testing download...");
socket.work();

socket
.open(IpAddress::Ipv4(server_address), DOWNLOAD_PORT)
.unwrap();


let mut buf = [0; IO_BUFFER_SIZE];

let mut total = 0;
Expand All @@ -167,15 +169,17 @@ fn test_download<'a>(server_address: Ipv4Address, socket: &mut esp_wifi::wifi_in
socket.disconnect();
}

fn test_upload<'a>(server_address: Ipv4Address, socket: &mut esp_wifi::wifi_interface::Socket<'a, 'a>) {
fn test_upload<'a>(
server_address: Ipv4Address,
socket: &mut esp_wifi::wifi_interface::Socket<'a, 'a>,
) {
println!("Testing upload...");
socket.work();

socket
.open(IpAddress::Ipv4(server_address), UPLOAD_PORT)
.unwrap();


let buf = [0; IO_BUFFER_SIZE];

let mut total = 0;
Expand All @@ -199,15 +203,17 @@ fn test_upload<'a>(server_address: Ipv4Address, socket: &mut esp_wifi::wifi_inte
socket.disconnect();
}

fn test_upload_download<'a>(server_address: Ipv4Address, socket: &mut esp_wifi::wifi_interface::Socket<'a, 'a>) {
fn test_upload_download<'a>(
server_address: Ipv4Address,
socket: &mut esp_wifi::wifi_interface::Socket<'a, 'a>,
) {
println!("Testing upload+download...");
socket.work();

socket
.open(IpAddress::Ipv4(server_address), UPLOAD_DOWNLOAD_PORT)
.unwrap();


let tx_buf = [0; IO_BUFFER_SIZE];
let mut rx_buf = [0; IO_BUFFER_SIZE];

Expand All @@ -220,7 +226,7 @@ fn test_upload_download<'a>(server_address: Ipv4Address, socket: &mut esp_wifi::
}

socket.work();

if let Ok(len) = socket.read(&mut rx_buf) {
total += len;
} else {
Expand All @@ -236,4 +242,4 @@ fn test_upload_download<'a>(server_address: Ipv4Address, socket: &mut esp_wifi::
println!("upload+download: {} kB/s", kbps);

socket.disconnect();
}
}
15 changes: 3 additions & 12 deletions esp-wifi/examples/embassy_bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,7 @@ async fn net_task(stack: &'static Stack<WifiDevice<'static>>) {
stack.run().await
}

async fn test_download(
server_address: Ipv4Address,
socket: &mut TcpSocket<'_>,
) -> usize {
async fn test_download(server_address: Ipv4Address, socket: &mut TcpSocket<'_>) -> usize {
println!("Testing download...");

socket.abort();
Expand Down Expand Up @@ -191,10 +188,7 @@ async fn test_download(
kbps
}

async fn test_upload(
server_address: Ipv4Address,
socket: &mut TcpSocket<'_>,
) -> usize {
async fn test_upload(server_address: Ipv4Address, socket: &mut TcpSocket<'_>) -> usize {
println!("Testing upload...");
socket.abort();
socket.set_timeout(Some(Duration::from_secs(10)));
Expand Down Expand Up @@ -231,10 +225,7 @@ async fn test_upload(
kbps
}

async fn test_upload_download(
server_address: Ipv4Address,
socket: &mut TcpSocket<'_>,
) -> usize {
async fn test_upload_download(server_address: Ipv4Address, socket: &mut TcpSocket<'_>) -> usize {
println!("Testing upload+download...");

socket.abort();
Expand Down

0 comments on commit 306ac19

Please sign in to comment.