-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Gijs de Jong <[email protected]> Co-authored-by: Gijs de Jong <[email protected]> Co-authored-by: Mark Honkoop <[email protected]>
- Loading branch information
1 parent
e4e77aa
commit b77bae1
Showing
3 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
use clap::Args; | ||
use color_eyre::Result; | ||
|
||
use nao::Nao; | ||
|
||
use crate::parsers::NaoAddress; | ||
|
||
#[derive(Args)] | ||
pub struct Arguments { | ||
/// The NAO to update the IP address e.g. 10.0.8.42 | ||
#[arg(required = true)] | ||
pub nao: NaoAddress, | ||
|
||
/// The third octet of the new ip address for the robot. | ||
pub first_octet: u8, | ||
|
||
/// The last octet of the new ip address for the robot. | ||
pub second_octet: u8, | ||
} | ||
|
||
pub async fn change_ip(arguments: Arguments) -> Result<()> { | ||
let nao = Nao::new(arguments.nao.ip); | ||
|
||
let result = nao | ||
.set_last_ip_octets(arguments.first_octet, arguments.second_octet) | ||
.await; | ||
|
||
if result.is_ok() { | ||
println!( | ||
"The new IP address is: {}.{}.{}.{}", | ||
arguments.nao.ip.octets()[0], | ||
arguments.nao.ip.octets()[1], | ||
arguments.first_octet, | ||
arguments.second_octet | ||
); | ||
} | ||
|
||
result | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters