Mirror a radio from another computer's broadcast data
Listen for Radio broadcast data from another Nonemm or N1MM computer and record its frequency, mode and split as this computer's own radio. No radio is controlled. The settings are in the Configure Radios dialog. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -118,6 +118,48 @@ public static class BroadcastMessages
|
||||
new XElement("AuxAntSelectedName", ""),
|
||||
new XElement("IsConnected", Flag(radio.IsConnected))).ToString();
|
||||
|
||||
/// Null for anything that is not a `RadioInfo` message with a frequency, so
|
||||
/// the other data on the same port is passed over.
|
||||
public static RadioBroadcast? ReadRadio(string xml)
|
||||
{
|
||||
XElement root;
|
||||
try
|
||||
{
|
||||
root = XElement.Parse(xml);
|
||||
}
|
||||
catch (System.Xml.XmlException)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (root.Name.LocalName != "RadioInfo"
|
||||
|| !long.TryParse(root.Element("Freq")?.Value, CultureInfo.InvariantCulture, out long frequency)
|
||||
|| !long.TryParse(root.Element("TXFreq")?.Value, CultureInfo.InvariantCulture, out long transmit)
|
||||
|| !int.TryParse(root.Element("RadioNr")?.Value, CultureInfo.InvariantCulture, out int number))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
string Text(string name) => root.Element(name)?.Value ?? "";
|
||||
bool Yes(string name) => bool.TryParse(Text(name), out bool value) && value;
|
||||
int.TryParse(Text("FocusRadioNr"), CultureInfo.InvariantCulture, out int focus);
|
||||
int.TryParse(Text("ActiveRadioNr"), CultureInfo.InvariantCulture, out int active);
|
||||
return new RadioBroadcast(
|
||||
Text("StationName"),
|
||||
new RadioReport(
|
||||
number,
|
||||
frequency * FrequencyUnit,
|
||||
transmit * FrequencyUnit,
|
||||
Text("Mode"),
|
||||
Text("mycall"),
|
||||
Text("OpCall"),
|
||||
Yes("IsRunning"),
|
||||
focus,
|
||||
Yes("IsSplit"),
|
||||
active,
|
||||
Yes("IsTransmitting"),
|
||||
Text("RadioName"),
|
||||
Yes("IsConnected")));
|
||||
}
|
||||
|
||||
/// `action` is `add` or `delete`. N1MM leaves the comment and status off a
|
||||
/// delete.
|
||||
public static string Spot(SpotReport spot, string action, string stationName)
|
||||
|
||||
Reference in New Issue
Block a user