From 2558f44f9adada9fb15b5fd12bc043493c18ecb9 Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Tue, 7 May 2024 16:12:17 -0600 Subject: [PATCH 1/3] fix: Adds try/catch around pre/post activation calls and adds JsonProperty decorators to Key and Name properties in interfaces --- src/Pepperdash Core/CoreInterfaces.cs | 3 +++ src/Pepperdash Core/Device.cs | 21 +++++++++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/Pepperdash Core/CoreInterfaces.cs b/src/Pepperdash Core/CoreInterfaces.cs index c1432c2..6e0b639 100644 --- a/src/Pepperdash Core/CoreInterfaces.cs +++ b/src/Pepperdash Core/CoreInterfaces.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using Crestron.SimplSharp; +using Newtonsoft.Json; using Serilog; namespace PepperDash.Core @@ -15,6 +16,7 @@ namespace PepperDash.Core /// /// Unique Key /// + [JsonProperty("key")] string Key { get; } } @@ -26,6 +28,7 @@ namespace PepperDash.Core /// /// Isn't it obvious :) /// + [JsonProperty("name")] string Name { get; } } diff --git a/src/Pepperdash Core/Device.cs b/src/Pepperdash Core/Device.cs index 749713e..fda30c4 100644 --- a/src/Pepperdash Core/Device.cs +++ b/src/Pepperdash Core/Device.cs @@ -99,7 +99,15 @@ namespace PepperDash.Core public void PreActivate() { if (_PreActivationActions != null) - _PreActivationActions.ForEach(a => a.Invoke()); + _PreActivationActions.ForEach(a => { + try + { + a.Invoke(); + } catch (Exception e) + { + Debug.LogMessage(e, "Error in PreActivationAction: " + e.Message, this); + } + }); } /// @@ -123,7 +131,16 @@ namespace PepperDash.Core public void PostActivate() { if (_PostActivationActions != null) - _PostActivationActions.ForEach(a => a.Invoke()); + _PostActivationActions.ForEach(a => { + try + { + a.Invoke(); + } + catch (Exception e) + { + Debug.LogMessage(e, "Error in PostActivationAction: " + e.Message, this); + } + }); } /// From 3e9deba0b6573c0e48e20ad09eeebe5b2dafbde7 Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Tue, 7 May 2024 16:14:35 -0600 Subject: [PATCH 2/3] fix: Adds more JsonProperty decorators to comm interfaces --- src/Pepperdash Core/CommunicationExtras.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Pepperdash Core/CommunicationExtras.cs b/src/Pepperdash Core/CommunicationExtras.cs index e780efd..9db5420 100644 --- a/src/Pepperdash Core/CommunicationExtras.cs +++ b/src/Pepperdash Core/CommunicationExtras.cs @@ -5,6 +5,7 @@ using System.Text; using Crestron.SimplSharp; using Crestron.SimplSharp.CrestronSockets; using System.Text.RegularExpressions; +using Newtonsoft.Json; namespace PepperDash.Core { @@ -25,6 +26,7 @@ namespace PepperDash.Core /// /// Indicates connection status /// + [JsonProperty("isConnected")] bool IsConnected { get; } /// /// Connect to the device @@ -70,6 +72,7 @@ namespace PepperDash.Core /// /// Object to enable stream debugging /// + [JsonProperty("streamDebugging")] CommunicationStreamDebugging StreamDebugging { get; } } @@ -87,7 +90,9 @@ namespace PepperDash.Core /// /// The current socket status of the client /// - SocketStatus ClientStatus { get; } + [JsonProperty("clinetStatus")] + [JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] + SocketStatus ClientStatus { get; } } /// @@ -106,10 +111,12 @@ namespace PepperDash.Core /// /// Enable automatic recconnect /// + [JsonProperty("autoReconnect")] bool AutoReconnect { get; set; } /// /// Interval in ms to attempt automatic recconnections /// + [JsonProperty("autoReconnectIntervalMs")] int AutoReconnectIntervalMs { get; set; } } From 305722236f2a9d19b1288fd88b3d771da750ff83 Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Tue, 7 May 2024 16:16:51 -0600 Subject: [PATCH 3/3] fix: removes unnecessary lib folder from project --- src/Pepperdash Core/PepperDash_Core.csproj | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Pepperdash Core/PepperDash_Core.csproj b/src/Pepperdash Core/PepperDash_Core.csproj index 2da71dc..1d756f9 100644 --- a/src/Pepperdash Core/PepperDash_Core.csproj +++ b/src/Pepperdash Core/PepperDash_Core.csproj @@ -26,6 +26,14 @@ pdbonly bin\4Series\$(Configuration)\PepperDashCore.xml + + + + + + + +