-
Notifications
You must be signed in to change notification settings - Fork 23
Adding wifi speed feature for linux #23
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
base: master
Are you sure you want to change the base?
Conversation
Feel free to suggest any modifications. |
src/connectivity/mod.rs
Outdated
fn disconnect(&self) -> Result<bool, WifiConnectionError>; | ||
|
||
// determines speed when connected to a network | ||
fn speed(&self) -> Result<String, WifiConnectionError>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Provide a default implementation of unimplemented!()
. This should prevent the build from failing for other targets.
src/connectivity/mod.rs
Outdated
/// Disconnects from a wireless network currently connected to. | ||
fn disconnect(&self) -> Result<bool, WifiConnectionError>; | ||
|
||
// determines speed when connected to a network |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor: Start with caps.
let piped_awk = Command::new("awk") | ||
.arg(r"/\*/{if (NR!=1) {print $6}}") | ||
.stdin(Stdio::from(nmcli_speed.stdout.unwrap())) // Pipe through. | ||
.stdout(Stdio::piped()) | ||
.spawn() | ||
.unwrap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be parsed manually. We'll want to reduce as much dependency as possible on external programs.
In the future, I plan to remove dependency on nmcli
for a similar reason.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, when parsing manually, could you add test cases to verify we're parsing the output of nmcli
correctly?
src/connectivity/providers/linux.rs
Outdated
.arg("list") | ||
.stdout(Stdio::piped()) | ||
.spawn() | ||
.expect("nothing"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Handle this error correctly i.e. use the WifiConnectionError
type.
use std::process::{Command, Stdio}; | ||
|
||
fn main() -> Result<(), WifiConnectionError> { | ||
let config = Some(Config { | ||
interface: Some("wlo1"), | ||
interface: Some("wlan0"), | ||
}); | ||
|
||
let mut wifi = WiFi::new(config); | ||
|
||
match wifi.connect("CSIS_MH", "") { | ||
match wifi.connect("TP-Link_CEE2", "05Bs@sdfvn") { | ||
Ok(result) => println!( | ||
"{}", | ||
if result == true { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure these changes are needed. You can easily setup a test program that points to your own version of the changes.
Thanks for the improvement. 😃 Could you kindly address the above changes? |
Thx for the suggestions, will definitely make improvements |
reflected on changes that you mentioned |
yaa will definitely try to implement features without external libraries like nmcli |
Implementing wifi speed using nmcli for linux