diff --git a/Pepperdash Core/Pepperdash Core/Comm/CommunicationStreamDebugging.cs b/Pepperdash Core/Pepperdash Core/Comm/CommunicationStreamDebugging.cs index f3b5613..b5b1c15 100644 --- a/Pepperdash Core/Pepperdash Core/Comm/CommunicationStreamDebugging.cs +++ b/Pepperdash Core/Pepperdash Core/Comm/CommunicationStreamDebugging.cs @@ -79,10 +79,7 @@ namespace PepperDash.Core _DebugTimeoutInMs = minutes * 60000; - if (DebugExpiryPeriod != null) - { - DisableDebugging(); - } + StopDebugTimer(); DebugExpiryPeriod = new CTimer((o) => DisableDebugging(), _DebugTimeoutInMs); @@ -101,14 +98,24 @@ namespace PepperDash.Core /// private void DisableDebugging() { - DebugExpiryPeriod.Stop(); - DebugExpiryPeriod.Dispose(); - DebugExpiryPeriod = null; + StopDebugTimer(); + Debug.SetDeviceDebugSettings(ParentDeviceKey, eStreamDebuggingSetting.Off); + } + + private void StopDebugTimer() + { RxStreamDebuggingIsEnabled = false; TxStreamDebuggingIsEnabled = false; - Debug.SetDeviceDebugSettings(ParentDeviceKey, eStreamDebuggingSetting.Off); + if (DebugExpiryPeriod == null) + { + return; + } + + DebugExpiryPeriod.Stop(); + DebugExpiryPeriod.Dispose(); + DebugExpiryPeriod = null; } } @@ -123,4 +130,4 @@ namespace PepperDash.Core Tx = 2, Both = Rx | Tx } -} \ No newline at end of file +} diff --git a/Pepperdash Core/Pepperdash Core/Logging/DebugMemory.cs b/Pepperdash Core/Pepperdash Core/Logging/DebugMemory.cs index 1b0fea1..5162853 100644 --- a/Pepperdash Core/Pepperdash Core/Logging/DebugMemory.cs +++ b/Pepperdash Core/Pepperdash Core/Logging/DebugMemory.cs @@ -68,11 +68,9 @@ namespace PepperDash.Core.DebugThings /// public void SetDebugSettingsForKey(string deviceKey, object settings) { - var existingSettings = DeviceDebugSettings[deviceKey]; - - if (existingSettings != null) + if(DeviceDebugSettings.ContainsKey(deviceKey)) { - existingSettings = settings; + DeviceDebugSettings[deviceKey] = settings; } else DeviceDebugSettings.Add(deviceKey, settings);