mirror of
https://gitea.farpn.net/w1cdn/mwtchahrd.git
synced 2025-11-24 22:56:35 -06:00
Add simple filter for text strings in source call-SSID.
This commit is contained in:
62
src/main.rs
62
src/main.rs
@@ -83,13 +83,13 @@ struct Cli {
|
|||||||
#[arg(short = 'y', long, allow_negative_numbers = true)]
|
#[arg(short = 'y', long, allow_negative_numbers = true)]
|
||||||
my_lat: Option<f64>,
|
my_lat: Option<f64>,
|
||||||
|
|
||||||
/// Spotter longitude DD.dddd; to send negaitve (W or S), use = e.g. --my-lon=-97.1
|
/// Spotter longitude DD.dddd
|
||||||
#[arg(short = 'x', long, allow_negative_numbers = true)]
|
#[arg(short = 'x', long, allow_negative_numbers = true)]
|
||||||
my_lon: Option<f64>,
|
my_lon: Option<f64>,
|
||||||
|
|
||||||
/// Filter out spots from these callsign-UUID combinations (self spots, for example), comma-separated
|
/// Filter out spots from these callsign-UUID combinations (self spots, for example), comma-separated
|
||||||
#[arg(short = 't', long, value_delimiter = ',')]
|
#[arg(short = 't', long, value_delimiter = ',', num_args = 1..,)]
|
||||||
filter: Option<String>,
|
filter: Vec<String>,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -454,11 +454,6 @@ fn handle_frame(frame: &AgwFrame, cli: &Cli, buffers: &mut BufferManager, loc_st
|
|||||||
if cli.ui_only && summary != "UI" {
|
if cli.ui_only && summary != "UI" {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Ignore frames where source matches one of the filtered strings
|
|
||||||
TODO finish this
|
|
||||||
if cli.filter {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// In non-debug mode, print the session line and any additional lines.
|
// In non-debug mode, print the session line and any additional lines.
|
||||||
if !cli.debug {
|
if !cli.debug {
|
||||||
@@ -493,30 +488,33 @@ fn handle_frame(frame: &AgwFrame, cli: &Cli, buffers: &mut BufferManager, loc_st
|
|||||||
|
|
||||||
//println!("Stored location: {} {}", stored_loc[0].clone(), stored_loc[1].clone());
|
//println!("Stored location: {} {}", stored_loc[0].clone(), stored_loc[1].clone());
|
||||||
|
|
||||||
// If Spothole is enabled
|
// If Spothole is enabled and this is a UI frame and the source is not filtered
|
||||||
if summary == "UI" && cli.spothole {
|
if summary == "UI" && cli.spothole && !cli.filter.contains(&source){
|
||||||
// POST JSON
|
// POST JSON
|
||||||
let packet = json!({
|
let packet = json!({
|
||||||
"dx_call": &source_call,
|
"dx_call": &source_call,
|
||||||
"dx_ssid": &source_ssid,
|
"dx_ssid": &source_ssid,
|
||||||
"de_call": &my_call,
|
"de_call": &my_call,
|
||||||
"de_latitude": &my_lat,
|
"de_latitude": &my_lat,
|
||||||
"de_longitude": &my_lon,
|
"de_longitude": &my_lon,
|
||||||
"freq": &freq,
|
"freq": &freq,
|
||||||
"comment": &text,
|
"comment": &text,
|
||||||
"dx_latitude": &json_lat,
|
"dx_latitude": &json_lat,
|
||||||
"dx_longitude": &json_lon,
|
"dx_longitude": &json_lon,
|
||||||
"mode": "PKT",
|
"mode": "PKT",
|
||||||
"mode_type": "DATA",
|
"mode_type": "DATA",
|
||||||
"mode_source": "SPOT",
|
"mode_source": "SPOT",
|
||||||
"time": SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_secs(),
|
"time": SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_secs(),
|
||||||
});
|
});
|
||||||
let client = reqwest::blocking::Client::new();
|
let client = reqwest::blocking::Client::new();
|
||||||
let res = client.post(spothole_url)
|
let res = client.post(spothole_url)
|
||||||
.json(&packet)
|
.json(&packet)
|
||||||
.send();
|
.send();
|
||||||
println!("sent to {} = {}", spothole_url, packet);
|
println!("sent to {} = {}", spothole_url, packet);
|
||||||
println!("res = {res:?}");
|
println!("res = {res:?}");
|
||||||
|
// If it's filtered, send a note about that
|
||||||
|
} else if summary == "UI" && cli.spothole && cli.filter.contains(&source) {
|
||||||
|
println!("Filter {:?} applied, not spotted", cli.filter)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send UDP
|
// Send UDP
|
||||||
|
|||||||
Reference in New Issue
Block a user