diff --git a/rust/src/hal/initial_hal.rs b/rust/src/hal/initial_hal.rs index d054f10..3a944b2 100644 --- a/rust/src/hal/initial_hal.rs +++ b/rust/src/hal/initial_hal.rs @@ -12,7 +12,7 @@ pub struct Initial<'a> { pub(crate) general_fault: PinDriver<'a, esp_idf_hal::gpio::AnyIOPin, InputOutput>, pub(crate) esp: ESP<'a>, pub(crate) config: PlantControllerConfig, - pub(crate) battery: Box, + pub(crate) battery: Box, } pub(crate) fn create_initial_board( @@ -20,7 +20,7 @@ pub(crate) fn create_initial_board( fs_mount_error: bool, config: PlantControllerConfig, esp: ESP<'static>, -) -> Result> + Send + Sync> { +) -> Result + Send>> { let mut general_fault = PinDriver::input_output(free_pins.gpio6.downgrade())?; general_fault.set_pull(Pull::Floating)?; general_fault.set_low()?; @@ -46,7 +46,7 @@ impl<'a> BoardInteraction<'a> for Initial<'a> { &self.config } - fn get_battery_monitor(&mut self) -> &mut Box { + fn get_battery_monitor(&mut self) -> &mut Box { &mut self.battery } diff --git a/rust/src/hal/mod.rs b/rust/src/hal/mod.rs index 79ca9e0..c05b9e4 100644 --- a/rust/src/hal/mod.rs +++ b/rust/src/hal/mod.rs @@ -93,7 +93,7 @@ pub enum Sensor { pub struct PlantHal {} pub struct HAL<'a> { - pub board_hal: Box + Sync + Send>, + pub board_hal: Box + Send>, } #[derive(Serialize, Deserialize, PartialEq, Debug)] @@ -116,7 +116,7 @@ impl Default for BackupHeader { pub trait BoardInteraction<'a> { fn get_esp(&mut self) -> &mut ESP<'a>; fn get_config(&mut self) -> &PlantControllerConfig; - fn get_battery_monitor(&mut self) -> &mut Box; + fn get_battery_monitor(&mut self) -> &mut Box; fn set_charge_indicator(&mut self, charging: bool) -> Result<()>; fn deep_sleep(&mut self, duration_in_ms: u64) -> !; fn get_backup_info(&mut self) -> Result; @@ -304,9 +304,9 @@ impl PlantHal { } BatteryBoardVersion::WchI2cSlave => BatteryMonitor::WchI2cSlave {}, }; - let battery_interaction = Box::new(battery_monitor) as Box; + let battery_interaction = Box::new(battery_monitor) as Box; - let board_hal: Box = match config.hardware.board { + let board_hal: Box = match config.hardware.board { BoardVersion::INITIAL => { initial_hal::create_initial_board(free_pins, fs_mount_error, config, esp)? } diff --git a/rust/src/hal/v3_hal.rs b/rust/src/hal/v3_hal.rs index e8ee742..968a066 100644 --- a/rust/src/hal/v3_hal.rs +++ b/rust/src/hal/v3_hal.rs @@ -75,7 +75,7 @@ const FAULT_2: usize = 23; pub struct V3<'a> { config: PlantControllerConfig, - battery_monitor: Box, + battery_monitor: Box, esp: ESP<'a>, shift_register: ShiftRegister40< PinDriver<'a, esp_idf_hal::gpio::AnyIOPin, InputOutput>, @@ -106,8 +106,8 @@ pub(crate) fn create_v3( peripherals: FreePeripherals, esp: ESP<'static>, config: PlantControllerConfig, - battery_monitor: Box, -) -> Result> { + battery_monitor: Box, +) -> Result> { let mut clock = PinDriver::input_output(peripherals.gpio15.downgrade())?; clock.set_pull(Pull::Floating)?; let mut latch = PinDriver::input_output(peripherals.gpio3.downgrade())?; @@ -255,7 +255,7 @@ impl<'a> BoardInteraction<'a> for V3<'a> { &self.config } - fn get_battery_monitor(&mut self) -> &mut Box<(dyn BatteryInteraction + 'static)> { + fn get_battery_monitor(&mut self) -> &mut Box<(dyn BatteryInteraction + Send + 'static)> { &mut self.battery_monitor } diff --git a/rust/src/hal/v4_hal.rs b/rust/src/hal/v4_hal.rs index ddb1419..8fcf1bf 100644 --- a/rust/src/hal/v4_hal.rs +++ b/rust/src/hal/v4_hal.rs @@ -36,7 +36,7 @@ const SENSOR_ON: u8 = 5_u8; pub struct V4<'a> { esp: ESP<'a>, - battery_monitor: Box, + battery_monitor: Box, config: PlantControllerConfig, tank_channel: AdcChannelDriver<'a, Gpio5, AdcDriver<'a, esp_idf_hal::adc::ADC1>>, solar_is_day: PinDriver<'a, esp_idf_hal::gpio::AnyIOPin, esp_idf_hal::gpio::Input>, @@ -63,8 +63,8 @@ pub(crate) fn create_v4( peripherals: FreePeripherals, esp: ESP<'static>, config: PlantControllerConfig, - battery_monitor: Box, -) -> anyhow::Result> { + battery_monitor: Box, +) -> anyhow::Result> { let mut awake = PinDriver::output(peripherals.gpio15.downgrade())?; awake.set_high()?; @@ -199,7 +199,7 @@ impl<'a> BoardInteraction<'a> for V4<'a> { &self.config } - fn get_battery_monitor(&mut self) -> &mut Box { + fn get_battery_monitor(&mut self) -> &mut Box { &mut self.battery_monitor } diff --git a/rust/src/main.rs b/rust/src/main.rs index 89ad933..8012341 100644 --- a/rust/src/main.rs +++ b/rust/src/main.rs @@ -31,7 +31,7 @@ use tank::*; use crate::config::BoardVersion::INITIAL; use crate::hal::{BoardInteraction, PlantHal, HAL, PLANT_COUNT}; use crate::hal::battery::BatteryInteraction; -pub static BOARD_ACCESS: Lazy>> = Lazy::new(|| Arc::new(PlantHal::create().unwrap())); +pub static BOARD_ACCESS: Lazy> = Lazy::new(|| PlantHal::create().unwrap()); pub static STAY_ALIVE: Lazy = Lazy::new(|| AtomicBool::new(false)); mod webserver {