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

(feature): Add simple activate if module already have config #71

Merged
merged 3 commits into from
Dec 4, 2023
Merged
Changes from 1 commit
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
52 changes: 52 additions & 0 deletions ublox-short-range/src/wifi/sta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
self.send_internal(
&EdmAtCmdWrapper(SetWifiStationConfig {
config_id: CONFIG_ID,
config_param: WifiStationConfig::WpaPskOrPassphrase(&pass),

Check warning on line 108 in ublox-short-range/src/wifi/sta.rs

View workflow job for this annotation

GitHub Actions / clippy

this expression creates a reference which is immediately dereferenced by the compiler

warning: this expression creates a reference which is immediately dereferenced by the compiler --> ublox-short-range/src/wifi/sta.rs:108:73 | 108 | config_param: WifiStationConfig::WpaPskOrPassphrase(&pass), | ^^^^^ help: change this to: `pass` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
}),
true,
)?;
Expand Down Expand Up @@ -138,6 +138,17 @@
Ok(())
}

pub fn activate(&mut self) -> Result<(), WifiConnectionError> {
self.send_internal(
&EdmAtCmdWrapper(ExecWifiStationAction {
config_id: CONFIG_ID,
action: WifiStationAction::Activate,
}),
true,
)?;
return Ok(());

Check warning on line 149 in ublox-short-range/src/wifi/sta.rs

View workflow job for this annotation

GitHub Actions / clippy

unneeded `return` statement

warning: unneeded `return` statement --> ublox-short-range/src/wifi/sta.rs:149:9 | 149 | return Ok(()); | ^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return = note: `#[warn(clippy::needless_return)]` on by default help: remove `return` | 149 - return Ok(()); 149 + Ok(()) |
}

pub fn scan(&mut self) -> Result<Vec<WifiNetwork, 32>, WifiError> {
match self.send_internal(&EdmAtCmdWrapper(WifiScan { ssid: None }), true) {
Ok(resp) => resp
Expand All @@ -160,6 +171,47 @@
.unwrap_or_default()
}

pub fn is_active_on_startup(&mut self) -> Result<bool, WifiConnectionError> {
if let Ok(resp) = self.send_internal(
&EdmAtCmdWrapper(GetWifiStationConfig {
config_id: CONFIG_ID,
parameter: Some(WifiStationConfigParameter::ActiveOnStartup),
}),
false,
) {
if let WifiStationConfigR::ActiveOnStartup(active) = resp.parameter {
return Ok(active == OnOff::On);
}
}
Err(WifiConnectionError::Illegal)
}

pub fn get_ssid(&mut self) -> Result<heapless::String<64>, WifiConnectionError> {
if let Ok(resp) = self.send_internal(
&EdmAtCmdWrapper(GetWifiStationConfig {
config_id: CONFIG_ID,
parameter: Some(WifiStationConfigParameter::SSID),
}),
false,
) {
if let WifiStationConfigR::SSID(ssid) = resp.parameter {
return Ok(ssid);
}
};
return Err(WifiConnectionError::Illegal);

Check warning on line 201 in ublox-short-range/src/wifi/sta.rs

View workflow job for this annotation

GitHub Actions / clippy

unneeded `return` statement

warning: unneeded `return` statement --> ublox-short-range/src/wifi/sta.rs:201:9 | 201 | return Err(WifiConnectionError::Illegal); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return help: remove `return` | 201 - return Err(WifiConnectionError::Illegal); 201 + Err(WifiConnectionError::Illegal) |
}

pub fn reset_config_profile(&mut self) -> Result<(), WifiConnectionError> {
self.send_internal(
&EdmAtCmdWrapper(ExecWifiStationAction {
config_id: CONFIG_ID,
action: WifiStationAction::Reset,
}),
false,
)?;
Ok(())
}

pub fn disconnect(&mut self) -> Result<(), WifiConnectionError> {
if let Some(con) = self.wifi_connection.take() {
match con.wifi_state {
Expand Down
Loading