Skip to content

Commit dd32f44

Browse files
ndorinCopilot
andcommitted
fix: clean up unused using directives and add firmware version check in ControlSystem
Co-authored-by: Copilot <copilot@github.com>
1 parent ba48f23 commit dd32f44

3 files changed

Lines changed: 25 additions & 4 deletions

File tree

src/PepperDash.Core/Logging/Debug.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
using System;
1+
using System;
22
using System.Collections.Generic;
3-
using System.Net;
43
using System.Reflection;
54
using System.Text.RegularExpressions;
65
using Crestron.SimplSharp;

src/PepperDash.Core/Logging/DebugWebsocketSink.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,10 @@ public string Url
5151
if (service == null) return "";
5252

5353
// Use CSLAN IP if available, otherwise fallback to primary IP. This ensures we provide a reachable URL in dual-stack environments.
54-
if (!string.IsNullOrEmpty(CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_ADDRESS, 1)))
55-
return $"wss://{CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_ADDRESS, 1)}:{_httpsServer.Port}{service.Path}";
54+
var cslanIp = CrestronEthernetHelper.GetEthernetParameter(
55+
CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_ADDRESS, 1);
56+
if (!string.IsNullOrEmpty(cslanIp) && cslanIp != "Invalid Value")
57+
return $"wss://{cslanIp}:{_httpsServer.Port}{service.Path}";
5658
else
5759
return $"wss://{CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_ADDRESS, 0)}:{_httpsServer.Port}{service.Path}";
5860
}

src/PepperDash.Essentials/ControlSystem.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ public class ControlSystem : CrestronControlSystem, ILoadConfig
2727
private CEvent _initializeEvent;
2828
private const long StartupTime = 500;
2929

30+
private const string minimumFirmwareVersion = "2.8006.00110";
31+
3032
/// <summary>
3133
/// Initializes a new instance of the ControlSystem class
3234
/// </summary>
@@ -46,6 +48,24 @@ public ControlSystem()
4648
/// <inheritdoc />
4749
public override void InitializeSystem()
4850
{
51+
52+
// Get FW version and stop if it's too low to run this version of Essentials. Must be greater than v2.8006.00110
53+
var fwVersion = InitialParametersClass.FirmwareVersion;
54+
55+
Debug.LogInformation("Control System Hardware Version: {fwVersion}", fwVersion);
56+
57+
// split the version into parts and compare against minimumFirmwareVersion
58+
var versionParts = fwVersion.Split('.').Select(int.Parse).ToArray();
59+
var minParts = minimumFirmwareVersion.Split('.').Select(int.Parse).ToArray();
60+
if (versionParts.Length < minParts.Length
61+
|| versionParts[0] < minParts[0]
62+
|| (versionParts[0] == minParts[0] && versionParts[1] < minParts[1])
63+
|| (versionParts[0] == minParts[0] && versionParts[1] == minParts[1] && versionParts[2] <= minParts[2]))
64+
{
65+
Debug.LogFatal("Firmware version {fwVersion} is too low to run this version of Essentials. Please upgrade to greater than v{minimumFirmwareVersion}.", fwVersion, minimumFirmwareVersion);
66+
return;
67+
}
68+
4969
// If the control system is a DMPS type, we need to wait to exit this method until all devices have had time to activate
5070
// to allow any HD-BaseT DM endpoints to register first.
5171
bool preventInitializationComplete = Global.ControlSystemIsDmpsType;

0 commit comments

Comments
 (0)