chore: 📎 + fmt

This commit is contained in:
2025-10-18 20:40:38 +02:00
parent 6357ec773f
commit 1db3f7af64
26 changed files with 548 additions and 578 deletions

View File

@@ -51,11 +51,8 @@ where
conn.initiate_response(
409,
Some(
format!(
"Checksum mismatch expected {} got {}",
expected_crc, actual_crc
)
.as_str(),
format!("Checksum mismatch expected {expected_crc} got {actual_crc}")
.as_str(),
),
&[],
)
@@ -131,7 +128,7 @@ where
let mut board = BOARD_ACCESS.get().await.lock().await;
board.board_hal.progress(counter).await;
counter = counter + 1;
counter += 1;
board
.board_hal
.get_rtc_module()
@@ -139,7 +136,7 @@ where
.await?;
checksum.update(&buf[0..to_write]);
}
offset = offset + to_write;
offset += to_write;
}
let mut board = BOARD_ACCESS.get().await.lock().await;

View File

@@ -27,7 +27,7 @@ where
T: Read + Write,
{
let filename = &path[prefix.len()..];
info!("file request for {} with method {}", filename, method);
info!("file request for {filename} with method {method}");
Ok(match method {
Method::Delete => {
let mut board = BOARD_ACCESS.get().await.lock().await;
@@ -65,7 +65,7 @@ where
&[
("Content-Type", "application/octet-stream"),
("Content-Disposition", disposition.as_str()),
("Content-Length", &format!("{}", size)),
("Content-Length", &format!("{size}")),
("Access-Control-Allow-Origin", "*"),
("Access-Control-Allow-Headers", "*"),
("Access-Control-Allow-Methods", "*"),
@@ -84,16 +84,16 @@ where
.await?;
let length = read_chunk.1;
if length == 0 {
info!("file request for {} finished", filename);
info!("file request for {filename} finished");
break;
}
let data = &read_chunk.0[0..length];
conn.write_all(data).await?;
if length < read_chunk.0.len() {
info!("file request for {} finished", filename);
info!("file request for {filename} finished");
break;
}
chunk = chunk + 1;
chunk += 1;
}
BOARD_ACCESS
.get()
@@ -120,8 +120,8 @@ where
let mut chunk = 0;
loop {
let buf = read_up_to_bytes_from_request(conn, Some(4096)).await?;
if buf.len() == 0 {
info!("file request for {} finished", filename);
if buf.is_empty() {
info!("file request for {filename} finished");
break;
} else {
let mut board = BOARD_ACCESS.get().await.lock().await;
@@ -132,8 +132,8 @@ where
.write_file(filename.to_owned(), offset as u32, &buf)
.await?;
}
offset = offset + buf.len();
chunk = chunk + 1;
offset += buf.len();
chunk += 1;
}
BOARD_ACCESS
.get()

View File

@@ -1,4 +1,3 @@
use core::str::FromStr;
use crate::fat_error::{FatError, FatResult};
use crate::hal::{esp_time, PLANT_COUNT};
use crate::log::LogMessage;
@@ -9,6 +8,7 @@ use alloc::format;
use alloc::string::{String, ToString};
use alloc::vec::Vec;
use chrono_tz::Tz;
use core::str::FromStr;
use edge_http::io::server::Connection;
use embedded_io_async::{Read, Write};
use log::info;
@@ -142,21 +142,15 @@ pub(crate) async fn get_time<T, const N: usize>(
let mut board = BOARD_ACCESS.get().await.lock().await;
let conf = board.board_hal.get_config();
let tz:Tz = match conf.timezone.as_ref(){
None => {
Tz::UTC
}
Some(tz_string) => {
match Tz::from_str(tz_string) {
Ok(tz) => {
tz
}
Err(err) => {
info!("failed parsing timezone {}", err);
Tz::UTC
}
let tz: Tz = match conf.timezone.as_ref() {
None => Tz::UTC,
Some(tz_string) => match Tz::from_str(tz_string) {
Ok(tz) => tz,
Err(err) => {
info!("failed parsing timezone {err}");
Tz::UTC
}
}
},
};
let native = esp_time().await.with_timezone(&tz).to_rfc3339();
@@ -164,7 +158,7 @@ pub(crate) async fn get_time<T, const N: usize>(
let rtc = match board.board_hal.get_rtc_module().get_rtc_time().await {
Ok(time) => time.with_timezone(&tz).to_rfc3339(),
Err(err) => {
format!("Error getting time: {}", err)
format!("Error getting time: {err}")
}
};

View File

@@ -19,7 +19,7 @@ use crate::webserver::get_log::get_log;
use crate::webserver::get_static::{serve_bundle, serve_favicon, serve_index};
use crate::webserver::ota::ota_operations;
use crate::webserver::post_json::{
board_test, night_lamp_test, pump_test, set_config, wifi_scan, write_time, detect_sensors,
board_test, detect_sensors, night_lamp_test, pump_test, set_config, wifi_scan, write_time,
};
use crate::{bail, BOARD_ACCESS};
use alloc::borrow::ToOwned;
@@ -64,7 +64,7 @@ impl Handler for HTTPRequestRouter {
file_operations(conn, method, &path, &prefix).await?
} else if path == "/ota" {
ota_operations(conn, method).await.map_err(|e| {
error!("Error handling ota: {}", e);
error!("Error handling ota: {e}");
e
})?
} else {
@@ -238,7 +238,7 @@ where
},
Err(err) => {
let error_text = err.to_string();
info!("error handling process {}", error_text);
info!("error handling process {error_text}");
conn.initiate_response(
500,
Some("OK"),

View File

@@ -32,7 +32,7 @@ where
let mut chunk = 0;
loop {
let buf = read_up_to_bytes_from_request(conn, Some(4096)).await?;
if buf.len() == 0 {
if buf.is_empty() {
info!("file request for ota finished");
let mut board = BOARD_ACCESS.get().await.lock().await;
board.board_hal.get_esp().finalize_ota().await?;
@@ -45,11 +45,11 @@ where
board
.board_hal
.get_esp()
.write_ota(offset as u32, &*buf)
.write_ota(offset as u32, &buf)
.await?;
}
offset = offset + buf.len();
chunk = chunk + 1;
offset += buf.len();
chunk += 1;
}
BOARD_ACCESS
.get()

View File

@@ -113,7 +113,7 @@ where
let mut board = BOARD_ACCESS.get().await.lock().await;
board.board_hal.get_esp().save_config(all).await?;
info!("Wrote config config {:?} with size {}", config, length);
info!("Wrote config config {config:?} with size {length}");
board.board_hal.set_config(config);
Ok(Some("Ok".to_string()))
}