use fleascope_rs::{FleaConnector, FleaScope};
fn main() -> Result<(), Box<dyn std::error::Error>> {
env_logger::init();
println!("FleaScope Device Discovery Example");
println!("=================================\n");
println!("1. Discovering available FleaScope devices...");
let devices = FleaConnector::get_available_devices_vec(None)?;
if devices.is_empty() {
println!("No FleaScope devices found. Please connect a device and try again.");
return Ok(());
}
println!("Found {} device(s):", devices.len());
for (i, device) in devices.iter().enumerate() {
println!(" {}. {} at {}", i + 1, device.name, device.port);
}
println!();
println!("2. Connecting to first available device...");
let mut scope = FleaScope::connect(None, None, true)?;
println!("Successfully connected!");
println!("\n3. Device information:");
println!("Connection established with auto-initialization");
println!("\n4. Testing basic communication...");
scope.set_waveform(fleascope_rs::Waveform::Sine, 100)?;
println!("Successfully set 100Hz sine wave");
println!("\n5. Connection test completed successfully!");
Ok(())
}