mirror of
https://gitea.farpn.net/w1cdn/mwtchahrd.git
synced 2025-10-20 00:14:09 -05:00
Make simple GET request from Spothole.
This commit is contained in:
@ -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"
|
||||
|
||||
|
12
src/main.rs
12
src/main.rs
@ -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.
|
||||
@ -400,6 +406,12 @@ fn handle_frame(frame: &AgwFrame, cli: &Cli, buffers: &mut BufferManager) {
|
||||
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 {
|
||||
let uaddr = format!("{}:{}", cli.uip, cli.uport);
|
||||
|
Reference in New Issue
Block a user