takproto 0.4.2

Rust library for TAK (Team Awareness Kit) Protocol - send CoT messages to TAK servers with mTLS support
Documentation
use std::time::{SystemTime, UNIX_EPOCH};
use takproto::proto::{CotEvent, Detail};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let now_ms = SystemTime::now().duration_since(UNIX_EPOCH)?.as_millis() as u64;

    println!("=== Example 1: With <contact> element ===\n");
    let event1 = CotEvent {
        r#type: "b-m-p-s-m".to_string(),
        uid: "MARKER-WITH-CONTACT".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="XML Mode Test"/>
<link uid="MARKER-WITH-CONTACT" type="b-m-p-s-m" relation="p-p" url="https://www.rust-lang.org" mime="text/html" remarks="Open Link"/>
<remarks>This has a contact element</remarks>"#.to_string(),
            ..Default::default()
        }),
        ..Default::default()
    };

    println!("{}\n", takproto::xml::encode_cot_event_xml(&event1));

    println!("=== Example 2: WITHOUT <contact> element ===\n");
    let event2 = CotEvent {
        r#type: "b-m-p-s-m".to_string(),
        uid: "SIMPLE-MARKER".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#"<link uid="SIMPLE-MARKER" type="b-m-p-s-m" relation="p-p" url="https://www.rust-lang.org" mime="text/html" remarks="Open Link"/>
<remarks>No contact element</remarks>"#.to_string(),
            ..Default::default()
        }),
        ..Default::default()
    };

    println!("{}\n", takproto::xml::encode_cot_event_xml(&event2));

    println!("=== EXPLANATION ===");
    println!("iTAK displays the 'uid' attribute as the marker name.");
    println!("If you add <contact callsign='...'>, iTAK may also show that callsign.");
    println!("This can cause confusion or duplicate display names.");
    println!("\nRECOMMENDATION:");
    println!("  1. Use a descriptive 'uid' (this is what shows as the marker name)");
    println!("  2. Skip the <contact> element unless you need the endpoint info");
    println!("  3. Put your description in <remarks> instead");

    Ok(())
}