fix tread safty issues by annotating Box Traits correctly

This commit is contained in:
2025-06-19 18:36:48 +02:00
parent e2cbf9618e
commit 69077239a5
5 changed files with 16 additions and 16 deletions

View File

@@ -36,7 +36,7 @@ const SENSOR_ON: u8 = 5_u8;
pub struct V4<'a> {
esp: ESP<'a>,
battery_monitor: Box<dyn BatteryInteraction>,
battery_monitor: Box<dyn BatteryInteraction + Send>,
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<dyn BatteryInteraction>,
) -> anyhow::Result<Box<dyn BoardInteraction + '_ + Send + Sync>> {
battery_monitor: Box<dyn BatteryInteraction + Send>,
) -> anyhow::Result<Box<dyn BoardInteraction + Send + '_>> {
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<dyn BatteryInteraction> {
fn get_battery_monitor(&mut self) -> &mut Box<dyn BatteryInteraction + Send> {
&mut self.battery_monitor
}