From c9f6a4a6c5ce6c58764154e6d7fe0925e9d92f87 Mon Sep 17 00:00:00 2001 From: mattbk Date: Sat, 18 Oct 2025 11:33:38 -0500 Subject: [PATCH] Spot packets to spothole.app if desired. --- src/main.rs | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 5eff6bc..fe2aaa2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -68,6 +68,10 @@ struct Cli { #[arg(short = 'o', long, default_value_t = false)] spothole: bool, + /// Spotting frequency + #[arg(short = 'f', long, default_value_t = 14105000)] + freq: u32, + } /// Convert a byte slice into a hex-dump string for debugging purposes. @@ -369,6 +373,7 @@ fn handle_frame(frame: &AgwFrame, cli: &Cli, buffers: &mut BufferManager) { let basic_destination = hdr.callto_str(); let timestamp = Local::now().format("%H:%M:%S").to_string(); let spotter = &cli.spotter; + let freq = &cli.freq; // Filter and compute the text from the payload only once. let text = filter_text(&frame.payload); @@ -408,8 +413,28 @@ fn handle_frame(frame: &AgwFrame, cli: &Cli, buffers: &mut BufferManager) { // If Spothole is enabled if summary == "UI" && cli.spothole { - let body = reqwest::blocking::get("https://spothole.app/api/v1/spots?limit=1"); - println!("body = {body:?}"); + // curl --request POST --header "Content-Type: application/json" + // --data '{"dx_call":"M0TRT","time":1760019539, "freq":14200000, + // "comment":"Test spot please ignore", "de_call":"M0TRT"}' https://spothole.app/api/v1/spot + + // POST JSON + let packet = json!({ + "dx_call": &source, + "de_call": &spotter, + "freq": &freq, + "comment": &text, + "mode": "PKT", + "mode_type": "DATA", + "mode_source": "SPOT", + "time": SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_secs(), + }); + let client = reqwest::blocking::Client::new(); + let res = client.post("https://spothole.app/api/v1/spot") + .json(&packet) + .send(); + println!("res = {res:?}"); + + } // Send UDP @@ -423,6 +448,7 @@ fn handle_frame(frame: &AgwFrame, cli: &Cli, buffers: &mut BufferManager) { "spotter": &spotter, "summary": &summary, "text": &text, + "freq": &freq, "timestamp": SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_secs(), "type": "data" });