update: refactor and enhance CAN sensor initialization, reorganize GPIO assignments, improve error detection and logging, and streamline TWAI handling
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user