Merge branch 'main' into meter-feedback-interface

This commit is contained in:
Andrew Welker
2025-07-17 12:34:16 -05:00
3 changed files with 187 additions and 47 deletions

View File

@@ -1,4 +1,6 @@
using System; using System;
using System.Collections.ObjectModel;
using Crestron.SimplSharpPro;
using Newtonsoft.Json; using Newtonsoft.Json;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using PepperDash.Core; using PepperDash.Core;
@@ -33,11 +35,11 @@ namespace PepperDash.Essentials.Core.DeviceTypeInterfaces
string SystemUuid { get; } string SystemUuid { get; }
BoolFeedback ApiOnlineAndAuthorized { get;} BoolFeedback ApiOnlineAndAuthorized { get; }
void SendMessageObject(IMobileControlMessage o); void SendMessageObject(IMobileControlMessage o);
void AddAction<T>(T messenger, Action<string, string, JToken> action) where T:IMobileControlMessenger; void AddAction<T>(T messenger, Action<string, string, JToken> action) where T : IMobileControlMessenger;
void RemoveAction(string key); void RemoveAction(string key);
@@ -45,14 +47,14 @@ namespace PepperDash.Essentials.Core.DeviceTypeInterfaces
bool CheckForDeviceMessenger(string key); bool CheckForDeviceMessenger(string key);
IMobileControlRoomMessenger GetRoomMessenger(string key); IMobileControlRoomMessenger GetRoomMessenger(string key);
} }
/// <summary> /// <summary>
/// Describes a mobile control messenger /// Describes a mobile control messenger
/// </summary> /// </summary>
public interface IMobileControlMessenger: IKeyed public interface IMobileControlMessenger : IKeyed
{ {
IMobileControl AppServerController { get; } IMobileControl AppServerController { get; }
string MessagePath { get; } string MessagePath { get; }
@@ -104,16 +106,47 @@ namespace PepperDash.Essentials.Core.DeviceTypeInterfaces
public interface IMobileControlAction public interface IMobileControlAction
{ {
IMobileControlMessenger Messenger { get; } IMobileControlMessenger Messenger { get; }
Action<string,string, JToken> Action { get; } Action<string, string, JToken> Action { get; }
} }
/// <summary>
/// Describes a MobileControl Touchpanel Controller
/// </summary>
public interface IMobileControlTouchpanelController : IKeyed public interface IMobileControlTouchpanelController : IKeyed
{ {
/// <summary>
/// The default room key for the controller
/// </summary>
string DefaultRoomKey { get; } string DefaultRoomKey { get; }
/// <summary>
/// Sets the application URL for the controller
/// </summary>
/// <param name="url">The application URL</param>
void SetAppUrl(string url); void SetAppUrl(string url);
/// <summary>
/// Indicates whether the controller uses a direct server connection
/// </summary>
bool UseDirectServer { get; } bool UseDirectServer { get; }
/// <summary>
/// Indicates whether the controller is a Zoom Room controller
/// </summary>
bool ZoomRoomController { get; } bool ZoomRoomController { get; }
} }
/// <summary>
/// Describes a MobileControl Crestron Touchpanel Controller
/// This interface extends the IMobileControlTouchpanelController to include connected IP information
/// </summary>
public interface IMobileControlCrestronTouchpanelController : IMobileControlTouchpanelController
{
/// <summary>
/// Gets a collection of connected IP information for the touchpanel controller
/// </summary>
ReadOnlyCollection<ConnectedIpInformation> ConnectedIps { get; }
}
} }

View File

@@ -1,4 +1,8 @@
using Crestron.SimplSharpPro; using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using Crestron.SimplSharpPro;
using Crestron.SimplSharpPro.DeviceSupport; using Crestron.SimplSharpPro.DeviceSupport;
using Crestron.SimplSharpPro.UI; using Crestron.SimplSharpPro.UI;
using Newtonsoft.Json; using Newtonsoft.Json;
@@ -10,64 +14,105 @@ using PepperDash.Essentials.Core.Config;
using PepperDash.Essentials.Core.DeviceInfo; using PepperDash.Essentials.Core.DeviceInfo;
using PepperDash.Essentials.Core.DeviceTypeInterfaces; using PepperDash.Essentials.Core.DeviceTypeInterfaces;
using PepperDash.Essentials.Core.UI; using PepperDash.Essentials.Core.UI;
using System;
using System.Collections.Generic;
using System.Linq;
using Feedback = PepperDash.Essentials.Core.Feedback; using Feedback = PepperDash.Essentials.Core.Feedback;
namespace PepperDash.Essentials.Touchpanel namespace PepperDash.Essentials.Touchpanel
{ {
//public interface IMobileControlTouchpanelController /// <summary>
//{ /// Mobile Control touchpanel controller that provides app control, Zoom integration,
// StringFeedback AppUrlFeedback { get; } /// and mobile control functionality for Crestron touchpanels.
// string DefaultRoomKey { get; } /// </summary>
// string DeviceKey { get; } public class MobileControlTouchpanelController : TouchpanelBase, IHasFeedback, ITswAppControl, ITswZoomControl, IDeviceInfoProvider, IMobileControlCrestronTouchpanelController, ITheme
//}
public class MobileControlTouchpanelController : TouchpanelBase, IHasFeedback, ITswAppControl, ITswZoomControl, IDeviceInfoProvider, IMobileControlTouchpanelController, ITheme
{ {
private readonly MobileControlTouchpanelProperties localConfig; private readonly MobileControlTouchpanelProperties localConfig;
private IMobileControlRoomMessenger _bridge; private IMobileControlRoomMessenger _bridge;
private string _appUrl; private string _appUrl;
/// <summary>
/// Gets feedback for the current application URL.
/// </summary>
public StringFeedback AppUrlFeedback { get; private set; } public StringFeedback AppUrlFeedback { get; private set; }
private readonly StringFeedback QrCodeUrlFeedback; private readonly StringFeedback QrCodeUrlFeedback;
private readonly StringFeedback McServerUrlFeedback; private readonly StringFeedback McServerUrlFeedback;
private readonly StringFeedback UserCodeFeedback; private readonly StringFeedback UserCodeFeedback;
private readonly BoolFeedback _appOpenFeedback; private readonly BoolFeedback _appOpenFeedback;
/// <summary>
/// Gets feedback indicating whether an application is currently open on the touchpanel.
/// </summary>
public BoolFeedback AppOpenFeedback => _appOpenFeedback; public BoolFeedback AppOpenFeedback => _appOpenFeedback;
private readonly BoolFeedback _zoomIncomingCallFeedback; private readonly BoolFeedback _zoomIncomingCallFeedback;
/// <summary>
/// Gets feedback indicating whether there is an incoming Zoom call.
/// </summary>
public BoolFeedback ZoomIncomingCallFeedback => _zoomIncomingCallFeedback; public BoolFeedback ZoomIncomingCallFeedback => _zoomIncomingCallFeedback;
private readonly BoolFeedback _zoomInCallFeedback; private readonly BoolFeedback _zoomInCallFeedback;
/// <summary>
/// Event that is raised when device information changes.
/// </summary>
public event DeviceInfoChangeHandler DeviceInfoChanged; public event DeviceInfoChangeHandler DeviceInfoChanged;
/// <summary>
/// Gets feedback indicating whether a Zoom call is currently active.
/// </summary>
public BoolFeedback ZoomInCallFeedback => _zoomInCallFeedback; public BoolFeedback ZoomInCallFeedback => _zoomInCallFeedback;
/// <summary>
/// Gets the collection of feedback objects for this touchpanel controller.
/// </summary>
public FeedbackCollection<Feedback> Feedbacks { get; private set; } public FeedbackCollection<Feedback> Feedbacks { get; private set; }
/// <summary>
/// Gets the collection of Zoom-related feedback objects.
/// </summary>
public FeedbackCollection<Feedback> ZoomFeedbacks { get; private set; } public FeedbackCollection<Feedback> ZoomFeedbacks { get; private set; }
/// <summary>
/// Gets the default room key for this touchpanel controller.
/// </summary>
public string DefaultRoomKey => _config.DefaultRoomKey; public string DefaultRoomKey => _config.DefaultRoomKey;
/// <summary>
/// Gets a value indicating whether to use direct server communication.
/// </summary>
public bool UseDirectServer => localConfig.UseDirectServer; public bool UseDirectServer => localConfig.UseDirectServer;
/// <summary>
/// Gets a value indicating whether this touchpanel acts as a Zoom Room controller.
/// </summary>
public bool ZoomRoomController => localConfig.ZoomRoomController; public bool ZoomRoomController => localConfig.ZoomRoomController;
/// <summary>
/// Gets the current theme for the touchpanel interface.
/// </summary>
public string Theme => localConfig.Theme; public string Theme => localConfig.Theme;
/// <summary>
/// Gets feedback for the current theme setting.
/// </summary>
public StringFeedback ThemeFeedback { get; private set; } public StringFeedback ThemeFeedback { get; private set; }
/// <summary>
/// Gets device information including MAC address and IP address.
/// </summary>
public DeviceInfo DeviceInfo => new DeviceInfo(); public DeviceInfo DeviceInfo => new DeviceInfo();
public ReadOnlyCollection<ConnectedIpInformation> ConnectedIps => Panel.ConnectedIpList;
/// <summary>
/// Initializes a new instance of the MobileControlTouchpanelController class.
/// </summary>
/// <param name="key">The unique key identifier for this touchpanel controller.</param>
/// <param name="name">The friendly name for this touchpanel controller.</param>
/// <param name="panel">The touchpanel hardware device.</param>
/// <param name="config">The configuration properties for this controller.</param>
public MobileControlTouchpanelController(string key, string name, BasicTriListWithSmartObject panel, MobileControlTouchpanelProperties config) : base(key, name, panel, config) public MobileControlTouchpanelController(string key, string name, BasicTriListWithSmartObject panel, MobileControlTouchpanelProperties config) : base(key, name, panel, config)
{ {
localConfig = config; localConfig = config;
@@ -139,6 +184,10 @@ namespace PepperDash.Essentials.Touchpanel
RegisterForExtenders(); RegisterForExtenders();
} }
/// <summary>
/// Updates the theme setting for this touchpanel controller and persists the change to configuration.
/// </summary>
/// <param name="theme">The new theme identifier to apply.</param>
public void UpdateTheme(string theme) public void UpdateTheme(string theme)
{ {
localConfig.Theme = theme; localConfig.Theme = theme;
@@ -271,6 +320,11 @@ namespace PepperDash.Essentials.Touchpanel
} }
} }
/// <summary>
/// Performs custom activation setup for the touchpanel controller, including
/// registering messengers and linking to mobile control.
/// </summary>
/// <returns>True if activation was successful; otherwise, false.</returns>
public override bool CustomActivate() public override bool CustomActivate()
{ {
var appMessenger = new ITswAppControlMessenger($"appControlMessenger-{Key}", $"/device/{Key}", this); var appMessenger = new ITswAppControlMessenger($"appControlMessenger-{Key}", $"/device/{Key}", this);
@@ -300,12 +354,20 @@ namespace PepperDash.Essentials.Touchpanel
return base.CustomActivate(); return base.CustomActivate();
} }
/// <summary>
/// Handles device extender signal changes for system reserved signals.
/// </summary>
/// <param name="currentDeviceExtender">The device extender that generated the signal change.</param>
/// <param name="args">The signal event arguments containing the changed signal information.</param>
protected override void ExtenderSystemReservedSigs_DeviceExtenderSigChange(DeviceExtender currentDeviceExtender, SigEventArgs args) protected override void ExtenderSystemReservedSigs_DeviceExtenderSigChange(DeviceExtender currentDeviceExtender, SigEventArgs args)
{ {
Debug.LogMessage(Serilog.Events.LogEventLevel.Verbose, this, $"System Device Extender args: ${args.Event}:${args.Sig}"); Debug.LogMessage(Serilog.Events.LogEventLevel.Verbose, this, $"System Device Extender args: ${args.Event}:${args.Sig}");
} }
/// <summary>
/// Sets up the panel drivers and signal mappings for the specified room.
/// </summary>
/// <param name="roomKey">The room key to configure the panel drivers for.</param>
protected override void SetupPanelDrivers(string roomKey) protected override void SetupPanelDrivers(string roomKey)
{ {
AppUrlFeedback.LinkInputSig(Panel.StringInput[1]); AppUrlFeedback.LinkInputSig(Panel.StringInput[1]);
@@ -366,6 +428,10 @@ namespace PepperDash.Essentials.Touchpanel
SetAppUrl(_bridge.AppUrl); SetAppUrl(_bridge.AppUrl);
} }
/// <summary>
/// Sets the application URL and updates the corresponding feedback.
/// </summary>
/// <param name="url">The new application URL to set.</param>
public void SetAppUrl(string url) public void SetAppUrl(string url)
{ {
_appUrl = url; _appUrl = url;
@@ -391,6 +457,9 @@ namespace PepperDash.Essentials.Touchpanel
} }
} }
/// <summary>
/// Hides the currently open application on the touchpanel.
/// </summary>
public void HideOpenApp() public void HideOpenApp()
{ {
if (Panel is TswX70Base x70Panel) if (Panel is TswX70Base x70Panel)
@@ -406,6 +475,9 @@ namespace PepperDash.Essentials.Touchpanel
} }
} }
/// <summary>
/// Opens an application on the touchpanel. Note: X60 panels do not support Zoom app opening.
/// </summary>
public void OpenApp() public void OpenApp()
{ {
if (Panel is TswX70Base x70Panel) if (Panel is TswX70Base x70Panel)
@@ -421,6 +493,9 @@ namespace PepperDash.Essentials.Touchpanel
} }
} }
/// <summary>
/// Closes the currently open application on the touchpanel.
/// </summary>
public void CloseOpenApp() public void CloseOpenApp()
{ {
if (Panel is TswX70Base x70Panel) if (Panel is TswX70Base x70Panel)
@@ -436,6 +511,9 @@ namespace PepperDash.Essentials.Touchpanel
} }
} }
/// <summary>
/// Ends the current Zoom call on the touchpanel.
/// </summary>
public void EndZoomCall() public void EndZoomCall()
{ {
if (Panel is TswX70Base x70Panel) if (Panel is TswX70Base x70Panel)
@@ -451,6 +529,10 @@ namespace PepperDash.Essentials.Touchpanel
} }
} }
/// <summary>
/// Updates the device information (MAC address and IP address) from the touchpanel
/// and raises the DeviceInfoChanged event.
/// </summary>
public void UpdateDeviceInfo() public void UpdateDeviceInfo()
{ {
if (Panel is TswXX70Base x70Panel) if (Panel is TswXX70Base x70Panel)
@@ -487,14 +569,27 @@ namespace PepperDash.Essentials.Touchpanel
} }
} }
/// <summary>
/// Factory class for creating MobileControlTouchpanelController instances from device configuration.
/// Supports various Crestron touchpanel models including TSW, TS, CrestronApp, XPanel, and DGE series.
/// </summary>
public class MobileControlTouchpanelControllerFactory : EssentialsPluginDeviceFactory<MobileControlTouchpanelController> public class MobileControlTouchpanelControllerFactory : EssentialsPluginDeviceFactory<MobileControlTouchpanelController>
{ {
/// <summary>
/// Initializes a new instance of the MobileControlTouchpanelControllerFactory class.
/// Sets up supported device type names and minimum framework version requirements.
/// </summary>
public MobileControlTouchpanelControllerFactory() public MobileControlTouchpanelControllerFactory()
{ {
TypeNames = new List<string>() { "mccrestronapp", "mctsw550", "mctsw750", "mctsw1050", "mctsw560", "mctsw760", "mctsw1060", "mctsw570", "mctsw770", "mcts770", "mctsw1070", "mcts1070", "mcxpanel", "mcdge1000" }; TypeNames = new List<string>() { "mccrestronapp", "mctsw550", "mctsw750", "mctsw1050", "mctsw560", "mctsw760", "mctsw1060", "mctsw570", "mctsw770", "mcts770", "mctsw1070", "mcts1070", "mcxpanel", "mcdge1000" };
MinimumEssentialsFrameworkVersion = "2.0.0"; MinimumEssentialsFrameworkVersion = "2.0.0";
} }
/// <summary>
/// Builds a MobileControlTouchpanelController device from the provided device configuration.
/// </summary>
/// <param name="dc">The device configuration containing the device properties and settings.</param>
/// <returns>A configured MobileControlTouchpanelController instance.</returns>
public override EssentialsDevice BuildDevice(DeviceConfig dc) public override EssentialsDevice BuildDevice(DeviceConfig dc)
{ {
var comm = CommFactory.GetControlPropertiesConfig(dc); var comm = CommFactory.GetControlPropertiesConfig(dc);
@@ -557,7 +652,7 @@ namespace PepperDash.Essentials.Touchpanel
return new Ts1070(id, Global.ControlSystem); return new Ts1070(id, Global.ControlSystem);
else if (type == "dge1000") else if (type == "dge1000")
return new Dge1000(id, Global.ControlSystem); return new Dge1000(id, Global.ControlSystem);
else else
{ {
Debug.LogMessage(Serilog.Events.LogEventLevel.Warning, "WARNING: Cannot create TSW controller with type '{0}'", type); Debug.LogMessage(Serilog.Events.LogEventLevel.Warning, "WARNING: Cannot create TSW controller with type '{0}'", type);

View File

@@ -1,4 +1,10 @@
using Crestron.SimplSharp; using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Text;
using Crestron.SimplSharp;
using Crestron.SimplSharp.WebScripting; using Crestron.SimplSharp.WebScripting;
using Newtonsoft.Json; using Newtonsoft.Json;
using PepperDash.Core; using PepperDash.Core;
@@ -9,12 +15,6 @@ using PepperDash.Essentials.Core.Web;
using PepperDash.Essentials.RoomBridges; using PepperDash.Essentials.RoomBridges;
using PepperDash.Essentials.WebApiHandlers; using PepperDash.Essentials.WebApiHandlers;
using Serilog.Events; using Serilog.Events;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Text;
using WebSocketSharp; using WebSocketSharp;
using WebSocketSharp.Net; using WebSocketSharp.Net;
using WebSocketSharp.Server; using WebSocketSharp.Server;
@@ -60,7 +60,7 @@ namespace PepperDash.Essentials.WebSocketServer
private string lanIpAddress => CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_ADDRESS, CrestronEthernetHelper.GetAdapterdIdForSpecifiedAdapterType(EthernetAdapterType.EthernetLANAdapter)); private string lanIpAddress => CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_ADDRESS, CrestronEthernetHelper.GetAdapterdIdForSpecifiedAdapterType(EthernetAdapterType.EthernetLANAdapter));
private System.Net.IPAddress csIpAddress; private System.Net.IPAddress csIpAddress;
private System.Net.IPAddress csSubnetMask; private System.Net.IPAddress csSubnetMask;
@@ -122,7 +122,7 @@ namespace PepperDash.Essentials.WebSocketServer
_parent = parent; _parent = parent;
// Set the default port to be 50000 plus the slot number of the program // Set the default port to be 50000 plus the slot number of the program
Port = 50000 + (int)Global.ControlSystem.ProgramNumber; Port = 50000 + (int)Global.ControlSystem.ProgramNumber;
if (customPort != 0) if (customPort != 0)
{ {
@@ -156,9 +156,9 @@ namespace PepperDash.Essentials.WebSocketServer
} }
try try
{ {
var csAdapterId = CrestronEthernetHelper.GetAdapterdIdForSpecifiedAdapterType(EthernetAdapterType.EthernetCSAdapter); var csAdapterId = CrestronEthernetHelper.GetAdapterdIdForSpecifiedAdapterType(EthernetAdapterType.EthernetCSAdapter);
var csSubnetMask = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_MASK, csAdapterId); var csSubnetMask = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_MASK, csAdapterId);
var csIpAddress = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_ADDRESS, csAdapterId); var csIpAddress = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_ADDRESS, csAdapterId);
this.csSubnetMask = System.Net.IPAddress.Parse(csSubnetMask); this.csSubnetMask = System.Net.IPAddress.Parse(csSubnetMask);
@@ -298,8 +298,6 @@ namespace PepperDash.Essentials.WebSocketServer
var processorIp = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_ADDRESS, lanAdapterId); var processorIp = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_ADDRESS, lanAdapterId);
this.LogVerbose("Processor IP: {processorIp}", processorIp);
foreach (var touchpanel in touchpanels.Select(tp => foreach (var touchpanel in touchpanels.Select(tp =>
{ {
var token = _secret.Tokens.FirstOrDefault((t) => t.Value.TouchpanelKey.Equals(tp.Key, StringComparison.InvariantCultureIgnoreCase)); var token = _secret.Tokens.FirstOrDefault((t) => t.Value.TouchpanelKey.Equals(tp.Key, StringComparison.InvariantCultureIgnoreCase));
@@ -321,11 +319,25 @@ namespace PepperDash.Essentials.WebSocketServer
continue; continue;
} }
var appUrl = $"http://{processorIp}:{_parent.Config.DirectServer.Port}/mc/app?token={touchpanel.Key}"; string ip = processorIp;
if (touchpanel.Touchpanel is IMobileControlCrestronTouchpanelController crestronTouchpanel)
{
ip = crestronTouchpanel.ConnectedIps.Any(ipInfo =>
{
if (System.Net.IPAddress.TryParse(ipInfo.DeviceIpAddress, out var parsedIp))
{
return csIpAddress.IsInSameSubnet(parsedIp, csSubnetMask);
}
this.LogWarning("Invalid IP address: {deviceIpAddress}", ipInfo.DeviceIpAddress);
return false;
}) ? csIpAddress.ToString() : processorIp;
}
var appUrl = $"http://{ip}:{_parent.Config.DirectServer.Port}/mc/app?token={touchpanel.Key}";
this.LogVerbose("Sending URL {appUrl}", appUrl); this.LogVerbose("Sending URL {appUrl}", appUrl);
touchpanel.Messenger.UpdateAppUrl($"http://{processorIp}:{_parent.Config.DirectServer.Port}/mc/app?token={touchpanel.Key}"); touchpanel.Messenger.UpdateAppUrl($"http://{ip}:{_parent.Config.DirectServer.Port}/mc/app?token={touchpanel.Key}");
} }
} }
@@ -349,7 +361,7 @@ namespace PepperDash.Essentials.WebSocketServer
if (!Directory.Exists($"{userAppPath}{localConfigFolderName}")) if (!Directory.Exists($"{userAppPath}{localConfigFolderName}"))
{ {
Directory.CreateDirectory($"{userAppPath}{localConfigFolderName}"); Directory.CreateDirectory($"{userAppPath}{localConfigFolderName}");
} }
using (var sw = new StreamWriter(File.Open($"{userAppPath}{localConfigFolderName}{Global.DirectorySeparator}{appConfigFileName}", FileMode.Create, FileAccess.ReadWrite))) using (var sw = new StreamWriter(File.Open($"{userAppPath}{localConfigFolderName}{Global.DirectorySeparator}{appConfigFileName}", FileMode.Create, FileAccess.ReadWrite)))
{ {
@@ -358,7 +370,7 @@ namespace PepperDash.Essentials.WebSocketServer
this.LogDebug("LAN Adapter ID: {lanAdapterId}", lanAdapterId); this.LogDebug("LAN Adapter ID: {lanAdapterId}", lanAdapterId);
var processorIp = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_ADDRESS, lanAdapterId); var processorIp = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_ADDRESS, lanAdapterId);
var config = GetApplicationConfig(processorIp); var config = GetApplicationConfig(processorIp);
@@ -378,7 +390,7 @@ namespace PepperDash.Essentials.WebSocketServer
return; return;
} }
if(csAdapterId == -1) if (csAdapterId == -1)
{ {
this.LogDebug("CS LAN Adapter not found"); this.LogDebug("CS LAN Adapter not found");
return; return;
@@ -389,8 +401,8 @@ namespace PepperDash.Essentials.WebSocketServer
using (var sw = new StreamWriter(File.Open($"{userAppPath}{localConfigFolderName}{Global.DirectorySeparator}{appConfigCsFileName}", FileMode.Create, FileAccess.ReadWrite))) using (var sw = new StreamWriter(File.Open($"{userAppPath}{localConfigFolderName}{Global.DirectorySeparator}{appConfigCsFileName}", FileMode.Create, FileAccess.ReadWrite)))
{ {
// Write the CS application configuration file. Used when a request comes in for the application config from the CS // Write the CS application configuration file. Used when a request comes in for the application config from the CS
var processorIp = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_ADDRESS, csAdapterId); var processorIp = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_ADDRESS, csAdapterId);
var config = GetApplicationConfig(processorIp); var config = GetApplicationConfig(processorIp);
var contents = JsonConvert.SerializeObject(config, Formatting.Indented); var contents = JsonConvert.SerializeObject(config, Formatting.Indented);
@@ -400,7 +412,7 @@ namespace PepperDash.Essentials.WebSocketServer
} }
private MobileControlApplicationConfig GetApplicationConfig(string processorIp) private MobileControlApplicationConfig GetApplicationConfig(string processorIp)
{ {
try try
{ {
var config = new MobileControlApplicationConfig var config = new MobileControlApplicationConfig
@@ -430,10 +442,10 @@ namespace PepperDash.Essentials.WebSocketServer
} }
catch (Exception ex) catch (Exception ex)
{ {
this.LogError(ex, "Error getting application configuration"); this.LogError(ex, "Error getting application configuration");
return null; return null;
} }
} }
/// <summary> /// <summary>
@@ -572,7 +584,7 @@ namespace PepperDash.Essentials.WebSocketServer
var values = s.Split(' '); var values = s.Split(' ');
if(values.Length < 2) if (values.Length < 2)
{ {
CrestronConsole.ConsoleCommandResponse("Invalid number of arguments. Please provide a room key and a grant code"); CrestronConsole.ConsoleCommandResponse("Invalid number of arguments. Please provide a room key and a grant code");
return; return;