This commit is contained in:
2025-09-14 13:50:46 +02:00
parent 4aa25c687b
commit 049a9d027c
3 changed files with 27 additions and 29 deletions

View File

@@ -6,6 +6,7 @@ use anyhow::{anyhow, bail, Context};
use chrono::{DateTime, Utc};
use serde::Serialize;
use alloc::string::ToString;
use alloc::{string::String, vec::Vec};
use core::marker::PhantomData;
use core::net::{IpAddr, Ipv4Addr};
@@ -176,9 +177,9 @@ impl Esp<'_> {
}
pub(crate) async fn wifi_ap(&mut self) -> anyhow::Result<Stack<'static>> {
let _ssid = match self.load_config() {
Ok(config) => config.network.ap_ssid.clone(),
Err(_) => heapless::String::from_str("PlantCtrl Emergency Mode").unwrap(),
let ssid = match self.load_config() {
Ok(config) => config.network.ap_ssid.as_str().to_string(),
Err(_) => "PlantCtrl Emergency Mode".to_string(),
};
let spawner = Spawner::for_current_executor().await;
@@ -205,7 +206,7 @@ impl Esp<'_> {
let stack = mk_static!(Stack, stack);
let controller = self.controller.take().unwrap();
spawner.spawn(connection(controller)).ok();
spawner.spawn(connection(controller, ssid)).ok();
spawner.spawn(net_task(runner)).ok();
spawner.spawn(run_dhcp(stack.clone(), gw_ip_addr_str)).ok();
@@ -739,7 +740,7 @@ async fn run_dhcp(stack: Stack<'static>, gw_ip_addr: &'static str) {
}
#[embassy_executor::task]
async fn connection(mut controller: WifiController<'static>) {
async fn connection(mut controller: WifiController<'static>, ssid: String) {
println!("start connection task");
println!("Device capabilities: {:?}", controller.capabilities());
loop {
@@ -753,7 +754,7 @@ async fn connection(mut controller: WifiController<'static>) {
}
if !matches!(controller.is_started(), core::result::Result::Ok(true)) {
let client_config = Configuration::AccessPoint(AccessPointConfiguration {
ssid: "esp-wifi".try_into().unwrap(),
ssid: ssid.clone(),
..Default::default()
});
controller.set_configuration(&client_config).unwrap();