use reentryudp::domain_models::*;
use strum::IntoEnumIterator;
use serde_json;
use std::net::UdpSocket;
fn main() {
let socket = UdpSocket::bind("127.0.0.1:0").unwrap();
loop {
for pin_position in PinPosition::iter().skip(1).take(3) {
let data_packet = DataPacket {
TargetCraft: Craft::Mercury as u32,
MessageType: MessageType::SetSwitch as u32,
ID: MercurySwitchID::CabinLight as u32,
ToPos: pin_position as u32,
};
let json = serde_json::to_string(&data_packet).unwrap();
println!("{}", json);
socket.send_to(json.as_bytes(), "127.0.0.1:8051").unwrap();
std::thread::sleep(std::time::Duration::from_secs(10));
}
}
}