diff --git a/CHANGELOG.md b/CHANGELOG.md index c7d31a1..8f8b2ab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ### Changed - Network/MAC/DNS address utils are now enumerating all adapter types + - Ignoring Crestron ethernet parameters that say "Invalid Value" ## [10.2.0] - 2019-12-04 ### Added diff --git a/ICD.Common.Utils/IcdEnvironment.SimplSharp.cs b/ICD.Common.Utils/IcdEnvironment.SimplSharp.cs index 70a1caa..3d156f8 100644 --- a/ICD.Common.Utils/IcdEnvironment.SimplSharp.cs +++ b/ICD.Common.Utils/IcdEnvironment.SimplSharp.cs @@ -1,14 +1,19 @@ -using ICD.Common.Utils.Extensions; -#if SIMPLSHARP +#if SIMPLSHARP using System; using System.Collections.Generic; using Crestron.SimplSharp; using ICD.Common.Properties; +using ICD.Common.Utils.Extensions; namespace ICD.Common.Utils { public static partial class IcdEnvironment { + /// + /// For some reason crestron returns "Invalid Value" for ethernet parameters sometimes :/ + /// + private const string INVALID_VALUE = "Invalid Value"; + #region Properties public static string NewLine { get { return CrestronEnvironment.NewLine; } } @@ -48,7 +53,7 @@ namespace ICD.Common.Utils continue; } - if (!string.IsNullOrEmpty(address)) + if (!string.IsNullOrEmpty(address) && !address.Equals(INVALID_VALUE)) yield return address; } } @@ -79,7 +84,7 @@ namespace ICD.Common.Utils continue; } - if (!string.IsNullOrEmpty(macAddress)) + if (!string.IsNullOrEmpty(macAddress) && !macAddress.Equals(INVALID_VALUE)) yield return macAddress; } } @@ -100,7 +105,12 @@ namespace ICD.Common.Utils try { short id = CrestronEthernetHelper.GetAdapterdIdForSpecifiedAdapterType(type); - return CrestronEthernetHelper.GetEthernetParameter(param, id); + string status = CrestronEthernetHelper.GetEthernetParameter(param, id); + + if (!string.IsNullOrEmpty(status) && !status.Equals(INVALID_VALUE)) + return status; + + return null; } catch (ArgumentException) { @@ -134,7 +144,7 @@ namespace ICD.Common.Utils continue; } - if (!string.IsNullOrEmpty(hostname)) + if (!string.IsNullOrEmpty(hostname) && !hostname.Equals(INVALID_VALUE)) yield return hostname; } }