update: refactor and enhance CAN sensor initialization, reorganize GPIO assignments, improve error detection and logging, and streamline TWAI handling

This commit is contained in:
2026-01-31 00:06:42 +01:00
parent 355388aa62
commit ce10d084f8
8 changed files with 70 additions and 16 deletions

View File

@@ -29,6 +29,11 @@ pub struct TestPump {
pump: usize,
}
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
pub struct CanPower {
state: bool,
}
pub(crate) async fn wifi_scan<T, const N: usize>(
_request: &mut Connection<'_, T, N>,
) -> FatResult<Option<String>> {
@@ -117,3 +122,22 @@ where
board.board_hal.set_config(config);
Ok(Some("Ok".to_string()))
}
pub(crate) async fn can_power<T, const N: usize>(
request: &mut Connection<'_, T, N>,
) -> FatResult<Option<String>>
where
T: Read + Write,
{
let actual_data = read_up_to_bytes_from_request(request, None).await?;
let pump_test: CanPower = serde_json::from_slice(&actual_data)?;
let mut board = BOARD_ACCESS.get().await.lock().await;
let config = &board.board_hal.can_power(pump_test.state).await?;
let enable = pump_test.state;
info!(
"set can power to {enable}"
);
Ok(None)
}