From f9b508b806ec6b8be3e357555b2e6aa3f69da682 Mon Sep 17 00:00:00 2001 From: Kenneth Knudsen Date: Fri, 8 Dec 2023 15:26:39 +0100 Subject: [PATCH] Load config on startup --- ublox-short-range/src/client.rs | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/ublox-short-range/src/client.rs b/ublox-short-range/src/client.rs index d9c1543..9d75e80 100644 --- a/ublox-short-range/src/client.rs +++ b/ublox-short-range/src/client.rs @@ -32,7 +32,7 @@ use crate::{ }, UbloxWifiBuffers, UbloxWifiIngress, UbloxWifiUrcChannel, }; -use atat::{blocking::AtatClient, AtatUrcChannel, UrcSubscription}; +use atat::{blocking::AtatClient, heapless_bytes::Bytes, AtatUrcChannel, UrcSubscription}; use defmt::{debug, error, trace}; use embassy_time::{Duration, Instant}; use embedded_hal::digital::OutputPin; @@ -335,6 +335,8 @@ where } } + self.load_wifi_config(); + self.initialized = true; Ok(()) @@ -360,6 +362,31 @@ where } } + fn load_wifi_config(&mut self) { + //Check if we have active network config if so then update wifi_connection + if let Ok(active) = self.is_active_on_startup() { + if active { + if let Ok(ssid) = self.get_ssid() { + defmt::info!("Found network in module configuring as active network"); + self.wifi_connection.replace(WifiConnection::new( + WifiNetwork { + bssid: Bytes::new(), + op_mode: crate::command::wifi::types::OperationMode::Infrastructure, + ssid: ssid, + channel: 0, + rssi: 1, + authentication_suites: 0, + unicast_ciphers: 0, + group_ciphers: 0, + mode: WifiMode::Station, + }, + WiFiState::NotConnected, + )); + } + } + } + } + pub fn retry_send( &mut self, cmd: &A,