initial webserver stub running

This commit is contained in:
2025-09-14 05:29:23 +02:00
parent be3c4a5095
commit b3cc313139
9 changed files with 959 additions and 726 deletions

View File

@@ -11,6 +11,7 @@ use esp_backtrace as _;
use crate::config::PlantConfig;
use crate::tank::WATER_FROZEN_THRESH;
use crate::webserver::httpd;
use crate::{
config::BoardVersion::INITIAL,
hal::{PlantHal, HAL, PLANT_COUNT},
@@ -23,7 +24,7 @@ use alloc::sync::Arc;
use alloc::{format, vec};
use chrono::{DateTime, Datelike, Timelike, Utc};
use chrono_tz::Tz::{self};
use core::sync::atomic::Ordering;
use core::sync::atomic::{AtomicBool, Ordering};
use embassy_executor::Spawner;
use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex;
use embassy_sync::mutex::{Mutex, MutexGuard};
@@ -36,7 +37,6 @@ use esp_println::{logger, println};
use hal::battery::BatteryState;
use log::{log, LogMessage};
use plant_state::PlantState;
use portable_atomic::AtomicBool;
use serde::{Deserialize, Serialize};
#[no_mangle]
@@ -57,7 +57,9 @@ mod config;
mod hal;
mod log;
mod plant_state;
mod sipo;
mod tank;
mod webserver;
extern crate alloc;
//mod webserver;
@@ -235,11 +237,11 @@ async fn safe_main() -> anyhow::Result<()> {
&& board.board_hal.get_config().network.ssid.is_none()
{
info!("No wifi configured, starting initial config mode");
board.board_hal.get_esp().wifi_ap().await.unwrap();
drop(board);
let stack = board.board_hal.get_esp().wifi_ap().await?;
let reboot_now = Arc::new(AtomicBool::new(false));
//TODO
//let _webserver = httpd(reboot_now.clone());
println!("starting webserver");
let _webserver = httpd(reboot_now.clone(), stack).await;
wait_infinity(WaitType::MissingConfig, reboot_now.clone()).await;
}
@@ -1055,7 +1057,7 @@ async fn main(spawner: Spawner) {
logger::init_logger_from_env();
//force init here!
println!("Hal init");
match BOARD_ACCESS.init(PlantHal::create(spawner).unwrap()) {
match BOARD_ACCESS.init(PlantHal::create(spawner).await.unwrap()) {
Ok(_) => {}
Err(_) => {
panic!("Could not set hal to static")