This commit is contained in:
2024-04-26 18:52:53 +02:00
parent d8044b8e34
commit 1fc04a58a0
4 changed files with 19 additions and 10 deletions

View File

@@ -676,7 +676,7 @@ impl PlantCtrlBoardInteraction for PlantCtrlBoard<'_> {
}
}
}
embedded_svc::mqtt::client::EventPayload::Connected{session_present: _} => {
embedded_svc::mqtt::client::EventPayload::Connected(_) => {
mqtt_connected_event_received_copy
.store(true, std::sync::atomic::Ordering::Relaxed);
mqtt_connected_event_ok_copy
@@ -894,6 +894,7 @@ impl PlantCtrlBoardInteraction for PlantCtrlBoard<'_> {
fn print_battery(
battery_driver: &mut Bq34z100g1Driver<I2cDriver, Delay>,
) -> Result<(), Bq34Z100Error<I2cError>> {
println!("Try communicating with battery");
let fwversion = battery_driver.fw_version().unwrap_or_else(|e| {
println!("Firmeware {:?}", e);
0
@@ -956,14 +957,19 @@ impl CreatePlantHal<'_> for PlantHal {
let config = I2cConfig::new()
.scl_enable_pullup(false)
.sda_enable_pullup(false)
.baudrate(10_u32.kHz().into());
.baudrate(10_u32.kHz().into())
.timeout(Duration::from_millis(10).into);
let scl = peripherals.pins.gpio19;
let sda = peripherals.pins.gpio20;
let driver = I2cDriver::new(i2c, sda, scl, &config).unwrap();
let i2c_port = driver.port();
esp!(unsafe { esp_idf_sys::i2c_set_timeout(i2c_port, 2)}).unwrap();
let mut timeout:i32 = 0;
esp!(unsafe { esp_idf_sys::i2c_get_timeout(i2c_port, &mut timeout)}).unwrap();
println!("Default i2c timeout is {}", timeout);
//esp!(unsafe { esp_idf_sys::i2c_set_timeout(i2c_port, 1)}).unwrap();
let mut battery_driver: Bq34z100g1Driver<I2cDriver, Delay> = Bq34z100g1Driver {
i2c: driver,