add per channel block call history (not user accessible, yet); add support to ignore traffic Tx'ed from ourselves;

pull/12/head
Bryan Biedenkapp 9 months ago
parent 2973a60db5
commit d9b635324b

@ -101,7 +101,8 @@ namespace dvmconsole
/// </summary> /// </summary>
public partial class CallHistoryWindow : Window public partial class CallHistoryWindow : Window
{ {
private const int MAX_CALL_HISTORY = 200; public const int MAX_CALL_HISTORY = 200;
private int maxCallHistory = MAX_CALL_HISTORY;
private SettingsManager settingsManager; private SettingsManager settingsManager;
/* /*
@ -120,10 +121,20 @@ namespace dvmconsole
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="CallHistoryWindow"/> class. /// Initializes a new instance of the <see cref="CallHistoryWindow"/> class.
/// </summary> /// </summary>
public CallHistoryWindow(SettingsManager settingsManager) /// <param name="settingsManager"></param>
/// <param name="maxCallHistory"></param>
public CallHistoryWindow(SettingsManager settingsManager, int maxCallHistory)
{ {
InitializeComponent(); InitializeComponent();
this.settingsManager = settingsManager; this.settingsManager = settingsManager;
this.maxCallHistory = maxCallHistory;
// clamp max call history count
if (this.maxCallHistory > MAX_CALL_HISTORY)
this.maxCallHistory = MAX_CALL_HISTORY;
if (this.maxCallHistory < 5)
this.maxCallHistory = 5;
ViewModel = new CallHistoryViewModel(); ViewModel = new CallHistoryViewModel();
DataContext = ViewModel; DataContext = ViewModel;
} }
@ -148,8 +159,8 @@ namespace dvmconsole
{ {
Dispatcher.Invoke(() => Dispatcher.Invoke(() =>
{ {
if (ViewModel.CallHistory.Count == MAX_CALL_HISTORY) if (ViewModel.CallHistory.Count == maxCallHistory)
ViewModel.CallHistory.RemoveAt(MAX_CALL_HISTORY - 1); ViewModel.CallHistory.RemoveAt(maxCallHistory - 1);
ViewModel.CallHistory.Insert(0, new CallEntry ViewModel.CallHistory.Insert(0, new CallEntry
{ {

@ -32,6 +32,8 @@ namespace dvmconsole.Controls
/// </summary> /// </summary>
public partial class ChannelBox : UserControl, INotifyPropertyChanged public partial class ChannelBox : UserControl, INotifyPropertyChanged
{ {
public const int MAX_CALL_HISTORY = 10;
public readonly static Border BORDER_DEFAULT; public readonly static Border BORDER_DEFAULT;
public readonly static Border BORDER_GREEN; public readonly static Border BORDER_GREEN;
@ -91,6 +93,8 @@ namespace dvmconsole.Controls
private bool isPrimary = false; private bool isPrimary = false;
private CallHistoryWindow callHistoryWindow;
/* /*
** Properties ** Properties
*/ */
@ -422,6 +426,8 @@ namespace dvmconsole.Controls
flashingBackgroundManager = new FlashingBackgroundManager(this); flashingBackgroundManager = new FlashingBackgroundManager(this);
callHistoryWindow = new CallHistoryWindow(SettingsManager.Instance, MAX_CALL_HISTORY);
ChannelName = channelName; ChannelName = channelName;
ChannelMode = "P25"; ChannelMode = "P25";
DstId = dstId; DstId = dstId;
@ -589,6 +595,17 @@ namespace dvmconsole.Controls
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
} }
/// <summary>
///
/// </summary>
/// <param name="channel"></param>
/// <param name="srcId"></param>
/// <param name="dstId"></param>
public void AddCall(string channel, int srcId, int dstId, string timestamp)
{
callHistoryWindow.AddCall(channel, srcId, dstId, timestamp);
}
/** WPF Events */ /** WPF Events */
/// <summary> /// <summary>

@ -270,6 +270,19 @@ namespace dvmconsole
continue; continue;
} }
// is the Rx stream ID any of our Tx stream IDs?
List<bool> txChannels = new List<bool>();
foreach (ChannelBox other in selectedChannelsManager.GetSelectedChannels())
if (other.TxStreamId > 0 && other.TxStreamId == channel.RxStreamId)
txChannels.Add(true);
// if we have a count of Tx channels this means we're sourcing traffic for the incoming stream ID
if (txChannels.Count() > 0)
{
Log.WriteLine($"({system.Name}) DMRD: Traffic *IGNORE TX TRAF * PEER {e.PeerId} CALL_START PEER ID {channel.PeerId} SRC_ID {e.SrcId} TGID {e.DstId} ALGID {channel.algId} KID {channel.kId} [STREAM ID {e.StreamId}]");
continue;
}
// is this a new call stream? // is this a new call stream?
if (e.StreamId != systemStatuses[cpgChannel.Name + e.Slot].RxStreamId) if (e.StreamId != systemStatuses[cpgChannel.Name + e.Slot].RxStreamId)
{ {
@ -297,6 +310,7 @@ namespace dvmconsole
Log.WriteLine($"({system.Name}) TS {e.Slot + 1} [STREAM ID {e.StreamId}] RX_LC {FneUtils.HexDump(systemStatuses[cpgChannel.Name + e.Slot].DMR_RxLC.GetBytes())}"); Log.WriteLine($"({system.Name}) TS {e.Slot + 1} [STREAM ID {e.StreamId}] RX_LC {FneUtils.HexDump(systemStatuses[cpgChannel.Name + e.Slot].DMR_RxLC.GetBytes())}");
callHistoryWindow.AddCall(cpgChannel.Name, (int)e.SrcId, (int)e.DstId, DateTime.Now.ToString()); callHistoryWindow.AddCall(cpgChannel.Name, (int)e.SrcId, (int)e.DstId, DateTime.Now.ToString());
channel.AddCall(cpgChannel.Name, (int)e.SrcId, (int)e.DstId, DateTime.Now.ToString());
callHistoryWindow.ChannelKeyed(cpgChannel.Name, (int)e.SrcId, false); // TODO: Encrypted state callHistoryWindow.ChannelKeyed(cpgChannel.Name, (int)e.SrcId, false); // TODO: Encrypted state
channel.Background = ChannelBox.GREEN_GRADIENT; channel.Background = ChannelBox.GREEN_GRADIENT;

@ -486,6 +486,19 @@ namespace dvmconsole
continue; continue;
} }
// is the Rx stream ID any of our Tx stream IDs?
List<bool> txChannels = new List<bool>();
foreach (ChannelBox other in selectedChannelsManager.GetSelectedChannels())
if (other.TxStreamId > 0 && other.TxStreamId == channel.RxStreamId)
txChannels.Add(true);
// if we have a count of Tx channels this means we're sourcing traffic for the incoming stream ID
if (txChannels.Count() > 0)
{
Log.WriteLine($"({system.Name}) P25D: Traffic *IGNORE TX TRAF * PEER {e.PeerId} CALL_START PEER ID {channel.PeerId} SRC_ID {e.SrcId} TGID {e.DstId} ALGID {channel.algId} KID {channel.kId} [STREAM ID {e.StreamId}]");
continue;
}
// is this a new call stream? // is this a new call stream?
if (e.StreamId != slot.RxStreamId && ((e.DUID != P25DUID.TDU) && (e.DUID != P25DUID.TDULC))) if (e.StreamId != slot.RxStreamId && ((e.DUID != P25DUID.TDU) && (e.DUID != P25DUID.TDULC)))
{ {
@ -503,6 +516,7 @@ namespace dvmconsole
channel.algId = P25Defines.P25_ALGO_UNENCRYPT; channel.algId = P25Defines.P25_ALGO_UNENCRYPT;
callHistoryWindow.AddCall(cpgChannel.Name, (int)e.SrcId, (int)e.DstId, DateTime.Now.ToString()); callHistoryWindow.AddCall(cpgChannel.Name, (int)e.SrcId, (int)e.DstId, DateTime.Now.ToString());
channel.AddCall(cpgChannel.Name, (int)e.SrcId, (int)e.DstId, DateTime.Now.ToString());
callHistoryWindow.ChannelKeyed(cpgChannel.Name, (int)e.SrcId, encrypted); callHistoryWindow.ChannelKeyed(cpgChannel.Name, (int)e.SrcId, encrypted);
if (channel.algId != P25Defines.P25_ALGO_UNENCRYPT) if (channel.algId != P25Defines.P25_ALGO_UNENCRYPT)

@ -111,7 +111,7 @@ namespace dvmconsole
private ChannelBox playbackChannelBox; private ChannelBox playbackChannelBox;
CallHistoryWindow callHistoryWindow; private CallHistoryWindow callHistoryWindow;
public static string PLAYBACKTG = "LOCPLAYBACK"; public static string PLAYBACKTG = "LOCPLAYBACK";
public static string PLAYBACKSYS = "Local Playback"; public static string PLAYBACKSYS = "Local Playback";
@ -158,7 +158,7 @@ namespace dvmconsole
settingsManager.LoadSettings(); settingsManager.LoadSettings();
InitializeKeyboardShortcuts(); InitializeKeyboardShortcuts();
callHistoryWindow = new CallHistoryWindow(settingsManager); callHistoryWindow = new CallHistoryWindow(settingsManager, CallHistoryWindow.MAX_CALL_HISTORY);
selectedChannelsManager = new SelectedChannelsManager(); selectedChannelsManager = new SelectedChannelsManager();
flashingManager = new FlashingBackgroundManager(null, channelsCanvas, null, this); flashingManager = new FlashingBackgroundManager(null, channelsCanvas, null, this);
@ -2427,6 +2427,8 @@ namespace dvmconsole
} }
} }
/** Keyboard Shortcuts */
/// <summary> /// <summary>
/// Sets the global PTT keybind /// Sets the global PTT keybind
/// Hooks a listener to listen for a keypress, then saves that as the global PTT keybind /// Hooks a listener to listen for a keypress, then saves that as the global PTT keybind
@ -2471,8 +2473,6 @@ namespace dvmconsole
settingsManager.SaveSettings(); settingsManager.SaveSettings();
MessageBox.Show("Global PTT shortcut set to " + keyPress.ToString(), "Success", MessageBoxButton.OK, MessageBoxImage.Information); MessageBox.Show("Global PTT shortcut set to " + keyPress.ToString(), "Success", MessageBoxButton.OK, MessageBoxImage.Information);
} }
/// <summary> /// <summary>
/// Initializes global keyboard shortcut listener /// Initializes global keyboard shortcut listener
@ -2487,6 +2487,11 @@ namespace dvmconsole
keyboardManager.OnKeyEvent += KeyboardManagerOnKeyEvent; keyboardManager.OnKeyEvent += KeyboardManagerOnKeyEvent;
} }
/// <summary>
///
/// </summary>
/// <param name="pressedKey"></param>
/// <param name="state"></param>
private void KeyboardManagerOnKeyEvent(Keys pressedKey,GlobalKeyboardHook.KeyboardState state) private void KeyboardManagerOnKeyEvent(Keys pressedKey,GlobalKeyboardHook.KeyboardState state)
{ {
if (pressedKey == settingsManager.GlobalPTTShortcut) if (pressedKey == settingsManager.GlobalPTTShortcut)
@ -2504,6 +2509,11 @@ namespace dvmconsole
} }
} }
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ToggleGlobalPTTAllChannels_Click(object sender, RoutedEventArgs e) private void ToggleGlobalPTTAllChannels_Click(object sender, RoutedEventArgs e)
{ {
settingsManager.GlobalPTTKeysAllChannels = !settingsManager.GlobalPTTKeysAllChannels; settingsManager.GlobalPTTKeysAllChannels = !settingsManager.GlobalPTTKeysAllChannels;

@ -37,10 +37,17 @@ namespace dvmconsole
private static string SettingsFilePath = UserAppDataPath + Path.DirectorySeparatorChar + "UserSettings.json"; private static string SettingsFilePath = UserAppDataPath + Path.DirectorySeparatorChar + "UserSettings.json";
private static SettingsManager _instance = null;
/* /*
** Properties ** Properties
*/ */
/// <summary>
/// Singleton instance.
/// </summary>
public static SettingsManager Instance { get { return _instance; } }
/// <summary> /// <summary>
/// Flag indicating whether or not system status widgets will be displayed. /// Flag indicating whether or not system status widgets will be displayed.
/// </summary> /// </summary>
@ -137,17 +144,29 @@ namespace dvmconsole
/// </summary> /// </summary>
public bool SaveTraceLog { get; set; } public bool SaveTraceLog { get; set; }
/// <summary>
///
/// </summary>
public Keys GlobalPTTShortcut { get; set; } = Keys.None; public Keys GlobalPTTShortcut { get; set; } = Keys.None;
/// <summary>
///
/// </summary>
public bool GlobalPTTKeysAllChannels { get; set; } public bool GlobalPTTKeysAllChannels { get; set; }
/* /*
** Methods ** Methods
*/ */
/// <summary> /// <summary>
/// /// Initializes a new instance of the <see cref="SettingsManager"/> class.
/// </summary>
public SettingsManager()
{
_instance = this;
}
/// <summary>
/// Load user settings.
/// </summary> /// </summary>
public bool LoadSettings() public bool LoadSettings()
{ {
@ -244,7 +263,7 @@ namespace dvmconsole
} }
/// <summary> /// <summary>
/// /// Save user settings.
/// </summary> /// </summary>
public void SaveSettings() public void SaveSettings()
{ {
@ -264,7 +283,7 @@ namespace dvmconsole
} }
/// <summary> /// <summary>
/// /// Reset user settings.
/// </summary> /// </summary>
public void Reset() public void Reset()
{ {

Loading…
Cancel
Save

Powered by TurnKey Linux.