///! **Fetch System Status** ///! ///! This example demostrates reading the system status from the sensor via a network connection. ///! You can either use WiFi or Ethernet. // // Import the client library. Add this to your `Cargo.toml`: // islabtech-upw-sensor-v1 = "0" use islabtech_upw_sensor_v1::{connect_via_network_on_port, Device, Error}; // You also want to import `tokio` in order to easily call the async library functions. // Add this to your Cargo.toml: // tokio = { version = "1.37.0", features = ["macros", "rt-multi-thread"] } use tokio; #[tokio::main] async fn main() -> Result<(), Error> { // establish a connection to your sensor over network. // The device shows its IP address(es) on its home screen. // The API port is 80. let sensor = connect_via_network_on_port( "192.168.1.123".parse().unwrap(), // put your sensor's IP address here. It shows its address on its home screen. 80.into(), // insert your port here or use `Default::default()` (defaults to 80) Default::default(), // specify TLS settings here or use `Default::default()` (defaults to `UseTls::Auto`) ); // pull the current system status from the device let status = sensor.system_status().await?; println!("{status:?}"); // Example output: // SystemStatus { firmware: FirmwareSystemStatus { version: Version { major: 0, minor: 1, patch: // 1 }, updates: FirmwareUpdatesSystemStatus { enabled: true } }, hardware: HardwareSystemStatus // { version: Version { major: 1, minor: 5, patch: 0 }, serial_number: 0B91-2FF2-C74D-5AD9 }, // time:TimeSystemStatus { milliseconds_since_boot: 82308, seconds_since_boot: 82, current_time: // 2024-05-22T20:37:18Z } } Ok(()) }