implement async mqtt config update trigger and fix mqtt.rs corruption
This commit is contained in:
@@ -279,23 +279,26 @@ async fn mqtt_incoming_task(
|
||||
match serde_json::from_str::<crate::config::PlantControllerConfig>(payload_str) {
|
||||
Ok(config) => {
|
||||
info!("Deserialized config, applying...");
|
||||
let board_mutex = crate::BOARD_ACCESS.get().await;
|
||||
let mut board = board_mutex.lock().await;
|
||||
if let Err(e) = board.board_hal.get_esp().save_config(payload_str.as_bytes().to_vec()).await {
|
||||
info!("Error saving config to flash: {}", e);
|
||||
} else {
|
||||
board.board_hal.set_config(config);
|
||||
info!("Config applied, rebooting");
|
||||
board.board_hal.get_esp().deep_sleep_ms(0);
|
||||
}
|
||||
|
||||
let board_mutex = crate::BOARD_ACCESS.get().await;
|
||||
let mut board = board_mutex.lock().await;
|
||||
if let Err(e) = board.board_hal.get_esp().save_config(payload_str.as_bytes().to_vec()).await {
|
||||
info!("Error saving config to flash: {}", e);
|
||||
let _ = publish("/config/update", "false").await;
|
||||
} else {
|
||||
board.board_hal.set_config(config);
|
||||
info!("Config applied, rebooting");
|
||||
let _ = publish("/config/update", "false").await;
|
||||
board.board_hal.get_esp().deep_sleep_ms(0);
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
info!("Error deserializing config: {}", e);
|
||||
let _ = publish("/config/update", "false").await;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
info!("No config update payload available");
|
||||
let _ = publish("/config/update", "false").await;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user