From f7317832a171568d1e6d9001885549045373ba04 Mon Sep 17 00:00:00 2001 From: Jason Alborough Date: Fri, 7 Oct 2022 11:11:23 -0400 Subject: [PATCH 1/5] fix: adds ssh dispose for the client --- Pepperdash Core/Pepperdash Core/Comm/GenericSshClient.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Pepperdash Core/Pepperdash Core/Comm/GenericSshClient.cs b/Pepperdash Core/Pepperdash Core/Comm/GenericSshClient.cs index 2990ae0..ae38011 100644 --- a/Pepperdash Core/Pepperdash Core/Comm/GenericSshClient.cs +++ b/Pepperdash Core/Pepperdash Core/Comm/GenericSshClient.cs @@ -290,6 +290,7 @@ namespace PepperDash.Core /// public void Disconnect() { + Debug.Console(2, "Disconnect Called"); ConnectEnabled = false; // Stop trying reconnects, if we are if (ReconnectTimer != null) @@ -307,11 +308,13 @@ namespace PepperDash.Core private void KillClient(SocketStatus status) { KillStream(); - + IsConnecting = false; if (Client != null) { - IsConnecting = false; + Client.ErrorOccurred -= Client_ErrorOccurred; Client.Disconnect(); + Client.Dispose(); + Client = null; ClientStatus = status; Debug.Console(1, this, "Disconnected"); From 4890b167ab8c551d1014f1c653fe3e20f7f0773a Mon Sep 17 00:00:00 2001 From: Andrew Welker Date: Fri, 4 Nov 2022 09:13:19 -0600 Subject: [PATCH 2/5] fix: update path to debug settings file The path wasn't taking into account running on VC-4, which was causing exceptions when Essentials was running on VC-4 --- Pepperdash Core/Pepperdash Core/Logging/Debug.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Pepperdash Core/Pepperdash Core/Logging/Debug.cs b/Pepperdash Core/Pepperdash Core/Logging/Debug.cs index fdb3cb4..334b4db 100644 --- a/Pepperdash Core/Pepperdash Core/Logging/Debug.cs +++ b/Pepperdash Core/Pepperdash Core/Logging/Debug.cs @@ -519,8 +519,13 @@ namespace PepperDash.Core /// static string GetMemoryFileName() { - CheckForMigration(); - return string.Format(@"\user\debugSettings\program{0}", InitialParametersClass.ApplicationNumber); + if (CrestronEnvironment.DevicePlatform == eDevicePlatform.Appliance) + { + CheckForMigration(); + return string.Format(@"\user\debugSettings\program{0}", InitialParametersClass.ApplicationNumber); + } + + return string.Format("", InitialParametersClass.RoomId); } private static void CheckForMigration() From 1e2fa36390b047f7c7f274082a42f284e6cf800a Mon Sep 17 00:00:00 2001 From: Andrew Welker Date: Fri, 4 Nov 2022 13:34:36 -0600 Subject: [PATCH 3/5] feat: update string formats to differ between appliance and server On VC-4, ALL statements have to go to the Error Log. With this change, all messages will go to the Error log at the Notice level on VC-4 only with the Essentials appdebug level added to the message. This should aid in filtering out messages from the error log --- .../Pepperdash Core/Logging/Debug.cs | 31 ++++++++++++++----- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/Pepperdash Core/Pepperdash Core/Logging/Debug.cs b/Pepperdash Core/Pepperdash Core/Logging/Debug.cs index 334b4db..8904928 100644 --- a/Pepperdash Core/Pepperdash Core/Logging/Debug.cs +++ b/Pepperdash Core/Pepperdash Core/Logging/Debug.cs @@ -367,9 +367,21 @@ namespace PepperDash.Core /// Object parameters public static void Console(uint level, string format, params object[] items) { - if (Level >= level) - CrestronConsole.PrintLine("[{0}]App {1}:{2}", DateTime.Now.ToString("HH:mm:ss.fff"), InitialParametersClass.ApplicationNumber, - string.Format(format, items)); + if (CrestronEnvironment.DevicePlatform == eDevicePlatform.Server) + { + var logString = string.Format("[level {0}] {1}", level, string.Format(format, items)); + + LogError(ErrorLogLevel.Notice, logString); + return; + } + + if(Level < level) + { + return; + } + + CrestronConsole.PrintLine("[{0}]App {1}:{2}", DateTime.Now.ToString("HH:mm:ss.fff"), InitialParametersClass.ApplicationNumber, + string.Format(format, items)); } /// @@ -442,7 +454,8 @@ namespace PepperDash.Core /// public static void LogError(ErrorLogLevel errorLogLevel, string str) { - var msg = string.Format("App {0}:{1}", InitialParametersClass.ApplicationNumber, str); + + var msg = CrestronEnvironment.DevicePlatform == eDevicePlatform.Appliance ? string.Format("App {0}:{1}", InitialParametersClass.ApplicationNumber, str) : string.Format("Room {0}:{1}", InitialParametersClass.RoomId, str); switch (errorLogLevel) { case ErrorLogLevel.Error: @@ -482,7 +495,11 @@ namespace PepperDash.Core //if (!Directory.Exists(dir)) // Directory.Create(dir); - using (var sw = new StreamWriter(GetMemoryFileName())) + var fileName = GetMemoryFileName(); + + Console(0, ErrorLogLevel.Notice, "Loading debug settings file from {0}", fileName); + + using (var sw = new StreamWriter(fileName)) { var json = JsonConvert.SerializeObject(_contexts); sw.Write(json); @@ -525,7 +542,7 @@ namespace PepperDash.Core return string.Format(@"\user\debugSettings\program{0}", InitialParametersClass.ApplicationNumber); } - return string.Format("", InitialParametersClass.RoomId); + return string.Format("{0}{1}user{1}debugSettings{1}{2}.json",Directory.GetApplicationRootDirectory(), Path.DirectorySeparatorChar, InitialParametersClass.RoomId); } private static void CheckForMigration() @@ -538,7 +555,7 @@ namespace PepperDash.Core { Console(0, ErrorLogLevel.Notice, String.Format( - @"Debug settings file not found at \nvram\debugSettings\program{0}. Attempting to use file at \user\debugSettings\program{0}", + @"Debug settings file migration not necessary. Using file at \user\debugSettings\program{0}", InitialParametersClass.ApplicationNumber)); return; } From 5c88d22f7fc1aff1410d4d7436d1590bfe69b07d Mon Sep 17 00:00:00 2001 From: Andrew Welker Date: Mon, 7 Nov 2022 16:52:52 -0700 Subject: [PATCH 4/5] feat: add `roomId` property to Control Properties Config --- .../Pepperdash Core/Comm/ControlPropertiesConfig.cs | 5 +++++ Pepperdash Core/Pepperdash Core/Logging/Debug.cs | 11 ++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Pepperdash Core/Pepperdash Core/Comm/ControlPropertiesConfig.cs b/Pepperdash Core/Pepperdash Core/Comm/ControlPropertiesConfig.cs index 651dacd..47e0ec8 100644 --- a/Pepperdash Core/Pepperdash Core/Comm/ControlPropertiesConfig.cs +++ b/Pepperdash Core/Pepperdash Core/Comm/ControlPropertiesConfig.cs @@ -70,6 +70,11 @@ namespace PepperDash.Core /// public string DeviceReadyResponsePattern { get; set; } + /// + /// Used when communcating to programs running in VC-4 + /// + public string RoomId { get; set; } + /// /// Constructor /// diff --git a/Pepperdash Core/Pepperdash Core/Logging/Debug.cs b/Pepperdash Core/Pepperdash Core/Logging/Debug.cs index 8904928..ee51b2c 100644 --- a/Pepperdash Core/Pepperdash Core/Logging/Debug.cs +++ b/Pepperdash Core/Pepperdash Core/Logging/Debug.cs @@ -69,7 +69,16 @@ namespace PepperDash.Core // Get the assembly version and print it to console and the log GetVersion(); - var msg = string.Format("[App {0}] Using PepperDash_Core v{1}", InitialParametersClass.ApplicationNumber, PepperDashCoreVersion); + string msg = ""; + + if (CrestronEnvironment.DevicePlatform == eDevicePlatform.Appliance) + { + msg = string.Format("[App {0}] Using PepperDash_Core v{1}", InitialParametersClass.ApplicationNumber, PepperDashCoreVersion); + } + else if (CrestronEnvironment.DevicePlatform == eDevicePlatform.Server) + { + msg = string.Format("[Room {0}] Using PepperDash_Core v{1}", InitialParametersClass.RoomId, PepperDashCoreVersion); + } CrestronConsole.PrintLine(msg); From 2a93f3bdb403bad5d10154a073eb0180af9874b2 Mon Sep 17 00:00:00 2001 From: Andrew Welker Date: Thu, 19 Jan 2023 11:47:52 -0700 Subject: [PATCH 5/5] fix: remove leftover merge issue --- Pepperdash Core/Pepperdash Core/Comm/GenericSshClient.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Pepperdash Core/Pepperdash Core/Comm/GenericSshClient.cs b/Pepperdash Core/Pepperdash Core/Comm/GenericSshClient.cs index 4ac42fa..88f9682 100644 --- a/Pepperdash Core/Pepperdash Core/Comm/GenericSshClient.cs +++ b/Pepperdash Core/Pepperdash Core/Comm/GenericSshClient.cs @@ -331,7 +331,7 @@ namespace PepperDash.Core private void KillClient(SocketStatus status) { KillStream(); - IsConnecting = false; + if (Client != null) { try