Merge remote-tracking branch 'origin/ConnectPro_v1.5' into ConnectPro_v1.6

# Conflicts:
#	ICD.Common.Utils/Properties/AssemblyInfo.cs
This commit is contained in:
Chris Cameron
2020-01-21 11:15:18 -05:00
3 changed files with 77 additions and 83 deletions

View File

@@ -5,8 +5,6 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
## [Unreleased] ## [Unreleased]
### Added
- Added public access to GetValues enumeration extension
### Added ### Added
- Added Not null tag for ICDUriBuilder Constructor that takes a URI as an argument. - Added Not null tag for ICDUriBuilder Constructor that takes a URI as an argument.
@@ -17,6 +15,13 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Added methods for serializing an XML array - Added methods for serializing an XML array
- Added WriteAllByte method on IcdFile. - Added WriteAllByte method on IcdFile.
- Added PathUtils for building paths in the HTML directory - Added PathUtils for building paths in the HTML directory
- Added public access to GetValues enumeration extension
## [10.3.0] - 2020-01-20
### Changed
- Network/MAC/DNS address utils are now enumerating all adapter types
- Ignoring Crestron ethernet parameters that say "Invalid Value"
- Skipping network interfaces with an invalid adapter id
## [10.2.0] - 2019-12-04 ## [10.2.0] - 2019-12-04
### Added ### Added

View File

@@ -1,14 +1,21 @@
using ICD.Common.Utils.Extensions; #if SIMPLSHARP
#if SIMPLSHARP
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using Crestron.SimplSharp; using Crestron.SimplSharp;
using ICD.Common.Properties; using ICD.Common.Properties;
using ICD.Common.Utils.Extensions;
namespace ICD.Common.Utils namespace ICD.Common.Utils
{ {
public static partial class IcdEnvironment public static partial class IcdEnvironment
{ {
/// <summary>
/// For some reason crestron returns "Invalid Value" for ethernet parameters sometimes :/
/// </summary>
private const string INVALID_VALUE = "Invalid Value";
#region Properties
public static string NewLine { get { return CrestronEnvironment.NewLine; } } public static string NewLine { get { return CrestronEnvironment.NewLine; } }
public static eRuntimeEnvironment RuntimeEnvironment public static eRuntimeEnvironment RuntimeEnvironment
@@ -31,36 +38,27 @@ namespace ICD.Common.Utils
{ {
const CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET param = const CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET param =
CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_ADDRESS; CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_ADDRESS;
const EthernetAdapterType primaryType = EthernetAdapterType.EthernetLANAdapter;
const EthernetAdapterType secondaryType = EthernetAdapterType.EthernetLAN2Adapter;
string address1 = null; foreach (EthernetAdapterType type in EnumUtils.GetValuesExceptNone<EthernetAdapterType>())
try
{ {
short id = CrestronEthernetHelper.GetAdapterdIdForSpecifiedAdapterType(primaryType); string address;
address1 = CrestronEthernetHelper.GetEthernetParameter(param, id);
}
catch (ArgumentException)
{
}
if (!string.IsNullOrEmpty(address1))
yield return address1;
string address2 = null; try
{
short id = CrestronEthernetHelper.GetAdapterdIdForSpecifiedAdapterType(type);
if (id >= InitialParametersClass.NumberOfEthernetInterfaces)
continue;
try address = CrestronEthernetHelper.GetEthernetParameter(param, id);
{ }
short adapter2Type = CrestronEthernetHelper.GetAdapterdIdForSpecifiedAdapterType(secondaryType); catch (ArgumentException)
address2 = CrestronEthernetHelper.GetEthernetParameter(param, adapter2Type); {
} continue;
catch (ArgumentException) }
{
}
if (!string.IsNullOrEmpty(address2)) if (!string.IsNullOrEmpty(address) && !address.Equals(INVALID_VALUE))
yield return address2; yield return address;
}
} }
} }
@@ -74,36 +72,27 @@ namespace ICD.Common.Utils
{ {
const CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET param = const CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET param =
CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_MAC_ADDRESS; CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_MAC_ADDRESS;
const EthernetAdapterType primaryType = EthernetAdapterType.EthernetLANAdapter;
const EthernetAdapterType secondaryType = EthernetAdapterType.EthernetLAN2Adapter;
string macAddress1 = null; foreach (EthernetAdapterType type in EnumUtils.GetValuesExceptNone<EthernetAdapterType>())
try
{ {
short id = CrestronEthernetHelper.GetAdapterdIdForSpecifiedAdapterType(primaryType); string macAddress;
macAddress1 = CrestronEthernetHelper.GetEthernetParameter(param, id);
}
catch (ArgumentException)
{
}
if (!string.IsNullOrEmpty(macAddress1)) try
yield return macAddress1; {
short id = CrestronEthernetHelper.GetAdapterdIdForSpecifiedAdapterType(type);
if (id >= InitialParametersClass.NumberOfEthernetInterfaces)
continue;
string macAddress2 = null; macAddress = CrestronEthernetHelper.GetEthernetParameter(param, id);
}
catch (ArgumentException)
{
continue;
}
try if (!string.IsNullOrEmpty(macAddress) && !macAddress.Equals(INVALID_VALUE))
{ yield return macAddress;
short id = CrestronEthernetHelper.GetAdapterdIdForSpecifiedAdapterType(secondaryType);
macAddress2 = CrestronEthernetHelper.GetEthernetParameter(param, id);
} }
catch (ArgumentException)
{
}
if (!string.IsNullOrEmpty(macAddress2))
yield return macAddress2;
} }
} }
@@ -122,7 +111,15 @@ namespace ICD.Common.Utils
try try
{ {
short id = CrestronEthernetHelper.GetAdapterdIdForSpecifiedAdapterType(type); short id = CrestronEthernetHelper.GetAdapterdIdForSpecifiedAdapterType(type);
return CrestronEthernetHelper.GetEthernetParameter(param, id); if (id >= InitialParametersClass.NumberOfEthernetInterfaces)
return null;
string status = CrestronEthernetHelper.GetEthernetParameter(param, id);
if (!string.IsNullOrEmpty(status) && !status.Equals(INVALID_VALUE))
return status;
return null;
} }
catch (ArgumentException) catch (ArgumentException)
{ {
@@ -141,40 +138,32 @@ namespace ICD.Common.Utils
{ {
const CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET param = const CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET param =
CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_HOSTNAME; CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_HOSTNAME;
const EthernetAdapterType primaryType = EthernetAdapterType.EthernetLANAdapter;
const EthernetAdapterType secondaryType = EthernetAdapterType.EthernetLAN2Adapter;
string address1 = null; foreach (EthernetAdapterType type in EnumUtils.GetValuesExceptNone<EthernetAdapterType>())
try
{ {
short id = CrestronEthernetHelper.GetAdapterdIdForSpecifiedAdapterType(primaryType); string hostname;
address1 = CrestronEthernetHelper.GetEthernetParameter(param, id);
try
{
short id = CrestronEthernetHelper.GetAdapterdIdForSpecifiedAdapterType(type);
if (id >= InitialParametersClass.NumberOfEthernetInterfaces)
continue;
hostname = CrestronEthernetHelper.GetEthernetParameter(param, id);
}
catch (ArgumentException)
{
continue;
}
if (!string.IsNullOrEmpty(hostname) && !hostname.Equals(INVALID_VALUE))
yield return hostname;
} }
catch (ArgumentException)
{
}
if (!string.IsNullOrEmpty(address1))
yield return address1;
string address2 = null;
try
{
short adapter2Type = CrestronEthernetHelper.GetAdapterdIdForSpecifiedAdapterType(secondaryType);
address2 = CrestronEthernetHelper.GetEthernetParameter(param, adapter2Type);
}
catch (ArgumentException)
{
}
if (!string.IsNullOrEmpty(address2))
yield return address2;
} }
} }
#endregion
/// <summary> /// <summary>
/// Static constructor. /// Static constructor.
/// </summary> /// </summary>

View File

@@ -4,4 +4,4 @@ using System.Reflection;
[assembly: AssemblyCompany("ICD Systems")] [assembly: AssemblyCompany("ICD Systems")]
[assembly: AssemblyProduct("ICD.Common.Utils")] [assembly: AssemblyProduct("ICD.Common.Utils")]
[assembly: AssemblyCopyright("Copyright © ICD Systems 2020")] [assembly: AssemblyCopyright("Copyright © ICD Systems 2020")]
[assembly: AssemblyVersion("10.2.0.0")] [assembly: AssemblyVersion("10.3.0.0")]