From 200586b360fbc7f8509585ff667fa673f27fd9ec Mon Sep 17 00:00:00 2001 From: Andrew Welker Date: Thu, 23 May 2024 09:03:57 -0500 Subject: [PATCH 01/11] build(force-patch): Essentials 2.0.0-alpha-2508 --- .../epi-essentials-mobile-control.csproj | 2 +- .../Messengers/IHasCurrentSourceInfoMessenger.cs | 6 +----- .../mobile-control-messengers.csproj | 2 +- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/4-series/epi-essentials-mobile-control/epi-essentials-mobile-control.csproj b/4-series/epi-essentials-mobile-control/epi-essentials-mobile-control.csproj index 706a239..869a5b1 100644 --- a/4-series/epi-essentials-mobile-control/epi-essentials-mobile-control.csproj +++ b/4-series/epi-essentials-mobile-control/epi-essentials-mobile-control.csproj @@ -28,7 +28,7 @@ TRACE;SERIES4 - + diff --git a/4-series/mobile-control-messengers/Messengers/IHasCurrentSourceInfoMessenger.cs b/4-series/mobile-control-messengers/Messengers/IHasCurrentSourceInfoMessenger.cs index 40a80a7..65bc67b 100644 --- a/4-series/mobile-control-messengers/Messengers/IHasCurrentSourceInfoMessenger.cs +++ b/4-series/mobile-control-messengers/Messengers/IHasCurrentSourceInfoMessenger.cs @@ -2,11 +2,7 @@ using Newtonsoft.Json.Linq; using PepperDash.Core; using PepperDash.Essentials.Core; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using PepperDash.Essentials.Core.Routing; namespace PepperDash.Essentials.AppServer.Messengers { diff --git a/4-series/mobile-control-messengers/mobile-control-messengers.csproj b/4-series/mobile-control-messengers/mobile-control-messengers.csproj index 7d2954c..874ecf0 100644 --- a/4-series/mobile-control-messengers/mobile-control-messengers.csproj +++ b/4-series/mobile-control-messengers/mobile-control-messengers.csproj @@ -62,6 +62,6 @@ - + \ No newline at end of file From 4d91c4438773b2bd4b858f11aa168d90e683f3e5 Mon Sep 17 00:00:00 2001 From: Andrew Welker Date: Thu, 23 May 2024 09:11:00 -0500 Subject: [PATCH 02/11] fix: update namespace --- 3-series/RoomBridges/MobileControlEssentialsRoomBridge.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/3-series/RoomBridges/MobileControlEssentialsRoomBridge.cs b/3-series/RoomBridges/MobileControlEssentialsRoomBridge.cs index 5bdb192..cdc979c 100644 --- a/3-series/RoomBridges/MobileControlEssentialsRoomBridge.cs +++ b/3-series/RoomBridges/MobileControlEssentialsRoomBridge.cs @@ -25,6 +25,8 @@ using PepperDash.Essentials.Core.Lighting; using PepperDash.Essentials.Core.Shades; using PepperDash.Core.Logging; +using PepperDash.Essentials.Core.Routing; + #if SERIES4 From dd0cf9623a787c25566ec82a583932a0ef38f6ae Mon Sep 17 00:00:00 2001 From: Andrew Welker Date: Thu, 23 May 2024 12:56:07 -0500 Subject: [PATCH 03/11] build(force-patch): Essentials 2.0.0-alpha-2509 --- .../epi-essentials-mobile-control.csproj | 4 ++-- .../mobile-control-messengers.csproj | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/4-series/epi-essentials-mobile-control/epi-essentials-mobile-control.csproj b/4-series/epi-essentials-mobile-control/epi-essentials-mobile-control.csproj index 869a5b1..0c56284 100644 --- a/4-series/epi-essentials-mobile-control/epi-essentials-mobile-control.csproj +++ b/4-series/epi-essentials-mobile-control/epi-essentials-mobile-control.csproj @@ -13,7 +13,7 @@ Copyright 2020 4.0.0-local true - $(Version) + $(Version) bin\$(Configuration)\ PepperDash Technologies PepperDash.Essentials.4Series.Plugin.MobileControl @@ -28,7 +28,7 @@ TRACE;SERIES4 - + diff --git a/4-series/mobile-control-messengers/mobile-control-messengers.csproj b/4-series/mobile-control-messengers/mobile-control-messengers.csproj index 874ecf0..d26c93a 100644 --- a/4-series/mobile-control-messengers/mobile-control-messengers.csproj +++ b/4-series/mobile-control-messengers/mobile-control-messengers.csproj @@ -62,6 +62,6 @@ - + \ No newline at end of file From 7c1f41bf6c99a6bf7b6949c7b0d7d81110d95c2d Mon Sep 17 00:00:00 2001 From: Andrew Welker Date: Fri, 24 May 2024 16:26:31 -0500 Subject: [PATCH 04/11] chore: move console messages around for action handling --- 3-series/Messengers/MessengerBase.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/3-series/Messengers/MessengerBase.cs b/3-series/Messengers/MessengerBase.cs index 75206e3..920c5a5 100644 --- a/3-series/Messengers/MessengerBase.cs +++ b/3-series/Messengers/MessengerBase.cs @@ -94,11 +94,12 @@ private void HandleMessage(string path, string id, JToken content) // replace base path with empty string. Should leave something like /fullStatus var route = path.Replace(MessagePath, string.Empty); - if(!_actions.TryGetValue(route, out var action)) { - Debug.Console(1, this, $"No action found for path {path}"); + if(!_actions.TryGetValue(route, out var action)) { return; } + Debug.LogMessage(Serilog.Events.LogEventLevel.Debug, "Executing action for path {path}", this, path); + action(id, content); } From 905d759d92ace907bf49517732861d7c5299c47c Mon Sep 17 00:00:00 2001 From: Andrew Welker Date: Fri, 24 May 2024 16:28:44 -0500 Subject: [PATCH 05/11] build: Essentials 2.0.0-beta-2510 --- .../epi-essentials-mobile-control.csproj | 2 +- .../mobile-control-messengers/mobile-control-messengers.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/4-series/epi-essentials-mobile-control/epi-essentials-mobile-control.csproj b/4-series/epi-essentials-mobile-control/epi-essentials-mobile-control.csproj index 0c56284..a825de0 100644 --- a/4-series/epi-essentials-mobile-control/epi-essentials-mobile-control.csproj +++ b/4-series/epi-essentials-mobile-control/epi-essentials-mobile-control.csproj @@ -28,7 +28,7 @@ TRACE;SERIES4 - + diff --git a/4-series/mobile-control-messengers/mobile-control-messengers.csproj b/4-series/mobile-control-messengers/mobile-control-messengers.csproj index d26c93a..19cc6af 100644 --- a/4-series/mobile-control-messengers/mobile-control-messengers.csproj +++ b/4-series/mobile-control-messengers/mobile-control-messengers.csproj @@ -62,6 +62,6 @@ - + \ No newline at end of file From c0d34c92c474e4c727fe5b34cc33a41e31a2a4a2 Mon Sep 17 00:00:00 2001 From: Andrew Welker Date: Tue, 28 May 2024 15:22:44 -0500 Subject: [PATCH 06/11] feat: add TP key to client This enables an application's device key to be sent to the application so it knows which touchpanel it is. --- 3-series/MobileControlSystemController.cs | 14 ++++- .../MobileControlWebsocketServer.cs | 59 ++++++++++++------- 2 files changed, 50 insertions(+), 23 deletions(-) diff --git a/3-series/MobileControlSystemController.cs b/3-series/MobileControlSystemController.cs index 893aaba..a86bb84 100644 --- a/3-series/MobileControlSystemController.cs +++ b/3-series/MobileControlSystemController.cs @@ -5,6 +5,7 @@ using Crestron.SimplSharp.WebScripting; using Newtonsoft.Json; using Newtonsoft.Json.Linq; +using Org.BouncyCastle.Crypto.Prng; using PepperDash.Core; using PepperDash.Essentials.AppServer; using PepperDash.Essentials.AppServer.Messengers; @@ -1585,8 +1586,8 @@ private void HandleHeartBeat(JToken content) private void HandleClientJoined(JToken content) { var clientId = content["clientId"].Value(); - var roomKey = content["roomKey"].Value(); - + var roomKey = content["roomKey"].Value(); + var touchpanelKey = content.SelectToken("touchpanelKey"); //content["touchpanelKey"].Value(); SendMessageObject(new MobileControlMessage { @@ -1594,6 +1595,15 @@ private void HandleClientJoined(JToken content) ClientId = clientId, Content = roomKey }); + + if(touchpanelKey == null) { return; } + + SendMessageObject(new MobileControlMessage + { + Type = "/system/touchpanelKey", + ClientId = clientId, + Content = touchpanelKey.Value() + }); } private void HandleUserCode(JToken content, Action action = null) diff --git a/4-series/epi-essentials-mobile-control/WebSocketServer/MobileControlWebsocketServer.cs b/4-series/epi-essentials-mobile-control/WebSocketServer/MobileControlWebsocketServer.cs index b167fd6..13eb808 100644 --- a/4-series/epi-essentials-mobile-control/WebSocketServer/MobileControlWebsocketServer.cs +++ b/4-series/epi-essentials-mobile-control/WebSocketServer/MobileControlWebsocketServer.cs @@ -33,6 +33,8 @@ public class UiClient : WebSocketBehavior public string RoomKey { get; set; } + public string TouchpanelKey { get; set; } + private DateTime _connectionTime; public TimeSpan ConnectedDuration @@ -64,34 +66,47 @@ protected override void OnOpen() var match = Regex.Match(url.AbsoluteUri, "(?:ws|wss):\\/\\/.*(?:\\/mc\\/api\\/ui\\/join\\/)(.*)"); - if (match.Success) + if (!match.Success) { - var clientId = match.Groups[1].Value; + return; + } + + var clientId = match.Groups[1].Value; - // Inform controller of client joining - if (Controller != null) - { - var clientJoined = new MobileControlMessage - { - Type = "/system/roomKey", - ClientId = clientId, - Content = RoomKey, - }; + // Inform controller of client joining + if (Controller == null) + { + Debug.LogMessage(Serilog.Events.LogEventLevel.Verbose, "WebSocket UiClient Controller is null"); + } + /* + var clientJoined = new MobileControlMessage + { + Type = "/system/roomKey", + ClientId = clientId, + Content = RoomKey, + }; - Controller.SendMessageObjectToDirectClient(clientJoined); + Controller.SendMessageObjectToDirectClient(clientJoined);*/ - var bridge = Controller.GetRoomBridge(RoomKey); + var clientJoined = new MobileControlMessage + { + Type = "/system/clientJoined", + Content = JToken.FromObject(new + { + clientId, + roomKey = RoomKey, + touchpanelKey = string.IsNullOrEmpty(TouchpanelKey) ? TouchpanelKey : string.Empty, + }) + }; - SendUserCodeToClient(bridge, clientId); + Controller.HandleClientMessage(JsonConvert.SerializeObject(clientJoined)); - bridge.UserCodeChanged += (sender, args) => SendUserCodeToClient((MobileControlEssentialsRoomBridge)sender, clientId); - } - else - { - Debug.Console(2, "WebSocket UiClient Controller is null"); - } - } + var bridge = Controller.GetRoomBridge(RoomKey); + + SendUserCodeToClient(bridge, clientId); + bridge.UserCodeChanged += (sender, args) => SendUserCodeToClient((MobileControlEssentialsRoomBridge)sender, clientId); + _connectionTime = DateTime.Now; // TODO: Future: Check token to see if there's already an open session using that token and reject/close the session @@ -509,6 +524,7 @@ private void RetrieveSecret() var key = client.Key; var path = _wsPath + key; var roomKey = client.Value.Token.RoomKey; + var touchpanelKey = client.Value.Token.TouchpanelKey; _server.AddWebSocketService(path, () => { @@ -516,6 +532,7 @@ private void RetrieveSecret() Debug.Console(2, this, "Constructing UiClient with id: {0}", key); c.Controller = _parent; c.RoomKey = roomKey; + c.TouchpanelKey = touchpanelKey; UiClients[key].SetClient(c); return c; }); From 2377fb4b31a8e8a7cbb21e30ea647d8eba0de057 Mon Sep 17 00:00:00 2001 From: Andrew Welker Date: Tue, 28 May 2024 15:23:16 -0500 Subject: [PATCH 07/11] feat: add theme save/recall via config --- .../Touchpanel/ITheme.cs | 17 +++++ .../MobileControlTouchpanelController.cs | 68 +++++++++++++------ .../MobileControlTouchpanelProperties.cs | 3 + .../Touchpanel/ThemeMessenger.cs | 42 ++++++++++++ 4 files changed, 109 insertions(+), 21 deletions(-) create mode 100644 4-series/epi-essentials-mobile-control/Touchpanel/ITheme.cs create mode 100644 4-series/epi-essentials-mobile-control/Touchpanel/ThemeMessenger.cs diff --git a/4-series/epi-essentials-mobile-control/Touchpanel/ITheme.cs b/4-series/epi-essentials-mobile-control/Touchpanel/ITheme.cs new file mode 100644 index 0000000..3d6eb7b --- /dev/null +++ b/4-series/epi-essentials-mobile-control/Touchpanel/ITheme.cs @@ -0,0 +1,17 @@ +using PepperDash.Core; +using PepperDash.Essentials.Core; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PepperDash.Essentials.Touchpanel +{ + public interface ITheme:IKeyed + { + string Theme { get; } + + void UpdateTheme(string theme); + } +} diff --git a/4-series/epi-essentials-mobile-control/Touchpanel/MobileControlTouchpanelController.cs b/4-series/epi-essentials-mobile-control/Touchpanel/MobileControlTouchpanelController.cs index 705269f..87180b7 100644 --- a/4-series/epi-essentials-mobile-control/Touchpanel/MobileControlTouchpanelController.cs +++ b/4-series/epi-essentials-mobile-control/Touchpanel/MobileControlTouchpanelController.cs @@ -2,6 +2,7 @@ using Crestron.SimplSharpPro.DeviceSupport; using Crestron.SimplSharpPro.UI; using Newtonsoft.Json; +using Newtonsoft.Json.Linq; using PepperDash.Core; using PepperDash.Essentials.Core; using PepperDash.Essentials.Core.Config; @@ -24,7 +25,7 @@ namespace PepperDash.Essentials.Devices.Common.TouchPanel //} - public class MobileControlTouchpanelController : TouchpanelBase, IHasFeedback, ITswAppControl, ITswZoomControl, IDeviceInfoProvider, IMobileControlTouchpanelController + public class MobileControlTouchpanelController : TouchpanelBase, IHasFeedback, ITswAppControl, ITswZoomControl, IDeviceInfoProvider, IMobileControlTouchpanelController, ITheme { private readonly MobileControlTouchpanelProperties localConfig; private IMobileControlRoomMessenger _bridge; @@ -61,6 +62,10 @@ public class MobileControlTouchpanelController : TouchpanelBase, IHasFeedback, I public bool ZoomRoomController => localConfig.ZoomRoomController; + public string Theme => localConfig.Theme; + + public StringFeedback ThemeFeedback { get; private set; } + public DeviceInfo DeviceInfo => new DeviceInfo(); public MobileControlTouchpanelController(string key, string name, BasicTriListWithSmartObject panel, MobileControlTouchpanelProperties config) : base(key, name, panel, config) @@ -69,6 +74,7 @@ public MobileControlTouchpanelController(string key, string name, BasicTriListWi AddPostActivationAction(SubscribeForMobileControlUpdates); + ThemeFeedback = new StringFeedback(() => Theme); AppUrlFeedback = new StringFeedback(() => _appUrl); QrCodeUrlFeedback = new StringFeedback(() => _bridge?.QrCodeUrl); McServerUrlFeedback = new StringFeedback(() => _bridge?.McServerUrl); @@ -78,13 +84,13 @@ public MobileControlTouchpanelController(string key, string name, BasicTriListWi { if (Panel is TswX60BaseClass tsX60) { - Debug.Console(2, this, $"x60 sending {tsX60.ExtenderApplicationControlReservedSigs.HideOpenApplicationFeedback.BoolValue}"); + Debug.LogMessage(Serilog.Events.LogEventLevel.Verbose, this, $"x60 sending {tsX60.ExtenderApplicationControlReservedSigs.HideOpenApplicationFeedback.BoolValue}"); return !tsX60.ExtenderApplicationControlReservedSigs.HideOpenApplicationFeedback.BoolValue; } if (Panel is TswX70Base tsX70) { - Debug.Console(2, this, $"x70 sending {tsX70.ExtenderApplicationControlReservedSigs.HideOpenedApplicationFeedback.BoolValue}"); + Debug.LogMessage(Serilog.Events.LogEventLevel.Verbose, this, $"x70 sending {tsX70.ExtenderApplicationControlReservedSigs.HideOpenedApplicationFeedback.BoolValue}"); return !tsX70.ExtenderApplicationControlReservedSigs.HideOpenedApplicationFeedback.BoolValue; } @@ -133,13 +139,28 @@ public MobileControlTouchpanelController(string key, string name, BasicTriListWi RegisterForExtenders(); } + public void UpdateTheme(string theme) + { + localConfig.Theme = theme; + + var props = JToken.FromObject(localConfig); + + var deviceConfig = ConfigReader.ConfigObject.Devices.FirstOrDefault((d) => d.Key == Key); + + if(deviceConfig == null) { return; } + + deviceConfig.Properties = props; + + ConfigWriter.UpdateDeviceConfig(deviceConfig); + } + private void RegisterForExtenders() { if (Panel is TswXX70Base x70Panel) { x70Panel.ExtenderApplicationControlReservedSigs.DeviceExtenderSigChange += (e, a) => { - Debug.Console(2, this, $"X70 App Control Device Extender args: {a.Event}:{a.Sig}:{a.Sig.Type}:{a.Sig.BoolValue}:{a.Sig.UShortValue}:{a.Sig.StringValue}"); + Debug.LogMessage(Serilog.Events.LogEventLevel.Verbose, this, $"X70 App Control Device Extender args: {a.Event}:{a.Sig}:{a.Sig.Type}:{a.Sig.BoolValue}:{a.Sig.UShortValue}:{a.Sig.StringValue}"); UpdateZoomFeedbacks(); if (!x70Panel.ExtenderApplicationControlReservedSigs.HideOpenedApplicationFeedback.BoolValue) @@ -156,7 +177,7 @@ private void RegisterForExtenders() x70Panel.ExtenderZoomRoomAppReservedSigs.DeviceExtenderSigChange += (e, a) => { - Debug.Console(2, this, $"X70 Zoom Room Ap Device Extender args: {a.Event}:{a.Sig}:{a.Sig.Type}:{a.Sig.BoolValue}:{a.Sig.UShortValue}:{a.Sig.StringValue}"); + Debug.LogMessage(Serilog.Events.LogEventLevel.Verbose, this, $"X70 Zoom Room Ap Device Extender args: {a.Event}:{a.Sig}:{a.Sig.Type}:{a.Sig.BoolValue}:{a.Sig.UShortValue}:{a.Sig.StringValue}"); UpdateZoomFeedbacks(); }; @@ -166,7 +187,7 @@ private void RegisterForExtenders() DeviceInfo.MacAddress = x70Panel.ExtenderEthernetReservedSigs.MacAddressFeedback.StringValue; DeviceInfo.IpAddress = x70Panel.ExtenderEthernetReservedSigs.IpAddressFeedback.StringValue; - Debug.Console(1, this, $"MAC: {DeviceInfo.MacAddress} IP: {DeviceInfo.IpAddress}"); + Debug.LogMessage(Serilog.Events.LogEventLevel.Debug, this, $"MAC: {DeviceInfo.MacAddress} IP: {DeviceInfo.IpAddress}"); var handler = DeviceInfoChanged; @@ -196,12 +217,12 @@ private void RegisterForExtenders() { x60withZoomApp.ExtenderApplicationControlReservedSigs.DeviceExtenderSigChange += (e, a) => { - Debug.Console(2, this, $"X60 App Control Device Extender args: {a.Event}:{a.Sig}:{a.Sig.Type}:{a.Sig.BoolValue}:{a.Sig.UShortValue}:{a.Sig.StringValue}"); + Debug.LogMessage(Serilog.Events.LogEventLevel.Verbose, this, $"X60 App Control Device Extender args: {a.Event}:{a.Sig}:{a.Sig.Type}:{a.Sig.BoolValue}:{a.Sig.UShortValue}:{a.Sig.StringValue}"); UpdateZoomFeedbacks(); }; x60withZoomApp.ExtenderZoomRoomAppReservedSigs.DeviceExtenderSigChange += (e, a) => { - Debug.Console(2, this, $"X60 Zoom Room App Device Extender args: {a.Event}:{a.Sig}:{a.Sig.Type}:{a.Sig.BoolValue}:{a.Sig.UShortValue}:{a.Sig.StringValue}"); + Debug.LogMessage(Serilog.Events.LogEventLevel.Verbose, this, $"X60 Zoom Room App Device Extender args: {a.Event}:{a.Sig}:{a.Sig.Type}:{a.Sig.BoolValue}:{a.Sig.UShortValue}:{a.Sig.StringValue}"); UpdateZoomFeedbacks(); }; @@ -210,7 +231,7 @@ private void RegisterForExtenders() DeviceInfo.MacAddress = x60withZoomApp.ExtenderEthernetReservedSigs.MacAddressFeedback.StringValue; DeviceInfo.IpAddress = x60withZoomApp.ExtenderEthernetReservedSigs.IpAddressFeedback.StringValue; - Debug.Console(1, this, $"MAC: {DeviceInfo.MacAddress} IP: {DeviceInfo.IpAddress}"); + Debug.LogMessage(Serilog.Events.LogEventLevel.Debug, this, $"MAC: {DeviceInfo.MacAddress} IP: {DeviceInfo.IpAddress}"); var handler = DeviceInfoChanged; @@ -238,6 +259,8 @@ public override bool CustomActivate() var zoomMessenger = new ITswZoomControlMessenger($"zoomControlMessenger-{Key}", $"/device/{Key}", this); + var themeMessenger = new ThemeMessenger($"themeMessenger-{Key}", $"/device/{Key}", this); + var mc = DeviceManager.AllDevices.OfType().FirstOrDefault(); if (mc == null) @@ -247,6 +270,7 @@ public override bool CustomActivate() mc.AddDeviceMessenger(appMessenger); mc.AddDeviceMessenger(zoomMessenger); + mc.AddDeviceMessenger(themeMessenger); return base.CustomActivate(); } @@ -254,7 +278,7 @@ public override bool CustomActivate() protected override void ExtenderSystemReservedSigs_DeviceExtenderSigChange(DeviceExtender currentDeviceExtender, SigEventArgs args) { - Debug.Console(2, this, $"System Device Extender args: ${args.Event}:${args.Sig}"); + Debug.LogMessage(Serilog.Events.LogEventLevel.Verbose, this, $"System Device Extender args: ${args.Event}:${args.Sig}"); } protected override void SetupPanelDrivers(string roomKey) @@ -279,14 +303,14 @@ private void SubscribeForMobileControlUpdates() { foreach (var dev in DeviceManager.AllDevices) { - Debug.Console(0, this, $"{dev.Key}:{dev.GetType().Name}"); + Debug.LogMessage(Serilog.Events.LogEventLevel.Information, this, $"{dev.Key}:{dev.GetType().Name}"); } var mcList = DeviceManager.AllDevices.OfType().ToList(); if (mcList.Count == 0) { - Debug.Console(0, this, $"No Mobile Control controller found"); + Debug.LogMessage(Serilog.Events.LogEventLevel.Information, this, $"No Mobile Control controller found"); return; } @@ -298,14 +322,14 @@ private void SubscribeForMobileControlUpdates() if (bridge == null) { - Debug.Console(0, this, $"No Mobile Control bridge for {_config.DefaultRoomKey} found "); + Debug.LogMessage(Serilog.Events.LogEventLevel.Information, this, $"No Mobile Control bridge for {_config.DefaultRoomKey} found "); return; } _bridge = bridge; _bridge.UserCodeChanged += UpdateFeedbacks; - _bridge.AppUrlChanged += (s, a) => { Debug.Console(0, this, "AppURL changed"); UpdateFeedbacks(s, a); }; + _bridge.AppUrlChanged += (s, a) => { Debug.LogMessage(Serilog.Events.LogEventLevel.Information, this, "AppURL changed"); UpdateFeedbacks(s, a); }; } public void SetAppUrl(string url) @@ -328,7 +352,7 @@ private void UpdateZoomFeedbacks() { foreach (var feedback in ZoomFeedbacks) { - Debug.Console(1, this, $"Updating {feedback.Key}"); + Debug.LogMessage(Serilog.Events.LogEventLevel.Debug, this, $"Updating {feedback.Key}"); feedback.FireUpdate(); } } @@ -358,7 +382,7 @@ public void OpenApp() if (Panel is TswX60WithZoomRoomAppReservedSigs) { - Debug.Console(0, this, $"X60 panel does not support zoom app"); + Debug.LogMessage(Serilog.Events.LogEventLevel.Information, this, $"X60 panel does not support zoom app"); return; } } @@ -425,7 +449,7 @@ public void UpdateDeviceInfo() handler(this, new DeviceInfoEventArgs(DeviceInfo)); } - Debug.Console(1, this, $"MAC: {DeviceInfo.MacAddress} IP: {DeviceInfo.IpAddress}"); + Debug.LogMessage(Serilog.Events.LogEventLevel.Debug, this, $"MAC: {DeviceInfo.MacAddress} IP: {DeviceInfo.IpAddress}"); } } @@ -442,14 +466,16 @@ public override EssentialsDevice BuildDevice(DeviceConfig dc) var comm = CommFactory.GetControlPropertiesConfig(dc); var props = JsonConvert.DeserializeObject(dc.Properties.ToString()); + Debug.LogMessage(Serilog.Events.LogEventLevel.Verbose, "Touchpanel Properties {@props}", this, props); + var panel = GetPanelForType(dc.Type, comm.IpIdInt, props.ProjectName); if (panel == null) { - Debug.Console(0, "Unable to create Touchpanel for type {0}. Touchpanel Controller WILL NOT function correctly", dc.Type); + Debug.LogMessage(Serilog.Events.LogEventLevel.Information, "Unable to create Touchpanel for type {0}. Touchpanel Controller WILL NOT function correctly", dc.Type); } - Debug.Console(1, "Factory Attempting to create new MobileControlTouchpanelController"); + Debug.LogMessage(Serilog.Events.LogEventLevel.Debug, "Factory Attempting to create new MobileControlTouchpanelController"); var panelController = new MobileControlTouchpanelController(dc.Key, dc.Name, panel, props); @@ -499,13 +525,13 @@ private BasicTriListWithSmartObject GetPanelForType(string type, uint id, string return new Ts1070(id, Global.ControlSystem); else { - Debug.Console(0, Debug.ErrorLogLevel.Notice, "WARNING: Cannot create TSW controller with type '{0}'", type); + Debug.LogMessage(Serilog.Events.LogEventLevel.Warning, "WARNING: Cannot create TSW controller with type '{0}'", type); return null; } } catch (Exception e) { - Debug.Console(0, Debug.ErrorLogLevel.Notice, "WARNING: Cannot create TSW base class. Panel will not function: {0}", e.Message); + Debug.LogMessage(Serilog.Events.LogEventLevel.Warning, "WARNING: Cannot create TSW base class. Panel will not function: {0}", e.Message); return null; } } diff --git a/4-series/epi-essentials-mobile-control/Touchpanel/MobileControlTouchpanelProperties.cs b/4-series/epi-essentials-mobile-control/Touchpanel/MobileControlTouchpanelProperties.cs index a72eaa6..1d8f8eb 100644 --- a/4-series/epi-essentials-mobile-control/Touchpanel/MobileControlTouchpanelProperties.cs +++ b/4-series/epi-essentials-mobile-control/Touchpanel/MobileControlTouchpanelProperties.cs @@ -13,5 +13,8 @@ public class MobileControlTouchpanelProperties : CrestronTouchpanelPropertiesCon [JsonProperty("buttonToolbarTimeoutInS")] public ushort ButtonToolbarTimoutInS { get; set; } = 0; + + [JsonProperty("theme")] + public string Theme { get; set; } = "light"; } } \ No newline at end of file diff --git a/4-series/epi-essentials-mobile-control/Touchpanel/ThemeMessenger.cs b/4-series/epi-essentials-mobile-control/Touchpanel/ThemeMessenger.cs new file mode 100644 index 0000000..cf93197 --- /dev/null +++ b/4-series/epi-essentials-mobile-control/Touchpanel/ThemeMessenger.cs @@ -0,0 +1,42 @@ +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using PepperDash.Core; +using PepperDash.Essentials.AppServer; +using PepperDash.Essentials.AppServer.Messengers; + +namespace PepperDash.Essentials.Touchpanel +{ + public class ThemeMessenger : MessengerBase + { + private readonly ITheme _tpDevice; + + public ThemeMessenger(string key, string path, ITheme device) : base(key, path, device as Device) + { + _tpDevice = device; + } + + protected override void RegisterActions() + { + AddAction("/fullStatus", (id, content) => + { + PostStatusMessage(new ThemeUpdateMessage { Theme = _tpDevice.Theme }); + }); + + AddAction("/saveTheme", (id, content) => + { + var theme = content.ToObject>(); + + Debug.LogMessage(Serilog.Events.LogEventLevel.Information, "Setting theme to {theme}", this, theme.Value); + _tpDevice.UpdateTheme(theme.Value); + + PostStatusMessage(JToken.FromObject(new {theme = theme.Value})); + }); + } + } + + public class ThemeUpdateMessage:DeviceStateMessageBase + { + [JsonProperty("theme")] + public string Theme { get; set; } + } +} From d9a9df438b08e126dd5bb19003519cdaf389d225 Mon Sep 17 00:00:00 2001 From: Andrew Welker Date: Tue, 28 May 2024 15:23:30 -0500 Subject: [PATCH 08/11] build: Essentials 2.0.0-beta-2519 --- .../epi-essentials-mobile-control.csproj | 2 +- .../mobile-control-messengers/mobile-control-messengers.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/4-series/epi-essentials-mobile-control/epi-essentials-mobile-control.csproj b/4-series/epi-essentials-mobile-control/epi-essentials-mobile-control.csproj index a825de0..1bc1daf 100644 --- a/4-series/epi-essentials-mobile-control/epi-essentials-mobile-control.csproj +++ b/4-series/epi-essentials-mobile-control/epi-essentials-mobile-control.csproj @@ -28,7 +28,7 @@ TRACE;SERIES4 - + diff --git a/4-series/mobile-control-messengers/mobile-control-messengers.csproj b/4-series/mobile-control-messengers/mobile-control-messengers.csproj index 19cc6af..b14366c 100644 --- a/4-series/mobile-control-messengers/mobile-control-messengers.csproj +++ b/4-series/mobile-control-messengers/mobile-control-messengers.csproj @@ -62,6 +62,6 @@ - + \ No newline at end of file From 34b490e54b8663ec8f6c006e22f374f9b2f06b39 Mon Sep 17 00:00:00 2001 From: Andrew Welker Date: Fri, 21 Jun 2024 10:25:02 -0500 Subject: [PATCH 09/11] feat: update to Essentials 2.0.0-alpha-2529 --- .../epi-essentials-mobile-control.csproj | 2 +- .../mobile-control-messengers/mobile-control-messengers.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/4-series/epi-essentials-mobile-control/epi-essentials-mobile-control.csproj b/4-series/epi-essentials-mobile-control/epi-essentials-mobile-control.csproj index 1bc1daf..53f99b5 100644 --- a/4-series/epi-essentials-mobile-control/epi-essentials-mobile-control.csproj +++ b/4-series/epi-essentials-mobile-control/epi-essentials-mobile-control.csproj @@ -28,7 +28,7 @@ TRACE;SERIES4 - + diff --git a/4-series/mobile-control-messengers/mobile-control-messengers.csproj b/4-series/mobile-control-messengers/mobile-control-messengers.csproj index b14366c..053d128 100644 --- a/4-series/mobile-control-messengers/mobile-control-messengers.csproj +++ b/4-series/mobile-control-messengers/mobile-control-messengers.csproj @@ -62,6 +62,6 @@ - + \ No newline at end of file From 2d84e3e043c5b7e0336f2479a38f05a17d80a7d7 Mon Sep 17 00:00:00 2001 From: Andrew Welker Date: Fri, 21 Jun 2024 10:26:37 -0500 Subject: [PATCH 10/11] fix: change how Zoom in-call and incoming call feedback is managed --- .../Touchpanel/ITswZoomControlMessenger.cs | 2 ++ .../MobileControlTouchpanelController.cs | 29 ++++++++++++++++--- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/4-series/epi-essentials-mobile-control/Touchpanel/ITswZoomControlMessenger.cs b/4-series/epi-essentials-mobile-control/Touchpanel/ITswZoomControlMessenger.cs index 51ff355..da59d93 100644 --- a/4-series/epi-essentials-mobile-control/Touchpanel/ITswZoomControlMessenger.cs +++ b/4-series/epi-essentials-mobile-control/Touchpanel/ITswZoomControlMessenger.cs @@ -34,6 +34,7 @@ protected override void RegisterActions() PostStatusMessage(JToken.FromObject(new { incomingCall = a.BoolValue, + inCall = _zoomControl.ZoomInCallFeedback.BoolValue })); }; @@ -44,6 +45,7 @@ protected override void RegisterActions() new { inCall = a.BoolValue, + incomingCall = _zoomControl.ZoomIncomingCallFeedback.BoolValue })); }; } diff --git a/4-series/epi-essentials-mobile-control/Touchpanel/MobileControlTouchpanelController.cs b/4-series/epi-essentials-mobile-control/Touchpanel/MobileControlTouchpanelController.cs index 87180b7..1313bf1 100644 --- a/4-series/epi-essentials-mobile-control/Touchpanel/MobileControlTouchpanelController.cs +++ b/4-series/epi-essentials-mobile-control/Touchpanel/MobileControlTouchpanelController.cs @@ -155,12 +155,13 @@ public void UpdateTheme(string theme) } private void RegisterForExtenders() - { + { if (Panel is TswXX70Base x70Panel) { x70Panel.ExtenderApplicationControlReservedSigs.DeviceExtenderSigChange += (e, a) => { Debug.LogMessage(Serilog.Events.LogEventLevel.Verbose, this, $"X70 App Control Device Extender args: {a.Event}:{a.Sig}:{a.Sig.Type}:{a.Sig.BoolValue}:{a.Sig.UShortValue}:{a.Sig.StringValue}"); + UpdateZoomFeedbacks(); if (!x70Panel.ExtenderApplicationControlReservedSigs.HideOpenedApplicationFeedback.BoolValue) @@ -178,7 +179,15 @@ private void RegisterForExtenders() x70Panel.ExtenderZoomRoomAppReservedSigs.DeviceExtenderSigChange += (e, a) => { Debug.LogMessage(Serilog.Events.LogEventLevel.Verbose, this, $"X70 Zoom Room Ap Device Extender args: {a.Event}:{a.Sig}:{a.Sig.Type}:{a.Sig.BoolValue}:{a.Sig.UShortValue}:{a.Sig.StringValue}"); - UpdateZoomFeedbacks(); + + if (a.Sig.Number == x70Panel.ExtenderZoomRoomAppReservedSigs.ZoomRoomIncomingCallFeedback.Number) + { + ZoomIncomingCallFeedback.FireUpdate(); + } + else if (a.Sig.Number == x70Panel.ExtenderZoomRoomAppReservedSigs.ZoomRoomActiveFeedback.Number) + { + ZoomInCallFeedback.FireUpdate(); + } }; @@ -218,12 +227,24 @@ private void RegisterForExtenders() x60withZoomApp.ExtenderApplicationControlReservedSigs.DeviceExtenderSigChange += (e, a) => { Debug.LogMessage(Serilog.Events.LogEventLevel.Verbose, this, $"X60 App Control Device Extender args: {a.Event}:{a.Sig}:{a.Sig.Type}:{a.Sig.BoolValue}:{a.Sig.UShortValue}:{a.Sig.StringValue}"); - UpdateZoomFeedbacks(); + + if (a.Sig.Number == x60withZoomApp.ExtenderApplicationControlReservedSigs.HideOpenApplicationFeedback.Number) + { + AppOpenFeedback.FireUpdate(); + } }; x60withZoomApp.ExtenderZoomRoomAppReservedSigs.DeviceExtenderSigChange += (e, a) => { Debug.LogMessage(Serilog.Events.LogEventLevel.Verbose, this, $"X60 Zoom Room App Device Extender args: {a.Event}:{a.Sig}:{a.Sig.Type}:{a.Sig.BoolValue}:{a.Sig.UShortValue}:{a.Sig.StringValue}"); - UpdateZoomFeedbacks(); + + if (a.Sig.Number == x60withZoomApp.ExtenderZoomRoomAppReservedSigs.ZoomRoomIncomingCallFeedback.Number) + { + ZoomIncomingCallFeedback.FireUpdate(); + } + else if (a.Sig.Number == x60withZoomApp.ExtenderZoomRoomAppReservedSigs.ZoomRoomActiveFeedback.Number) + { + ZoomInCallFeedback.FireUpdate(); + } }; x60withZoomApp.ExtenderEthernetReservedSigs.DeviceExtenderSigChange += (e, a) => From 8fee4ec5d6f4a9a59d1ae851849f362dd25610e1 Mon Sep 17 00:00:00 2001 From: Andrew Welker Date: Mon, 24 Jun 2024 09:47:08 -0500 Subject: [PATCH 11/11] fix: allow theme messenger to build/register The xPanel is setup to use the config to save/store theme information. However, the messenger needs to be built for the xPanel to persist it's theme information that way. --- .../MobileControlTouchpanelController.cs | 30 +++++++++++-------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/4-series/epi-essentials-mobile-control/Touchpanel/MobileControlTouchpanelController.cs b/4-series/epi-essentials-mobile-control/Touchpanel/MobileControlTouchpanelController.cs index 1313bf1..0b77a0e 100644 --- a/4-series/epi-essentials-mobile-control/Touchpanel/MobileControlTouchpanelController.cs +++ b/4-series/epi-essentials-mobile-control/Touchpanel/MobileControlTouchpanelController.cs @@ -141,13 +141,13 @@ public MobileControlTouchpanelController(string key, string name, BasicTriListWi public void UpdateTheme(string theme) { - localConfig.Theme = theme; - + localConfig.Theme = theme; + var props = JToken.FromObject(localConfig); var deviceConfig = ConfigReader.ConfigObject.Devices.FirstOrDefault((d) => d.Key == Key); - if(deviceConfig == null) { return; } + if (deviceConfig == null) { return; } deviceConfig.Properties = props; @@ -155,7 +155,7 @@ public void UpdateTheme(string theme) } private void RegisterForExtenders() - { + { if (Panel is TswXX70Base x70Panel) { x70Panel.ExtenderApplicationControlReservedSigs.DeviceExtenderSigChange += (e, a) => @@ -168,13 +168,14 @@ private void RegisterForExtenders() { x70Panel.ExtenderButtonToolbarReservedSigs.ShowButtonToolbar(); x70Panel.ExtenderButtonToolbarReservedSigs.Button2On(); - } else + } + else { x70Panel.ExtenderButtonToolbarReservedSigs.HideButtonToolbar(); x70Panel.ExtenderButtonToolbarReservedSigs.Button2Off(); } }; - + x70Panel.ExtenderZoomRoomAppReservedSigs.DeviceExtenderSigChange += (e, a) => { @@ -189,7 +190,7 @@ private void RegisterForExtenders() ZoomInCallFeedback.FireUpdate(); } }; - + x70Panel.ExtenderEthernetReservedSigs.DeviceExtenderSigChange += (e, a) => { @@ -200,7 +201,7 @@ private void RegisterForExtenders() var handler = DeviceInfoChanged; - if(handler == null) + if (handler == null) { return; } @@ -248,7 +249,7 @@ private void RegisterForExtenders() }; x60withZoomApp.ExtenderEthernetReservedSigs.DeviceExtenderSigChange += (e, a) => - { + { DeviceInfo.MacAddress = x60withZoomApp.ExtenderEthernetReservedSigs.MacAddressFeedback.StringValue; DeviceInfo.IpAddress = x60withZoomApp.ExtenderEthernetReservedSigs.IpAddressFeedback.StringValue; @@ -272,10 +273,6 @@ private void RegisterForExtenders() public override bool CustomActivate() { - if (!(Panel is TswXX70Base) && !(Panel is TswX60WithZoomRoomAppReservedSigs)) - { - return base.CustomActivate(); - } var appMessenger = new ITswAppControlMessenger($"appControlMessenger-{Key}", $"/device/{Key}", this); var zoomMessenger = new ITswZoomControlMessenger($"zoomControlMessenger-{Key}", $"/device/{Key}", this); @@ -289,6 +286,13 @@ public override bool CustomActivate() return base.CustomActivate(); } + if (!(Panel is TswXX70Base) && !(Panel is TswX60WithZoomRoomAppReservedSigs)) + { + mc.AddDeviceMessenger(themeMessenger); + + return base.CustomActivate(); + } + mc.AddDeviceMessenger(appMessenger); mc.AddDeviceMessenger(zoomMessenger); mc.AddDeviceMessenger(themeMessenger);