not working wip of station mode
This commit is contained in:
@@ -234,7 +234,7 @@ async fn safe_main(spawner: Spawner) -> FatResult<()> {
|
||||
{
|
||||
info!("No wifi configured, starting initial config mode");
|
||||
|
||||
let stack = board.board_hal.get_esp().wifi_ap().await?;
|
||||
let stack = board.board_hal.get_esp().wifi_ap(false).await?;
|
||||
|
||||
let reboot_now = Arc::new(AtomicBool::new(false));
|
||||
println!("starting webserver");
|
||||
@@ -243,8 +243,6 @@ async fn safe_main(spawner: Spawner) -> FatResult<()> {
|
||||
wait_infinity(board, WaitType::MissingConfig, reboot_now.clone()).await;
|
||||
}
|
||||
|
||||
info!("attempting to connect wifi ");
|
||||
|
||||
let mut stack = Option::None;
|
||||
let network_mode = if board.board_hal.get_config().network.ssid.is_some() {
|
||||
try_connect_wifi_sntp_mqtt(&mut board, *&mut stack).await
|
||||
@@ -261,7 +259,7 @@ async fn safe_main(spawner: Spawner) -> FatResult<()> {
|
||||
|
||||
let res = {
|
||||
let esp = board.board_hal.get_esp();
|
||||
esp.wifi_ap().await
|
||||
esp.wifi_ap(true).await
|
||||
|
||||
};
|
||||
match res {
|
||||
@@ -898,10 +896,16 @@ async fn publish_firmware_info(
|
||||
let _ = esp.mqtt_publish("/state", "online".as_bytes()).await;
|
||||
}
|
||||
|
||||
async fn try_connect_wifi_sntp_mqtt(board: &mut MutexGuard<'static, CriticalSectionRawMutex, HAL<'static>>, stack_store:Option<Stack<'_>>) -> NetworkMode {
|
||||
async fn try_connect_wifi_sntp_mqtt(board: &mut MutexGuard<'static, CriticalSectionRawMutex, HAL<'static>>, mut stack_store:Option<Stack<'_>>) -> NetworkMode {
|
||||
let nw_conf = &board.board_hal.get_config().network.clone();
|
||||
match board.board_hal.get_esp().wifi(nw_conf).await {
|
||||
Ok(ip_info) => {
|
||||
Ok(stack) => {
|
||||
stack_store = Some(stack);
|
||||
|
||||
loop {
|
||||
println!("wifi stuff");
|
||||
Timer::after_millis(1000).await;
|
||||
}
|
||||
let sntp_mode: SntpMode = match board.board_hal.get_esp().sntp(1000 * 10).await {
|
||||
Ok(new_time) => {
|
||||
info!("Using time from sntp");
|
||||
@@ -932,7 +936,7 @@ async fn try_connect_wifi_sntp_mqtt(board: &mut MutexGuard<'static, CriticalSect
|
||||
NetworkMode::WIFI {
|
||||
sntp: sntp_mode,
|
||||
mqtt: mqtt_connected,
|
||||
ip_address: ip_info.ip.to_string(),
|
||||
ip_address: stack.hardware_address().to_string(),
|
||||
}
|
||||
}
|
||||
Err(err) => {
|
||||
|
||||
Reference in New Issue
Block a user