From 3f6beae7b02c03598361466d719cfba3a3aea63b Mon Sep 17 00:00:00 2001 From: Lena Date: Fri, 27 Oct 2023 21:55:20 +0200 Subject: [PATCH] add `load_network_slot` (commented out atm) --- ctru-rs/src/services/ac.rs | 70 ++++++++++++++++++++++++++++--------- ctru-rs/src/services/mod.rs | 2 +- 2 files changed, 55 insertions(+), 17 deletions(-) diff --git a/ctru-rs/src/services/ac.rs b/ctru-rs/src/services/ac.rs index 2630629..d85e819 100644 --- a/ctru-rs/src/services/ac.rs +++ b/ctru-rs/src/services/ac.rs @@ -41,7 +41,7 @@ impl Ac { /// use ctru::services::ac::Ac; /// /// let ac = Ac::new()?; - /// + /// /// println!("Waiting for an internet connection..."); /// ac.wait_for_internet_connection()?; /// println!("Connected."); @@ -70,7 +70,7 @@ impl Ac { /// use ctru::services::ac::Ac; /// /// let ac = Ac::new()?; - /// + /// /// println!("Wi-Fi connected: {}", ac.get_wifi_status()?); /// # /// # Ok(()) @@ -98,7 +98,7 @@ impl Ac { /// use ctru::services::ac::Ac; /// /// let ac = Ac::new()?; - /// + /// /// # /// # Ok(()) /// # } @@ -115,7 +115,7 @@ impl Ac { } /// Returns the SSID of the Wi-Fi network the console is connected to, or error if the console isn't connected to any network. - /// + /// /// You can check if the console is connected to a network using [`Self::get_wifi_status()`] /// /// # Example @@ -128,7 +128,7 @@ impl Ac { /// use ctru::services::ac::Ac; /// /// let ac = Ac::new()?; - /// + /// /// println!("The console is connected to the network \"{}\"", ac.get_wifi_ssid().unwrap()) /// # /// # Ok(()) @@ -159,9 +159,9 @@ impl Ac { /// use ctru::services::ac::Ac; /// /// let ac = Ac::new()?; - /// + /// /// println!("Proxy enabled: {}", ac.get_proxy_enabled()?); - /// + /// /// # /// # Ok(()) /// # } @@ -179,7 +179,7 @@ impl Ac { /// Returns the connected network's proxy port, if present. /// /// You can check if the console is using a proxy with [`Self::get_proxy_enabled()`] - /// + /// /// # Example /// /// ``` @@ -190,7 +190,7 @@ impl Ac { /// use ctru::services::ac::Ac; /// /// let ac = Ac::new()?; - /// + /// /// println!("Proxy port: {}", ac.get_proxy_port()?); /// # /// # Ok(()) @@ -209,7 +209,7 @@ impl Ac { /// Returns the connected network's proxy username, if present. /// /// You can check if the console is using a proxy with [`Self::get_proxy_enabled()`] - /// + /// /// # Example /// /// ``` @@ -220,9 +220,9 @@ impl Ac { /// use ctru::services::ac::Ac; /// /// let ac = Ac::new()?; - /// + /// /// println!("Proxy username: {}", ac.get_proxy_username()?); - /// + /// /// # /// # Ok(()) /// # } @@ -241,7 +241,7 @@ impl Ac { /// Returns the connected network's proxy password, if present. /// /// You can check if the console is using a proxy with [`Self::get_proxy_enabled()`] - /// + /// /// # Example /// /// ``` @@ -252,7 +252,7 @@ impl Ac { /// use ctru::services::ac::Ac; /// /// let ac = Ac::new()?; - /// + /// /// println!("Proxy password: {}", ac.get_proxy_password()?); /// # /// # Ok(()) @@ -268,6 +268,34 @@ impl Ac { Ok(String::from_utf8(vec).unwrap()) } } + + /* + /// Load the selected network slot, if present. + /// + /// Note: this method requires `ac:i` access + /// # Example + /// + /// ``` + /// # let _runner = test_runner::GdbRunner::default(); + /// # use std::error::Error; + /// # fn main() -> Result<(), Box> { + /// # + /// use ctru::services::ac::Ac; + /// + /// let ac = Ac::new()?; + /// + /// ac.load_network_slot(NetworkSlot::Second)?; + /// # + /// # Ok(()) + /// # } + /// ``` + #[doc(alias = "ACI_LoadNetworkSetting")] + pub fn load_network_slot(&self, slot: NetworkSlot) -> crate::Result<()> { + unsafe { + ResultCode(ctru_sys::ACI_LoadNetworkSetting(slot as u32))?; + Ok(()) + } + }*/ } impl Drop for Ac { @@ -288,5 +316,15 @@ pub enum SecurityMode { WPA_TKIP = 4, WPA2_TKIP = 5, WPA_AES = 6, - WPA2_AES = 7 -} \ No newline at end of file + WPA2_AES = 7, +} + +/* +#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] +#[repr(u32)] +pub enum NetworkSlot { + First = 0, + Second = 1, + Third = 2 +} +*/ diff --git a/ctru-rs/src/services/mod.rs b/ctru-rs/src/services/mod.rs index 86ada52..e378c8d 100644 --- a/ctru-rs/src/services/mod.rs +++ b/ctru-rs/src/services/mod.rs @@ -11,6 +11,7 @@ //! //! In [`ctru-rs`](crate) some services only allow a single handle to be created at a time, to ensure a safe and controlled environment. +pub mod ac; pub mod am; pub mod apt; pub mod cam; @@ -26,7 +27,6 @@ mod reference; pub mod soc; pub mod sslc; pub mod svc; -pub mod ac; cfg_if::cfg_if! { if #[cfg(all(feature = "romfs", romfs_exists))] {