Add get property commands for each property.

This commit is contained in:
Jeremy Whiting 2024-05-02 15:27:29 -06:00
parent d8b689ae50
commit 1fa25aaa41

View file

@ -27,6 +27,9 @@ struct Args {
#[derive(Subcommand)] #[derive(Subcommand)]
enum Commands { enum Commands {
GetAlsCalibrationGain {},
GetHardwareCurrentlySupported {},
SetFanControlState { SetFanControlState {
// Set the fan control state. // Set the fan control state.
// 0 - BIOS, 1 - OS // 0 - BIOS, 1 - OS
@ -34,6 +37,8 @@ enum Commands {
value: u32, value: u32,
}, },
GetFanControlState {},
SetGPUPerformanceLevel { SetGPUPerformanceLevel {
// Set the gpu performance level // Set the gpu performance level
// 0 = Auto, 1 = Low, 2 = High, 3 = Manual, 4 = Profile Peak // 0 = Auto, 1 = Low, 2 = High, 3 = Manual, 4 = Profile Peak
@ -41,6 +46,8 @@ enum Commands {
value: u32, value: u32,
}, },
GetGPUPerformanceLevel {},
SetManualGPUClock { SetManualGPUClock {
// Set the GPU clock value manually // Set the GPU clock value manually
// Controls the GPU clock frequency in MHz when GPUPerformanceLevel is set to Manual // Controls the GPU clock frequency in MHz when GPUPerformanceLevel is set to Manual
@ -48,12 +55,22 @@ enum Commands {
value: u32, value: u32,
}, },
GetManualGPUClock {},
GetManualGPUClockMax {},
GetManualGPUClockMin {},
SetTDPLimit { SetTDPLimit {
// Set the TDP limit // Set the TDP limit
#[arg(short, long)] #[arg(short, long)]
value: u32, value: u32,
}, },
GetTDPLimit {},
GetTDPLimitMax {},
GetTDPLimitMin {},
GetVersion {},
SetWifiBackend { SetWifiBackend {
// Set the wifi backend to given string if possible // Set the wifi backend to given string if possible
// Supported values are iwd|wpa_supplicant // Supported values are iwd|wpa_supplicant
@ -61,6 +78,8 @@ enum Commands {
backend: String, backend: String,
}, },
GetWifiBackend {},
SetWifiDebugMode { SetWifiDebugMode {
// Set wifi debug mode to given value // Set wifi debug mode to given value
// 1 for on, 0 for off currently // 1 for on, 0 for off currently
@ -68,12 +87,16 @@ enum Commands {
mode: u32, mode: u32,
}, },
GetWifiDebugMode {},
SetWifiPowerManagementState { SetWifiPowerManagementState {
// Set the wifi power management state // Set the wifi power management state
// 0 - disabled, 1 - enabled // 0 - disabled, 1 - enabled
#[arg(short, long)] #[arg(short, long)]
value: u32, value: u32,
}, },
GetWifiPowerManagementState {},
} }
#[tokio::main] #[tokio::main]
@ -107,18 +130,62 @@ async fn main() -> Result<()> {
// Then process arguments // Then process arguments
match &args.command { match &args.command {
Some(Commands::GetAlsCalibrationGain {}) => {
let gain = proxy.als_calibration_gain().await?;
println!("ALS calibration gain: {gain}");
}
Some(Commands::GetHardwareCurrentlySupported {}) => {
let supported = proxy.hardware_currently_supported().await?;
println!("Hardware currently supported: {supported}");
}
Some(Commands::GetVersion {}) => {
let version = proxy.version().await?;
println!("Version: {version}");
}
Some(Commands::SetFanControlState { value }) => { Some(Commands::SetFanControlState { value }) => {
proxy.set_fan_control_state(*value).await?; proxy.set_fan_control_state(*value).await?;
} }
Some(Commands::SetGPUPerformanceLevel { value }) => { Some(Commands::SetGPUPerformanceLevel { value }) => {
proxy.set_gpu_performance_level(*value).await?; proxy.set_gpu_performance_level(*value).await?;
} }
Some(Commands::GetGPUPerformanceLevel {}) => {
let level = proxy.gpu_performance_level().await?;
println!("GPU performance level: {level}");
}
Some(Commands::SetManualGPUClock { value }) => { Some(Commands::SetManualGPUClock { value }) => {
proxy.set_manual_gpu_clock(*value).await?; proxy.set_manual_gpu_clock(*value).await?;
} }
Some(Commands::GetManualGPUClock {}) => {
let clock = proxy.manual_gpu_clock().await?;
println!("Manual GPU Clock: {clock}");
}
Some(Commands::GetManualGPUClockMax {}) => {
let value = proxy.manual_gpu_clock_max().await?;
println!("Manual GPU Clock Max: {value}");
}
Some(Commands::GetManualGPUClockMin {}) => {
let value = proxy.manual_gpu_clock_min().await?;
println!("Manual GPU Clock Min: {value}");
}
Some(Commands::SetTDPLimit { value }) => { Some(Commands::SetTDPLimit { value }) => {
proxy.set_tdp_limit(*value).await?; proxy.set_tdp_limit(*value).await?;
} }
Some(Commands::GetTDPLimit {}) => {
let limit = proxy.tdp_limit().await?;
println!("TDP limit: {limit}");
}
Some(Commands::GetFanControlState {}) => {
let state = proxy.fan_control_state().await?;
println!("Fan control state: {state}");
}
Some(Commands::GetTDPLimitMax {}) => {
let value = proxy.tdp_limit_max().await?;
println!("TDP limit max: {value}");
}
Some(Commands::GetTDPLimitMin {}) => {
let value = proxy.tdp_limit_min().await?;
println!("TDP limit min: {value}");
}
Some(Commands::SetWifiBackend { backend }) => match WifiBackend::from_str(backend) { Some(Commands::SetWifiBackend { backend }) => match WifiBackend::from_str(backend) {
Ok(b) => { Ok(b) => {
proxy.set_wifi_backend(b as u32).await?; proxy.set_wifi_backend(b as u32).await?;
@ -127,12 +194,25 @@ async fn main() -> Result<()> {
println!("Unknown wifi backend {backend}"); println!("Unknown wifi backend {backend}");
} }
}, },
Some(Commands::GetWifiBackend {}) => {
let backend = proxy.wifi_backend().await?;
let backend_string = WifiBackend::try_from(backend).unwrap().to_string();
println!("Wifi backend: {backend_string}");
}
Some(Commands::SetWifiDebugMode { mode }) => { Some(Commands::SetWifiDebugMode { mode }) => {
proxy.set_wifi_debug_mode(*mode, 20000).await?; proxy.set_wifi_debug_mode(*mode, 20000).await?;
} }
Some(Commands::GetWifiDebugMode {}) => {
let mode = proxy.wifi_debug_mode_state().await?;
println!("Wifi debug mode: {mode}");
}
Some(Commands::SetWifiPowerManagementState { value }) => { Some(Commands::SetWifiPowerManagementState { value }) => {
proxy.set_wifi_power_management_state(*value).await?; proxy.set_wifi_power_management_state(*value).await?;
} }
Some(Commands::GetWifiPowerManagementState {}) => {
let state = proxy.wifi_power_management_state().await?;
println!("Wifi power management state: {state}");
}
None => {} None => {}
} }