use std::time::Duration;
use tokio::time::sleep;
use knust::protocol::address::{GroupAddress, IndividualAddress};
use knust::{ConnectionConfig, ConnectionType, Knx};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
env_logger::init();
let config = ConnectionConfig {
connection_type: ConnectionType::Tunneling,
gateway_ip: Some("192.168.1.100".parse()?),
individual_address: IndividualAddress::new(1, 1, 240),
..Default::default()
};
let knx = Knx::new(config).await?;
knx.connect().await?;
let addresses = vec![
GroupAddress::from_parts(1, 2, 3)?, GroupAddress::from_parts(2, 1, 1)?, GroupAddress::from_parts(3, 0, 5)?, ];
println!("Reading values from group addresses...");
for address in addresses {
println!("Reading from {address}...");
sleep(Duration::from_millis(500)).await;
println!(" Address {address}: Value read (implementation pending)");
}
knx.disconnect().await?;
println!("Value reader example completed successfully!");
Ok(())
}