1
0
mirror of https://gitea.farpn.net/w1cdn/mwtchahrd.git synced 2025-10-19 16:04:10 -05:00

Make simple GET request from Spothole.

This commit is contained in:
mattbk
2025-10-18 10:43:56 -05:00
parent ab4f190138
commit 369de6f873
2 changed files with 13 additions and 0 deletions

View File

@ -8,6 +8,7 @@ authors = ["Chris, N6CTA <mail@n6cta.com>"]
anyhow = "1.0"
chrono = "0.4"
clap = { version = "4", features = ["derive"] }
reqwest = { version = "0.12.24", features = ["json", "blocking"] }
serde_json = "1.0.145"
socket2 = "0.5"

View File

@ -11,6 +11,7 @@ use std::time::{Duration, SystemTime, UNIX_EPOCH};
use std::net::UdpSocket;
use std::net::Ipv4Addr;
use serde_json::json;
use reqwest;
/// Validate that the provided port string can be parsed into a u16 and is nonzero.
fn validate_port(port: &str) -> Result<u16, String> {
@ -62,6 +63,11 @@ struct Cli {
/// Spotter callsign (e.g. W1CDN)
#[arg(short = 's', long)]
spotter: Option<String>,
/// Spot UI frames to Spothole
#[arg(short = 'o', long, default_value_t = false)]
spothole: bool,
}
/// Convert a byte slice into a hex-dump string for debugging purposes.
@ -399,6 +405,12 @@ fn handle_frame(frame: &AgwFrame, cli: &Cli, buffers: &mut BufferManager) {
if cli.ui_only && summary != "UI" {
return;
}
// 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:?}");
}
// Send UDP
if cli.uport != 55555 {