Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load config on startup #77

Merged
merged 1 commit into from
Dec 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion ublox-short-range/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
},
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;
Expand Down Expand Up @@ -197,7 +197,7 @@
config: Config<RST>,
) -> (UbloxWifiIngress<INGRESS_BUF_SIZE>, Self) {
let (ingress, client) =
buffers.split_blocking(tx, EdmDigester::default(), atat::Config::default());

Check warning on line 200 in ublox-short-range/src/client.rs

View workflow job for this annotation

GitHub Actions / clippy

use of `default` to create a unit struct

warning: use of `default` to create a unit struct --> ublox-short-range/src/client.rs:200:51 | 200 | buffers.split_blocking(tx, EdmDigester::default(), atat::Config::default()); | ^^^^^^^^^^^ help: remove this call to `default` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#default_constructed_unit_structs = note: `#[warn(clippy::default_constructed_unit_structs)]` on by default

(
ingress,
Expand Down Expand Up @@ -335,6 +335,8 @@
}
}

self.load_wifi_config();

self.initialized = true;

Ok(())
Expand All @@ -360,6 +362,31 @@
}
}

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,

Check warning on line 375 in ublox-short-range/src/client.rs

View workflow job for this annotation

GitHub Actions / clippy

redundant field names in struct initialization

warning: redundant field names in struct initialization --> ublox-short-range/src/client.rs:375:29 | 375 | ... ssid: ssid, | ^^^^^^^^^^ help: replace it with: `ssid` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_field_names = note: `#[warn(clippy::redundant_field_names)]` on by default
channel: 0,
rssi: 1,
authentication_suites: 0,
unicast_ciphers: 0,
group_ciphers: 0,
mode: WifiMode::Station,
},
WiFiState::NotConnected,
));
}
}
}
}

pub fn retry_send<A, const LEN: usize>(
&mut self,
cmd: &A,
Expand Down
Loading