src/test.rs hinzugefügt

This commit is contained in:
2026-03-17 19:41:14 +00:00
parent 53f0018390
commit bae2586623

16
src/test.rs Normal file
View File

@@ -0,0 +1,16 @@
use std::net::UdpSocket;
//call from main fn
pub fn sendtestudp(to: String, port: u16, payload: String) {
let socket = UdpSocket::bind("0.0.0.0:0").expect("couldn't bind to address");
let to = format!("{}:{}", to, port);
//form hex string to real hex -> FF == 0xFF
let bytes: Vec<u8> = (0..payload.len())
.step_by(2)
.map(|i| u8::from_str_radix(&payload[i..i+2], 16).expect("not a real hex"))
.collect();
socket.send_to(&bytes, to);
}