mirror of
https://gitea.farpn.net/w1cdn/mwtchahrd.git
synced 2025-10-19 16:04:10 -05:00
Spot packets to spothole.app if desired.
This commit is contained in:
30
src/main.rs
30
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"
|
||||
});
|
||||
|
Reference in New Issue
Block a user