new ota logic

This commit is contained in:
2026-03-15 19:57:19 +01:00
parent 07ab69075a
commit c61a586595
15 changed files with 313 additions and 400 deletions

View File

@@ -11,6 +11,7 @@ use embedded_storage::nor_flash::NorFlashErrorKind;
use esp_hal::i2c::master::ConfigError;
use esp_hal::pcnt::unit::{InvalidHighLimit, InvalidLowLimit};
use esp_hal::twai::EspTwaiError;
use esp_hal_ota::OtaError;
use esp_radio::wifi::WifiError;
use ina219::errors::{BusVoltageReadError, ShuntVoltageReadError};
use lib_bms_protocol::BmsProtocolError;
@@ -73,6 +74,9 @@ pub enum FatError {
SNTPError {
error: sntpc::Error,
},
OtaError {
error: OtaError,
},
}
pub type FatResult<T> = Result<T, FatError>;
@@ -106,6 +110,7 @@ impl fmt::Display for FatError {
}
FatError::SNTPError { error } => write!(f, "SNTPError {error:?}"),
FatError::BMSError { error } => write!(f, "BMSError, {error}"),
FatError::OtaError { error } => write!(f, "OtaError {error:?}"),
}
}
}
@@ -323,13 +328,18 @@ impl From<sntpc::Error> for FatError {
}
}
impl From<BmsProtocolError> for FatError{
impl From<BmsProtocolError> for FatError {
fn from(value: BmsProtocolError) -> Self {
match value {
BmsProtocolError::I2cCommunicationError => {
FatError::String{error: "I2C communication error".to_string()}
}
BmsProtocolError::I2cCommunicationError => FatError::String {
error: "I2C communication error".to_string(),
},
}
}
}
}
impl From<OtaError> for FatError {
fn from(value: OtaError) -> Self {
FatError::OtaError { error: value }
}
}