use std::time::{SystemTime, UNIX_EPOCH};
use takproto::proto::{CotEvent, Detail};
use takproto::TakClient;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let now_ms = SystemTime::now().duration_since(UNIX_EPOCH)?.as_millis() as u64;
let event = CotEvent {
r#type: "b-m-p-s-m".to_string(),
uid: "TEST-LINKS".to_string(),
send_time: now_ms,
start_time: now_ms,
stale_time: now_ms + 300_000,
how: "h-e".to_string(),
lat: 39.377445,
lon: -76.83216000,
hae: 10.0,
ce: 9.9,
le: 9.9,
detail: Some(Detail {
xml_detail: r#"<contact callsign="Test Marker"/>
<link uid="TEST-LINKS" production_time="2024-01-01T00:00:00Z" type="b-m-p-s-m" relation="p-p" url="https://www.rust-lang.org" mime="text/html" remarks="Rust Website"/>
<remarks>Marker with link</remarks>"#.to_string(),
..Default::default()
}),
..Default::default()
};
println!("=== XML Representation ===");
println!("{}", takproto::xml::encode_cot_event_xml(&event));
println!("\n=== Instructions ===");
println!("This shows what the XML looks like when sent in XML mode.");
println!("After protocol negotiation, this gets encoded as protobuf.");
println!("\nThe issue might be that TAK clients expect the link element");
println!("at a specific location in the detail hierarchy.");
Ok(())
}