diff --git a/src/PepperDash.Essentials.MobileControl/Touchpanel/MobileControlTouchpanelController.AppControl.cs b/src/PepperDash.Essentials.MobileControl/Touchpanel/MobileControlTouchpanelController.AppControl.cs
new file mode 100644
index 00000000..7556f8d2
--- /dev/null
+++ b/src/PepperDash.Essentials.MobileControl/Touchpanel/MobileControlTouchpanelController.AppControl.cs
@@ -0,0 +1,76 @@
+using Crestron.SimplSharpPro.UI;
+using PepperDash.Core;
+using PepperDash.Core.Logging;
+
+namespace PepperDash.Essentials.Touchpanel
+{
+ ///
+ /// Partial class containing app control functionality for managing applications on the touchpanel.
+ ///
+ public partial class MobileControlTouchpanelController
+ {
+ ///
+ /// Sets the application URL for mobile control access.
+ ///
+ /// The URL to set for the mobile control application.
+ public void SetAppUrl(string url)
+ {
+ _appUrl = GetUrlWithCorrectIp(url);
+ AppUrlFeedback.FireUpdate();
+ }
+
+ ///
+ /// Hides the currently open application on the touchpanel.
+ ///
+ public void HideOpenApp()
+ {
+ if (Panel is TswX70Base x70Panel)
+ {
+ x70Panel.ExtenderApplicationControlReservedSigs.HideOpenedApplication();
+ return;
+ }
+
+ if (Panel is TswX60BaseClass x60Panel)
+ {
+ x60Panel.ExtenderApplicationControlReservedSigs.HideOpenApplication();
+ return;
+ }
+ }
+
+ ///
+ /// Opens an application on the touchpanel.
+ ///
+ public void OpenApp()
+ {
+ if (Panel is TswX70Base x70Panel)
+ {
+ x70Panel.ExtenderApplicationControlReservedSigs.OpenApplication();
+ return;
+ }
+
+ if (Panel is TswX60WithZoomRoomAppReservedSigs)
+ {
+ Debug.LogMessage(Serilog.Events.LogEventLevel.Information, this, $"X60 panel does not support zoom app");
+ return;
+ }
+ }
+
+ ///
+ /// Closes the currently open application on the touchpanel.
+ ///
+ public void CloseOpenApp()
+ {
+ if (Panel is TswX70Base x70Panel)
+ {
+ x70Panel.ExtenderApplicationControlReservedSigs.CloseOpenedApplication();
+ return;
+ }
+
+ if (Panel is TswX60WithZoomRoomAppReservedSigs x60Panel)
+ {
+ x60Panel.ExtenderApplicationControlReservedSigs.CloseOpenedApplication();
+ return;
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/PepperDash.Essentials.MobileControl/Touchpanel/MobileControlTouchpanelController.DeviceInfo.cs b/src/PepperDash.Essentials.MobileControl/Touchpanel/MobileControlTouchpanelController.DeviceInfo.cs
new file mode 100644
index 00000000..bb7d5576
--- /dev/null
+++ b/src/PepperDash.Essentials.MobileControl/Touchpanel/MobileControlTouchpanelController.DeviceInfo.cs
@@ -0,0 +1,142 @@
+using System;
+using System.Linq;
+using System.Text.RegularExpressions;
+using Crestron.SimplSharp;
+using Crestron.SimplSharpPro;
+using Crestron.SimplSharpPro.UI;
+using PepperDash.Core;
+using PepperDash.Core.Logging;
+using PepperDash.Essentials.Core;
+using PepperDash.Essentials.Core.DeviceInfo;
+
+namespace PepperDash.Essentials.Touchpanel
+{
+ ///
+ /// Partial class containing device information, IP address handling, and network configuration functionality.
+ ///
+ public partial class MobileControlTouchpanelController
+ {
+ ///
+ /// Updates device information including MAC address and IP address from panel extenders.
+ ///
+ public void UpdateDeviceInfo()
+ {
+ if (Panel is TswXX70Base x70Panel)
+ {
+ DeviceInfo.MacAddress = x70Panel.ExtenderEthernetReservedSigs.MacAddressFeedback.StringValue;
+ DeviceInfo.IpAddress = x70Panel.ExtenderEthernetReservedSigs.IpAddressFeedback.StringValue;
+
+ var handler = DeviceInfoChanged;
+
+ if (handler == null)
+ {
+ return;
+ }
+
+ handler(this, new DeviceInfoEventArgs(DeviceInfo));
+ }
+
+ if (Panel is TswX60WithZoomRoomAppReservedSigs x60Panel)
+ {
+ DeviceInfo.MacAddress = x60Panel.ExtenderEthernetReservedSigs.MacAddressFeedback.StringValue;
+ DeviceInfo.IpAddress = x60Panel.ExtenderEthernetReservedSigs.IpAddressFeedback.StringValue;
+
+ var handler = DeviceInfoChanged;
+
+ if (handler == null)
+ {
+ return;
+ }
+
+ handler(this, new DeviceInfoEventArgs(DeviceInfo));
+ }
+
+ Debug.LogMessage(Serilog.Events.LogEventLevel.Debug, this, $"MAC: {DeviceInfo.MacAddress} IP: {DeviceInfo.IpAddress}");
+ }
+
+ ///
+ /// Gets the URL with the correct IP address based on the connected devices and the Crestron processor's IP address.
+ ///
+ /// The original URL to process.
+ /// The URL with the correct IP address for the panel's network connection.
+ private string GetUrlWithCorrectIp(string url)
+ {
+ var lanAdapterId = CrestronEthernetHelper.GetAdapterdIdForSpecifiedAdapterType(EthernetAdapterType.EthernetLANAdapter);
+
+ var processorIp = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_ADDRESS, lanAdapterId);
+
+ if (csIpAddress == null || csSubnetMask == null || url == null)
+ {
+ this.LogWarning("CS IP Address Subnet Mask or url is null, cannot determine correct IP for URL");
+ return url;
+ }
+
+ this.LogVerbose("Processor IP: {processorIp}, CS IP: {csIpAddress}, CS Subnet Mask: {csSubnetMask}", processorIp, csIpAddress, csSubnetMask);
+ this.LogVerbose("Connected IP Count: {connectedIps}", ConnectedIps.Count);
+
+ var ip = ConnectedIps.Any(ipInfo =>
+ {
+ if (System.Net.IPAddress.TryParse(ipInfo.DeviceIpAddress, out var parsedIp))
+ {
+ return parsedIp.IsInSameSubnet(csIpAddress, csSubnetMask);
+ }
+ this.LogWarning("Invalid IP address: {deviceIpAddress}", ipInfo.DeviceIpAddress);
+ return false;
+ }) ? csIpAddress.ToString() : processorIp;
+
+ var match = Regex.Match(url, @"^http://([^:/]+):\d+/mc/app\?token=.+$");
+ if (match.Success)
+ {
+ string ipa = match.Groups[1].Value;
+ // ip will be "192.168.1.100"
+ }
+
+ // replace ipa with ip but leave the rest of the string intact
+ var updatedUrl = Regex.Replace(url, @"^http://[^:/]+", $"http://{ip}");
+
+ this.LogVerbose("Updated URL: {updatedUrl}", updatedUrl);
+
+ return updatedUrl;
+ }
+
+ ///
+ /// Subscribes to mobile control updates and bridge events for feedback updates.
+ ///
+ private void SubscribeForMobileControlUpdates()
+ {
+ foreach (var dev in DeviceManager.AllDevices)
+ {
+ Debug.LogMessage(Serilog.Events.LogEventLevel.Information, this, $"{dev.Key}:{dev.GetType().Name}");
+ }
+
+ var mcList = DeviceManager.AllDevices.OfType().ToList();
+
+ if (mcList.Count == 0)
+ {
+ Debug.LogMessage(Serilog.Events.LogEventLevel.Information, this, $"No Mobile Control controller found");
+ return;
+ }
+
+ // use first in list, since there should only be one.
+ var mc = mcList[0];
+
+ var bridge = mc.GetRoomBridge(_config.DefaultRoomKey);
+
+ if (bridge == null)
+ {
+ 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) =>
+ {
+ SetAppUrl(_bridge.AppUrl);
+ };
+
+ UpdateFeedbacks();
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/PepperDash.Essentials.MobileControl/Touchpanel/MobileControlTouchpanelController.PanelExtenders.cs b/src/PepperDash.Essentials.MobileControl/Touchpanel/MobileControlTouchpanelController.PanelExtenders.cs
new file mode 100644
index 00000000..5c3b2f42
--- /dev/null
+++ b/src/PepperDash.Essentials.MobileControl/Touchpanel/MobileControlTouchpanelController.PanelExtenders.cs
@@ -0,0 +1,160 @@
+using System;
+using Crestron.SimplSharpPro.UI;
+using PepperDash.Core;
+using PepperDash.Core.Logging;
+using PepperDash.Essentials.Core.DeviceInfo;
+
+namespace PepperDash.Essentials.Touchpanel
+{
+ ///
+ /// Partial class containing panel extender registration and event handling functionality.
+ ///
+ public partial class MobileControlTouchpanelController
+ {
+ ///
+ /// Registers for extender signals based on the panel type and sets up event handlers
+ /// for app control, Zoom room, and Ethernet functionality.
+ ///
+ private void RegisterForExtenders()
+ {
+ if (Panel is TswXX70Base x70Panel)
+ {
+ RegisterX70PanelExtenders(x70Panel);
+ return;
+ }
+
+ if (Panel is TswX60WithZoomRoomAppReservedSigs x60withZoomApp)
+ {
+ RegisterX60PanelExtenders(x60withZoomApp);
+ }
+ }
+
+ ///
+ /// Registers extender signals and event handlers for TSW X70 series panels.
+ ///
+ /// The X70 panel to register extenders for.
+ private void RegisterX70PanelExtenders(TswXX70Base x70Panel)
+ {
+ // App Control Extender
+ 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)
+ {
+ x70Panel.ExtenderButtonToolbarReservedSigs.ShowButtonToolbar();
+ x70Panel.ExtenderButtonToolbarReservedSigs.Button2On();
+ }
+ else
+ {
+ x70Panel.ExtenderButtonToolbarReservedSigs.HideButtonToolbar();
+ x70Panel.ExtenderButtonToolbarReservedSigs.Button2Off();
+ }
+ };
+
+ // Zoom Room App Extender
+ x70Panel.ExtenderZoomRoomAppReservedSigs.DeviceExtenderSigChange += (e, a) =>
+ {
+ Debug.LogMessage(Serilog.Events.LogEventLevel.Verbose, this, $"X70 Zoom Room App Device Extender args: {a.Event}:{a.Sig}:{a.Sig.Type}:{a.Sig.BoolValue}:{a.Sig.UShortValue}:{a.Sig.StringValue}");
+
+ if (a.Sig.Number == x70Panel.ExtenderZoomRoomAppReservedSigs.ZoomRoomIncomingCallFeedback.Number)
+ {
+ ZoomIncomingCallFeedback.FireUpdate();
+ }
+ else if (a.Sig.Number == x70Panel.ExtenderZoomRoomAppReservedSigs.ZoomRoomActiveFeedback.Number)
+ {
+ ZoomInCallFeedback.FireUpdate();
+ }
+ };
+
+ // Ethernet Extender
+ x70Panel.ExtenderEthernetReservedSigs.DeviceExtenderSigChange += (e, a) =>
+ {
+ DeviceInfo.MacAddress = x70Panel.ExtenderEthernetReservedSigs.MacAddressFeedback.StringValue;
+ DeviceInfo.IpAddress = x70Panel.ExtenderEthernetReservedSigs.IpAddressFeedback.StringValue;
+
+ Debug.LogMessage(Serilog.Events.LogEventLevel.Debug, this, $"MAC: {DeviceInfo.MacAddress} IP: {DeviceInfo.IpAddress}");
+
+ var handler = DeviceInfoChanged;
+
+ if (handler == null)
+ {
+ return;
+ }
+
+ handler(this, new DeviceInfoEventArgs(DeviceInfo));
+ };
+
+ // Initialize extenders
+ x70Panel.ExtenderApplicationControlReservedSigs.Use();
+ x70Panel.ExtenderZoomRoomAppReservedSigs.Use();
+ x70Panel.ExtenderEthernetReservedSigs.Use();
+ x70Panel.ExtenderButtonToolbarReservedSigs.Use();
+
+ // Initialize button toolbar
+ x70Panel.ExtenderButtonToolbarReservedSigs.Button1Off();
+ x70Panel.ExtenderButtonToolbarReservedSigs.Button3Off();
+ x70Panel.ExtenderButtonToolbarReservedSigs.Button4Off();
+ x70Panel.ExtenderButtonToolbarReservedSigs.Button5Off();
+ x70Panel.ExtenderButtonToolbarReservedSigs.Button6Off();
+ }
+
+ ///
+ /// Registers extender signals and event handlers for TSW X60 series panels with Zoom room app support.
+ ///
+ /// The X60 panel with Zoom room app to register extenders for.
+ private void RegisterX60PanelExtenders(TswX60WithZoomRoomAppReservedSigs x60withZoomApp)
+ {
+ // App Control Extender
+ 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}");
+
+ if (a.Sig.Number == x60withZoomApp.ExtenderApplicationControlReservedSigs.HideOpenApplicationFeedback.Number)
+ {
+ AppOpenFeedback.FireUpdate();
+ }
+ };
+
+ // Zoom Room App Extender
+ 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}");
+
+ if (a.Sig.Number == x60withZoomApp.ExtenderZoomRoomAppReservedSigs.ZoomRoomIncomingCallFeedback.Number)
+ {
+ ZoomIncomingCallFeedback.FireUpdate();
+ }
+ else if (a.Sig.Number == x60withZoomApp.ExtenderZoomRoomAppReservedSigs.ZoomRoomActiveFeedback.Number)
+ {
+ ZoomInCallFeedback.FireUpdate();
+ }
+ };
+
+ // Ethernet Extender
+ x60withZoomApp.ExtenderEthernetReservedSigs.DeviceExtenderSigChange += (e, a) =>
+ {
+ DeviceInfo.MacAddress = x60withZoomApp.ExtenderEthernetReservedSigs.MacAddressFeedback.StringValue;
+ DeviceInfo.IpAddress = x60withZoomApp.ExtenderEthernetReservedSigs.IpAddressFeedback.StringValue;
+
+ Debug.LogMessage(Serilog.Events.LogEventLevel.Debug, this, $"MAC: {DeviceInfo.MacAddress} IP: {DeviceInfo.IpAddress}");
+
+ var handler = DeviceInfoChanged;
+
+ if (handler == null)
+ {
+ return;
+ }
+
+ handler(this, new DeviceInfoEventArgs(DeviceInfo));
+ };
+
+ // Initialize extenders
+ x60withZoomApp.ExtenderZoomRoomAppReservedSigs.Use();
+ x60withZoomApp.ExtenderApplicationControlReservedSigs.Use();
+ x60withZoomApp.ExtenderEthernetReservedSigs.Use();
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/PepperDash.Essentials.MobileControl/Touchpanel/MobileControlTouchpanelController.ZoomIntegration.cs b/src/PepperDash.Essentials.MobileControl/Touchpanel/MobileControlTouchpanelController.ZoomIntegration.cs
new file mode 100644
index 00000000..20e2191f
--- /dev/null
+++ b/src/PepperDash.Essentials.MobileControl/Touchpanel/MobileControlTouchpanelController.ZoomIntegration.cs
@@ -0,0 +1,42 @@
+using Crestron.SimplSharpPro.UI;
+using PepperDash.Core;
+using PepperDash.Core.Logging;
+
+namespace PepperDash.Essentials.Touchpanel
+{
+ ///
+ /// Partial class containing Zoom integration functionality for managing Zoom calls and room control.
+ ///
+ public partial class MobileControlTouchpanelController
+ {
+ ///
+ /// Updates all Zoom-related feedback values to reflect current state.
+ ///
+ private void UpdateZoomFeedbacks()
+ {
+ foreach (var feedback in ZoomFeedbacks)
+ {
+ Debug.LogMessage(Serilog.Events.LogEventLevel.Debug, this, $"Updating {feedback.Key}");
+ feedback.FireUpdate();
+ }
+ }
+
+ ///
+ /// Ends the current Zoom call on the touchpanel.
+ ///
+ public void EndZoomCall()
+ {
+ if (Panel is TswX70Base x70Panel)
+ {
+ x70Panel.ExtenderZoomRoomAppReservedSigs.ZoomRoomEndCall();
+ return;
+ }
+
+ if (Panel is TswX60WithZoomRoomAppReservedSigs x60Panel)
+ {
+ x60Panel.ExtenderZoomRoomAppReservedSigs.ZoomRoomEndCall();
+ return;
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/PepperDash.Essentials.MobileControl/Touchpanel/MobileControlTouchpanelController.cs b/src/PepperDash.Essentials.MobileControl/Touchpanel/MobileControlTouchpanelController.cs
index a660b8b9..4995456a 100644
--- a/src/PepperDash.Essentials.MobileControl/Touchpanel/MobileControlTouchpanelController.cs
+++ b/src/PepperDash.Essentials.MobileControl/Touchpanel/MobileControlTouchpanelController.cs
@@ -23,8 +23,9 @@ namespace PepperDash.Essentials.Touchpanel
///
/// Mobile Control touchpanel controller that provides app control, Zoom integration,
/// and mobile control functionality for Crestron touchpanels.
+ /// This is the main partial class containing core properties, constructor, and basic functionality.
///
- public class MobileControlTouchpanelController : TouchpanelBase, IHasFeedback, ITswAppControl, ITswZoomControl, IDeviceInfoProvider, IMobileControlCrestronTouchpanelController, ITheme
+ public partial class MobileControlTouchpanelController : TouchpanelBase, IHasFeedback, ITswAppControl, ITswZoomControl, IDeviceInfoProvider, IMobileControlCrestronTouchpanelController, ITheme
{
private readonly MobileControlTouchpanelProperties localConfig;
private IMobileControlRoomMessenger _bridge;
@@ -233,123 +234,6 @@ namespace PepperDash.Essentials.Touchpanel
ConfigWriter.UpdateDeviceConfig(deviceConfig);
}
- 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)
- {
- x70Panel.ExtenderButtonToolbarReservedSigs.ShowButtonToolbar();
- x70Panel.ExtenderButtonToolbarReservedSigs.Button2On();
- }
- else
- {
- x70Panel.ExtenderButtonToolbarReservedSigs.HideButtonToolbar();
- x70Panel.ExtenderButtonToolbarReservedSigs.Button2Off();
- }
- };
-
-
- 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}");
-
- if (a.Sig.Number == x70Panel.ExtenderZoomRoomAppReservedSigs.ZoomRoomIncomingCallFeedback.Number)
- {
- ZoomIncomingCallFeedback.FireUpdate();
- }
- else if (a.Sig.Number == x70Panel.ExtenderZoomRoomAppReservedSigs.ZoomRoomActiveFeedback.Number)
- {
- ZoomInCallFeedback.FireUpdate();
- }
- };
-
-
- x70Panel.ExtenderEthernetReservedSigs.DeviceExtenderSigChange += (e, a) =>
- {
- DeviceInfo.MacAddress = x70Panel.ExtenderEthernetReservedSigs.MacAddressFeedback.StringValue;
- DeviceInfo.IpAddress = x70Panel.ExtenderEthernetReservedSigs.IpAddressFeedback.StringValue;
-
- Debug.LogMessage(Serilog.Events.LogEventLevel.Debug, this, $"MAC: {DeviceInfo.MacAddress} IP: {DeviceInfo.IpAddress}");
-
- var handler = DeviceInfoChanged;
-
- if (handler == null)
- {
- return;
- }
-
- handler(this, new DeviceInfoEventArgs(DeviceInfo));
- };
-
- x70Panel.ExtenderApplicationControlReservedSigs.Use();
- x70Panel.ExtenderZoomRoomAppReservedSigs.Use();
- x70Panel.ExtenderEthernetReservedSigs.Use();
- x70Panel.ExtenderButtonToolbarReservedSigs.Use();
-
- x70Panel.ExtenderButtonToolbarReservedSigs.Button1Off();
- x70Panel.ExtenderButtonToolbarReservedSigs.Button3Off();
- x70Panel.ExtenderButtonToolbarReservedSigs.Button4Off();
- x70Panel.ExtenderButtonToolbarReservedSigs.Button5Off();
- x70Panel.ExtenderButtonToolbarReservedSigs.Button6Off();
-
- return;
- }
-
- if (Panel is TswX60WithZoomRoomAppReservedSigs x60withZoomApp)
- {
- 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}");
-
- 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}");
-
- 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) =>
- {
- DeviceInfo.MacAddress = x60withZoomApp.ExtenderEthernetReservedSigs.MacAddressFeedback.StringValue;
- DeviceInfo.IpAddress = x60withZoomApp.ExtenderEthernetReservedSigs.IpAddressFeedback.StringValue;
-
- Debug.LogMessage(Serilog.Events.LogEventLevel.Debug, this, $"MAC: {DeviceInfo.MacAddress} IP: {DeviceInfo.IpAddress}");
-
- var handler = DeviceInfoChanged;
-
- if (handler == null)
- {
- return;
- }
-
- handler(this, new DeviceInfoEventArgs(DeviceInfo));
- };
-
- x60withZoomApp.ExtenderZoomRoomAppReservedSigs.Use();
- x60withZoomApp.ExtenderApplicationControlReservedSigs.Use();
- x60withZoomApp.ExtenderEthernetReservedSigs.Use();
- }
- }
-
///
/// Performs custom activation setup for the touchpanel controller, including
/// registering messengers and linking to mobile control.
@@ -439,232 +323,26 @@ namespace PepperDash.Essentials.Touchpanel
}
///
- /// Gets the URL with the correct IP address based on the connected devices and the Crestron processor's IP address.
+ /// Updates feedbacks in response to state changes.
///
- ///
- ///
- private string GetUrlWithCorrectIp(string url)
- {
- var lanAdapterId = CrestronEthernetHelper.GetAdapterdIdForSpecifiedAdapterType(EthernetAdapterType.EthernetLANAdapter);
-
- var processorIp = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_ADDRESS, lanAdapterId);
-
- if (csIpAddress == null || csSubnetMask == null || url == null)
- {
- this.LogWarning("CS IP Address Subnet Mask or url is null, cannot determine correct IP for URL");
- return url;
- }
-
- this.LogVerbose("Processor IP: {processorIp}, CS IP: {csIpAddress}, CS Subnet Mask: {csSubnetMask}", processorIp, csIpAddress, csSubnetMask);
- this.LogVerbose("Connected IP Count: {connectedIps}", ConnectedIps.Count);
-
- var ip = 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 match = Regex.Match(url, @"^http://([^:/]+):\d+/mc/app\?token=.+$");
- if (match.Success)
- {
- string ipa = match.Groups[1].Value;
- // ip will be "192.168.1.100"
- }
-
- // replace ipa with ip but leave the rest of the string intact
- var updatedUrl = Regex.Replace(url, @"^http://[^:/]+", $"http://{ip}");
-
- this.LogVerbose("Updated URL: {updatedUrl}", updatedUrl);
-
- return updatedUrl;
- }
-
- private void SubscribeForMobileControlUpdates()
- {
- foreach (var dev in DeviceManager.AllDevices)
- {
- Debug.LogMessage(Serilog.Events.LogEventLevel.Information, this, $"{dev.Key}:{dev.GetType().Name}");
- }
-
- var mcList = DeviceManager.AllDevices.OfType().ToList();
-
- if (mcList.Count == 0)
- {
- Debug.LogMessage(Serilog.Events.LogEventLevel.Information, this, $"No Mobile Control controller found");
-
- return;
- }
-
- // use first in list, since there should only be one.
- var mc = mcList[0];
-
- var bridge = mc.GetRoomBridge(_config.DefaultRoomKey);
-
- if (bridge == null)
- {
- 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) =>
- {
- this.LogInformation("AppURL changed");
- SetAppUrl(_bridge.AppUrl);
- UpdateFeedbacks(s, a);
- };
-
- SetAppUrl(_bridge.AppUrl);
- }
-
- ///
- /// Sets the application URL and updates the corresponding feedback.
- ///
- /// The new application URL to set.
- ///
- /// SetAppUrl method
- ///
- public void SetAppUrl(string url)
- {
- _appUrl = GetUrlWithCorrectIp(url);
-
- AppUrlFeedback.FireUpdate();
- }
-
+ /// The event sender.
+ /// The event arguments.
private void UpdateFeedbacks(object sender, EventArgs args)
{
UpdateFeedbacks();
}
+ ///
+ /// Updates all feedback values to reflect current state.
+ ///
private void UpdateFeedbacks()
{
- foreach (var feedback in Feedbacks) { this.LogDebug("Updating {feedbackKey}", feedback.Key); feedback.FireUpdate(); }
- }
-
- private void UpdateZoomFeedbacks()
- {
- foreach (var feedback in ZoomFeedbacks)
+ foreach (var feedback in Feedbacks)
{
- Debug.LogMessage(Serilog.Events.LogEventLevel.Debug, this, $"Updating {feedback.Key}");
+ this.LogDebug("Updating {feedbackKey}", feedback.Key);
feedback.FireUpdate();
}
}
-
- ///
- /// HideOpenApp method
- ///
- public void HideOpenApp()
- {
- if (Panel is TswX70Base x70Panel)
- {
- x70Panel.ExtenderApplicationControlReservedSigs.HideOpenedApplication();
- return;
- }
-
- if (Panel is TswX60BaseClass x60Panel)
- {
- x60Panel.ExtenderApplicationControlReservedSigs.HideOpenApplication();
- return;
- }
- }
-
- ///
- /// OpenApp method
- ///
- public void OpenApp()
- {
- if (Panel is TswX70Base x70Panel)
- {
- x70Panel.ExtenderApplicationControlReservedSigs.OpenApplication();
- return;
- }
-
- if (Panel is TswX60WithZoomRoomAppReservedSigs)
- {
- Debug.LogMessage(Serilog.Events.LogEventLevel.Information, this, $"X60 panel does not support zoom app");
- return;
- }
- }
-
- ///
- /// CloseOpenApp method
- ///
- public void CloseOpenApp()
- {
- if (Panel is TswX70Base x70Panel)
- {
- x70Panel.ExtenderApplicationControlReservedSigs.CloseOpenedApplication();
- return;
- }
-
- if (Panel is TswX60WithZoomRoomAppReservedSigs x60Panel)
- {
- x60Panel.ExtenderApplicationControlReservedSigs.CloseOpenedApplication();
- return;
- }
- }
-
- ///
- /// EndZoomCall method
- ///
- public void EndZoomCall()
- {
- if (Panel is TswX70Base x70Panel)
- {
- x70Panel.ExtenderZoomRoomAppReservedSigs.ZoomRoomEndCall();
- return;
- }
-
- if (Panel is TswX60WithZoomRoomAppReservedSigs x60Panel)
- {
- x60Panel.ExtenderZoomRoomAppReservedSigs.ZoomRoomEndCall();
- return;
- }
- }
-
- ///
- /// UpdateDeviceInfo method
- ///
- public void UpdateDeviceInfo()
- {
- if (Panel is TswXX70Base x70Panel)
- {
- DeviceInfo.MacAddress = x70Panel.ExtenderEthernetReservedSigs.MacAddressFeedback.StringValue;
- DeviceInfo.IpAddress = x70Panel.ExtenderEthernetReservedSigs.IpAddressFeedback.StringValue;
-
- var handler = DeviceInfoChanged;
-
- if (handler == null)
- {
- return;
- }
-
- handler(this, new DeviceInfoEventArgs(DeviceInfo));
- }
-
- if (Panel is TswX60WithZoomRoomAppReservedSigs x60Panel)
- {
- DeviceInfo.MacAddress = x60Panel.ExtenderEthernetReservedSigs.MacAddressFeedback.StringValue;
- DeviceInfo.IpAddress = x60Panel.ExtenderEthernetReservedSigs.IpAddressFeedback.StringValue;
-
- var handler = DeviceInfoChanged;
-
- if (handler == null)
- {
- return;
- }
-
- handler(this, new DeviceInfoEventArgs(DeviceInfo));
- }
-
- Debug.LogMessage(Serilog.Events.LogEventLevel.Debug, this, $"MAC: {DeviceInfo.MacAddress} IP: {DeviceInfo.IpAddress}");
- }
}
///