[fix](trx-reporting): split beacon_symbol into table and code fields
Replace the two-character beacon_symbol string with separate beacon_symbol_table (char) and beacon_symbol_code (char) fields to avoid TOML backslash escaping issues with the alternate symbol table. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Stan Grams <sjg@haxx.space>
This commit is contained in:
@@ -86,9 +86,7 @@ fn format_aprs_lon(lon: f64) -> String {
|
||||
/// Uses APRS uncompressed position format (`!`) with path `TCPIP*`.
|
||||
/// The two-character `symbol` string sets the symbol-table and symbol-code
|
||||
/// (e.g. `/-` = house, `/&` = diamond/gateway).
|
||||
fn format_beacon(callsign: &str, lat: f64, lon: f64, symbol: &str) -> String {
|
||||
let sym_table = symbol.chars().next().unwrap_or('/');
|
||||
let sym_code = symbol.chars().nth(1).unwrap_or('-');
|
||||
fn format_beacon(callsign: &str, lat: f64, lon: f64, sym_table: char, sym_code: char) -> String {
|
||||
format!(
|
||||
"{}>APRS,TCPIP*:!{}{}{}{}\r\n",
|
||||
callsign,
|
||||
@@ -126,7 +124,7 @@ pub async fn run_aprsfi_uplink(
|
||||
// Pre-build the beacon packet (None if beaconing disabled or no coords).
|
||||
let beacon_packet: Option<String> = if cfg.beacon {
|
||||
match coords {
|
||||
Some((lat, lon)) => Some(format_beacon(&callsign, lat, lon, &cfg.beacon_symbol)),
|
||||
Some((lat, lon)) => Some(format_beacon(&callsign, lat, lon, cfg.beacon_symbol_table, cfg.beacon_symbol_code)),
|
||||
None => {
|
||||
warn!(
|
||||
"APRS-IS IGate: beacon enabled but no coordinates available \
|
||||
@@ -443,13 +441,13 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn beacon_format_house_symbol() {
|
||||
let s = format_beacon("SP2SJG-10", 52.2297, 21.0122, "/-");
|
||||
let s = format_beacon("SP2SJG-10", 52.2297, 21.0122, '/', '-');
|
||||
assert_eq!(s, "SP2SJG-10>APRS,TCPIP*:!5213.78N/02100.73E-\r\n");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn beacon_format_southern_western() {
|
||||
let s = format_beacon("VK2ABC-10", -33.8688, 151.2093, "/-");
|
||||
let s = format_beacon("VK2ABC-10", -33.8688, 151.2093, '/', '-');
|
||||
assert!(s.contains('S'));
|
||||
assert!(s.contains('E'));
|
||||
}
|
||||
|
||||
@@ -54,9 +54,10 @@ pub struct AprsFiConfig {
|
||||
pub beacon: bool,
|
||||
/// How often to send a position beacon, in seconds. Default: 1200 (20 min).
|
||||
pub beacon_interval_secs: u64,
|
||||
/// APRS symbol as a two-character string: symbol-table + symbol-code.
|
||||
/// E.g. "/&" = diamond (gateway), "/-" = house. Default: "/-".
|
||||
pub beacon_symbol: String,
|
||||
/// APRS symbol table identifier: "/" = primary, "\\" = alternate.
|
||||
pub beacon_symbol_table: char,
|
||||
/// APRS symbol code. E.g. '-' = house, '&' = diamond/gateway, 'I' = IGate.
|
||||
pub beacon_symbol_code: char,
|
||||
/// Beacon latitude override (decimal degrees). Falls back to [general].latitude.
|
||||
pub latitude: Option<f64>,
|
||||
/// Beacon longitude override (decimal degrees). Falls back to [general].longitude.
|
||||
@@ -73,7 +74,8 @@ impl Default for AprsFiConfig {
|
||||
callsign: None,
|
||||
beacon: false,
|
||||
beacon_interval_secs: 1200,
|
||||
beacon_symbol: "/-".to_string(),
|
||||
beacon_symbol_table: '/',
|
||||
beacon_symbol_code: '-',
|
||||
latitude: None,
|
||||
longitude: None,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user