takproto 0.4.2

Rust library for TAK (Team Awareness Kit) Protocol - send CoT messages to TAK servers with mTLS support
Documentation
//! Test connection state - does the server see us connected?

use takproto::{TakClient, TlsConfigBuilder};
use tokio::time::Duration;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let args: Vec<String> = std::env::args().collect();
    if args.len() < 6 {
        eprintln!("Usage: {} <server:port> <server_name> <p12_file> <password> <server_cert.pem>", args[0]);
        std::process::exit(1);
    }

    let server_addr = &args[1];
    let server_name = &args[2];
    let p12_file = &args[3];
    let password = &args[4];
    let server_cert = &args[5];

    let tls_config = TlsConfigBuilder::new()
        .with_p12(p12_file, password)?
        .with_additional_root_cert(server_cert)?
        .build()?;

    println!("Connecting to {}...", server_addr);
    let _client = TakClient::connect_tls(server_addr, server_name, tls_config).await?;
    println!("✓ Connected (client perspective)\n");

    println!("Waiting 30 seconds...");
    println!("Check your TAK server:");
    println!("  - Do you see a new connection?");
    println!("  - What does the connection count show?");
    println!("  - Any errors in server logs?");

    for i in 1..=30 {
        tokio::time::sleep(Duration::from_secs(1)).await;
        if i % 5 == 0 {
            println!("  {} seconds elapsed...", i);
        }
    }

    println!("\n✓ Connection held for 30 seconds");
    println!("Did the server show an active connection?");

    Ok(())
}