Merge pull request #433 from PepperDash/feature/add-runtime-ip-info-to-global

Add runtime IP info to global
This commit is contained in:
Andrew Welker
2020-09-30 14:06:38 -06:00
committed by GitHub
5 changed files with 478 additions and 356 deletions

View File

@@ -1,120 +1,120 @@
using System; using System;
using Crestron.SimplSharp; using Crestron.SimplSharp;
using Crestron.SimplSharpPro; using Crestron.SimplSharpPro;
using Crestron.SimplSharpPro.DM; using Crestron.SimplSharpPro.DM;
using Newtonsoft.Json; using Newtonsoft.Json;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using PepperDash.Core; using PepperDash.Core;
using PepperDash.Essentials.Core.Config; using PepperDash.Essentials.Core.Config;
namespace PepperDash.Essentials.Core namespace PepperDash.Essentials.Core
{ {
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
public class CommFactory public class CommFactory
{ {
public static EssentialsControlPropertiesConfig GetControlPropertiesConfig(DeviceConfig deviceConfig) public static EssentialsControlPropertiesConfig GetControlPropertiesConfig(DeviceConfig deviceConfig)
{ {
try try
{ {
return JsonConvert.DeserializeObject<EssentialsControlPropertiesConfig> return JsonConvert.DeserializeObject<EssentialsControlPropertiesConfig>
(deviceConfig.Properties["control"].ToString()); (deviceConfig.Properties["control"].ToString());
//Debug.Console(2, "Control TEST: {0}", JsonConvert.SerializeObject(controlConfig)); //Debug.Console(2, "Control TEST: {0}", JsonConvert.SerializeObject(controlConfig));
} }
catch (Exception e) catch (Exception e)
{ {
Debug.Console(0, "ERROR: [{0}] Control properties deserialize failed:\r{1}", deviceConfig.Key, e); Debug.Console(0, "ERROR: [{0}] Control properties deserialize failed:\r{1}", deviceConfig.Key, e);
return null; return null;
} }
} }
/// <summary> /// <summary>
/// Returns a comm method of either com port, TCP, SSH, and puts this into the DeviceManager /// Returns a comm method of either com port, TCP, SSH, and puts this into the DeviceManager
/// </summary> /// </summary>
/// <param name="deviceConfig">The Device config object</param> /// <param name="deviceConfig">The Device config object</param>
public static IBasicCommunication CreateCommForDevice(DeviceConfig deviceConfig) public static IBasicCommunication CreateCommForDevice(DeviceConfig deviceConfig)
{ {
EssentialsControlPropertiesConfig controlConfig = GetControlPropertiesConfig(deviceConfig); EssentialsControlPropertiesConfig controlConfig = GetControlPropertiesConfig(deviceConfig);
if (controlConfig == null) if (controlConfig == null)
return null; return null;
IBasicCommunication comm = null; IBasicCommunication comm = null;
try try
{ {
var c = controlConfig.TcpSshProperties; var c = controlConfig.TcpSshProperties;
switch (controlConfig.Method) switch (controlConfig.Method)
{ {
case eControlMethod.Com: case eControlMethod.Com:
comm = new ComPortController(deviceConfig.Key + "-com", GetComPort, controlConfig.ComParams, controlConfig); comm = new ComPortController(deviceConfig.Key + "-com", GetComPort, controlConfig.ComParams, controlConfig);
break; break;
case eControlMethod.Cec: case eControlMethod.Cec:
comm = new CecPortController(deviceConfig.Key + "-cec", GetCecPort, controlConfig); comm = new CecPortController(deviceConfig.Key + "-cec", GetCecPort, controlConfig);
break; break;
case eControlMethod.IR: case eControlMethod.IR:
break; break;
case eControlMethod.Ssh: case eControlMethod.Ssh:
{ {
var ssh = new GenericSshClient(deviceConfig.Key + "-ssh", c.Address, c.Port, c.Username, c.Password); var ssh = new GenericSshClient(deviceConfig.Key + "-ssh", c.Address, c.Port, c.Username, c.Password);
ssh.AutoReconnect = c.AutoReconnect; ssh.AutoReconnect = c.AutoReconnect;
if(ssh.AutoReconnect) if(ssh.AutoReconnect)
ssh.AutoReconnectIntervalMs = c.AutoReconnectIntervalMs; ssh.AutoReconnectIntervalMs = c.AutoReconnectIntervalMs;
comm = ssh; comm = ssh;
break; break;
} }
case eControlMethod.Tcpip: case eControlMethod.Tcpip:
{ {
var tcp = new GenericTcpIpClient(deviceConfig.Key + "-tcp", c.Address, c.Port, c.BufferSize); var tcp = new GenericTcpIpClient(deviceConfig.Key + "-tcp", c.Address, c.Port, c.BufferSize);
tcp.AutoReconnect = c.AutoReconnect; tcp.AutoReconnect = c.AutoReconnect;
if (tcp.AutoReconnect) if (tcp.AutoReconnect)
tcp.AutoReconnectIntervalMs = c.AutoReconnectIntervalMs; tcp.AutoReconnectIntervalMs = c.AutoReconnectIntervalMs;
comm = tcp; comm = tcp;
break; break;
} }
case eControlMethod.Udp: case eControlMethod.Udp:
{ {
var udp = new GenericUdpServer(deviceConfig.Key + "-udp", c.Address, c.Port, c.BufferSize); var udp = new GenericUdpServer(deviceConfig.Key + "-udp", c.Address, c.Port, c.BufferSize);
comm = udp; comm = udp;
break; break;
} }
case eControlMethod.Telnet: case eControlMethod.Telnet:
break; break;
default: default:
break; break;
} }
} }
catch (Exception e) catch (Exception e)
{ {
Debug.Console(0, "Cannot create communication from JSON:\r{0}\r\rException:\r{1}", Debug.Console(0, "Cannot create communication from JSON:\r{0}\r\rException:\r{1}",
deviceConfig.Properties.ToString(), e); deviceConfig.Properties.ToString(), e);
} }
// put it in the device manager if it's the right flavor // put it in the device manager if it's the right flavor
var comDev = comm as Device; var comDev = comm as Device;
if (comDev != null) if (comDev != null)
DeviceManager.AddDevice(comDev); DeviceManager.AddDevice(comDev);
return comm; return comm;
} }
public static ComPort GetComPort(EssentialsControlPropertiesConfig config) public static ComPort GetComPort(EssentialsControlPropertiesConfig config)
{ {
var comPar = config.ComParams; var comPar = config.ComParams;
var dev = GetIComPortsDeviceFromManagedDevice(config.ControlPortDevKey); var dev = GetIComPortsDeviceFromManagedDevice(config.ControlPortDevKey);
if (dev != null && config.ControlPortNumber <= dev.NumberOfComPorts) if (dev != null && config.ControlPortNumber <= dev.NumberOfComPorts)
return dev.ComPorts[config.ControlPortNumber]; return dev.ComPorts[config.ControlPortNumber];
Debug.Console(0, "GetComPort: Device '{0}' does not have com port {1}", config.ControlPortDevKey, config.ControlPortNumber); Debug.Console(0, "GetComPort: Device '{0}' does not have com port {1}", config.ControlPortDevKey, config.ControlPortNumber);
return null; return null;
} }
/// <summary> /// <summary>
/// Gets an ICec port from a RoutingInput or RoutingOutput on a device /// Gets an ICec port from a RoutingInput or RoutingOutput on a device
/// </summary> /// </summary>
/// <param name="config"></param> /// <param name="config"></param>
/// <returns></returns> /// <returns></returns>
public static ICec GetCecPort(ControlPropertiesConfig config) public static ICec GetCecPort(ControlPropertiesConfig config)
{ {
var dev = DeviceManager.GetDeviceForKey(config.ControlPortDevKey); var dev = DeviceManager.GetDeviceForKey(config.ControlPortDevKey);
if (dev != null) if (dev != null)
@@ -147,64 +147,64 @@ namespace PepperDash.Essentials.Core
Debug.Console(0, "GetCecPort: '{0}' - Configuration missing 'ControlPortName'", config.ControlPortDevKey); Debug.Console(0, "GetCecPort: '{0}' - Configuration missing 'ControlPortName'", config.ControlPortDevKey);
} }
} }
Debug.Console(0, "GetCecPort: Device '{0}' is not a valid device.", config.ControlPortDevKey); Debug.Console(0, "GetCecPort: Device '{0}' is not a valid device.", config.ControlPortDevKey);
return null; return null;
}
/// <summary>
/// Helper to grab the IComPorts device for this PortDeviceKey. Key "controlSystem" will
/// return the ControlSystem object from the Global class.
/// </summary>
/// <returns>IComPorts device or null if the device is not found or does not implement IComPorts</returns>
public static IComPorts GetIComPortsDeviceFromManagedDevice(string ComPortDevKey)
{
if ((ComPortDevKey.Equals("controlSystem", System.StringComparison.OrdinalIgnoreCase)
|| ComPortDevKey.Equals("processor", System.StringComparison.OrdinalIgnoreCase))
&& Global.ControlSystem is IComPorts)
return Global.ControlSystem;
else
{
var dev = DeviceManager.GetDeviceForKey(ComPortDevKey) as IComPorts;
if (dev == null)
Debug.Console(0, "ComPortConfig: Cannot find com port device '{0}'", ComPortDevKey);
return dev;
}
}
}
/// <summary>
///
/// </summary>
public class EssentialsControlPropertiesConfig :
PepperDash.Core.ControlPropertiesConfig
{
[JsonConverter(typeof(ComSpecJsonConverter))]
public ComPort.ComPortSpec ComParams { get; set; }
public string CresnetId { get; set; }
/// <summary>
/// Attempts to provide uint conversion of string CresnetId
/// </summary>
public uint CresnetIdInt
{
get
{
try
{
return Convert.ToUInt32(CresnetId, 16);
}
catch (Exception)
{
throw new FormatException(string.Format("ERROR:Unable to convert Cresnet ID: {0} to hex. Error:\n{1}", CresnetId));
}
}
} }
public string InfinetId { get; set; } /// <summary>
/// Helper to grab the IComPorts device for this PortDeviceKey. Key "controlSystem" will
/// return the ControlSystem object from the Global class.
/// </summary>
/// <returns>IComPorts device or null if the device is not found or does not implement IComPorts</returns>
public static IComPorts GetIComPortsDeviceFromManagedDevice(string ComPortDevKey)
{
if ((ComPortDevKey.Equals("controlSystem", System.StringComparison.OrdinalIgnoreCase)
|| ComPortDevKey.Equals("processor", System.StringComparison.OrdinalIgnoreCase))
&& Global.ControlSystem is IComPorts)
return Global.ControlSystem;
else
{
var dev = DeviceManager.GetDeviceForKey(ComPortDevKey) as IComPorts;
if (dev == null)
Debug.Console(0, "ComPortConfig: Cannot find com port device '{0}'", ComPortDevKey);
return dev;
}
}
}
/// <summary>
///
/// </summary>
public class EssentialsControlPropertiesConfig :
PepperDash.Core.ControlPropertiesConfig
{
[JsonConverter(typeof(ComSpecJsonConverter))]
public ComPort.ComPortSpec ComParams { get; set; }
public string CresnetId { get; set; }
/// <summary>
/// Attempts to provide uint conversion of string CresnetId
/// </summary>
public uint CresnetIdInt
{
get
{
try
{
return Convert.ToUInt32(CresnetId, 16);
}
catch (Exception)
{
throw new FormatException(string.Format("ERROR:Unable to convert Cresnet ID: {0} to hex. Error:\n{1}", CresnetId));
}
}
}
public string InfinetId { get; set; }
/// <summary> /// <summary>
/// Attepmts to provide uiont conversion of string InifinetId /// Attepmts to provide uiont conversion of string InifinetId
/// </summary> /// </summary>
@@ -221,13 +221,13 @@ namespace PepperDash.Essentials.Core
throw new FormatException(string.Format("ERROR:Unable to conver Infinet ID: {0} to hex. Error:\n{1}", InfinetId)); throw new FormatException(string.Format("ERROR:Unable to conver Infinet ID: {0} to hex. Error:\n{1}", InfinetId));
} }
} }
} }
} }
public class IrControlSpec public class IrControlSpec
{ {
public string PortDeviceKey { get; set; } public string PortDeviceKey { get; set; }
public uint PortNumber { get; set; } public uint PortNumber { get; set; }
public string File { get; set; } public string File { get; set; }
} }
} }

View File

@@ -1,5 +1,5 @@
using System; using System;
using System.Collections.Generic;
using Crestron.SimplSharp; using Crestron.SimplSharp;
using Crestron.SimplSharp.Reflection; using Crestron.SimplSharp.Reflection;
@@ -81,7 +81,7 @@ namespace PepperDash.Essentials.Core.Config
// } // }
//} //}
/// <summary> /// <summary>,
/// The OS Version of the processor (Firmware Version) /// The OS Version of the processor (Firmware Version)
/// </summary> /// </summary>
[JsonProperty("osVersion")] [JsonProperty("osVersion")]
@@ -92,5 +92,18 @@ namespace PepperDash.Essentials.Core.Config
// return Crestron.SimplSharp.CrestronEnvironment.OSVersion.Firmware; // return Crestron.SimplSharp.CrestronEnvironment.OSVersion.Firmware;
// } // }
//} //}
/// <summary>
/// The information gathered by the processor at runtime about it's NICs and their IP addresses.
/// </summary>
[JsonProperty("ipInfo")]
public Dictionary<short, EthernetAdapterInfo> IpInfo
{
get
{
return Global.EthernetAdapterInfoCollection;
}
}
} }
} }

View File

@@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
namespace PepperDash.Essentials.Core
{
public class EthernetAdapterInfo
{
public EthernetAdapterType Type { get; set; }
public bool DhcpIsOn { get; set; }
public string Hostname { get; set; }
public string MacAddress { get; set; }
public string IpAddress { get; set; }
public string Subnet { get; set; }
public string Gateway { get; set; }
public string Dns1 { get; set; }
public string Dns2 { get; set; }
public string Dns3 { get; set; }
public string Domain { get; set; }
}
}

View File

@@ -1,175 +1,260 @@
using System; using System;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using Crestron.SimplSharp; using Crestron.SimplSharp;
using Crestron.SimplSharp.CrestronIO; using System.Collections.Generic;
using Crestron.SimplSharp.CrestronDataStore; using Crestron.SimplSharp.CrestronIO;
using Crestron.SimplSharpPro; using Crestron.SimplSharp.CrestronDataStore;
using Crestron.SimplSharpPro;
using PepperDash.Core;
using PepperDash.Essentials.License; using PepperDash.Core;
using PepperDash.Essentials.License;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq; using Newtonsoft.Json;
using Newtonsoft.Json.Schema; using Newtonsoft.Json.Linq;
using Newtonsoft.Json.Schema;
namespace PepperDash.Essentials.Core
{ namespace PepperDash.Essentials.Core
public static class Global {
{ public static class Global
{
public static CrestronControlSystem ControlSystem { get; set; } public static CrestronControlSystem ControlSystem { get; set; }
public static LicenseManager LicenseManager { get; set; } public static LicenseManager LicenseManager { get; set; }
/// <summary> public static Dictionary<short, EthernetAdapterInfo> EthernetAdapterInfoCollection {get; private set;}
/// The file path prefix to the folder containing configuration files
/// </summary> /// <summary>
public static string FilePathPrefix { get; private set; } /// The file path prefix to the folder containing configuration files
/// </summary>
/// <summary> public static string FilePathPrefix { get; private set; }
/// The file path prefix to the applciation directory
/// </summary> /// <summary>
public static string ApplicationDirectoryPathPrefix /// The file path prefix to the applciation directory
{ /// </summary>
get public static string ApplicationDirectoryPathPrefix
{ {
return Crestron.SimplSharp.CrestronIO.Directory.GetApplicationDirectory(); get
} {
} return Crestron.SimplSharp.CrestronIO.Directory.GetApplicationDirectory();
}
/// <summary> }
/// Returns the directory separator character based on the running OS
/// </summary> /// <summary>
public static char DirectorySeparator /// Returns the directory separator character based on the running OS
{ /// </summary>
get public static char DirectorySeparator
{ {
return System.IO.Path.DirectorySeparatorChar; get
} {
} return System.IO.Path.DirectorySeparatorChar;
}
/// <summary> }
/// Wildcarded config file name for global reference
/// </summary> /// <summary>
public const string ConfigFileName = "*configurationFile*.json"; /// Wildcarded config file name for global reference
/// </summary>
/// <summary> public const string ConfigFileName = "*configurationFile*.json";
/// Sets the file path prefix
/// </summary> /// <summary>
/// <param name="prefix"></param> /// Sets the file path prefix
public static void SetFilePathPrefix(string prefix) /// </summary>
{ /// <param name="prefix"></param>
FilePathPrefix = prefix; public static void SetFilePathPrefix(string prefix)
} {
FilePathPrefix = prefix;
static string _AssemblyVersion; }
/// <summary> static string _AssemblyVersion;
/// Gets the Assembly Version of Essentials
/// </summary> /// <summary>
/// <returns>The Assembly Version at Runtime</returns> /// Gets the Assembly Version of Essentials
public static string AssemblyVersion /// </summary>
{ /// <returns>The Assembly Version at Runtime</returns>
get public static string AssemblyVersion
{ {
return _AssemblyVersion; get
} {
private set return _AssemblyVersion;
{ }
_AssemblyVersion = value; private set
} {
} _AssemblyVersion = value;
}
/// <summary> }
/// Sets the Assembly version to the version of the Essentials Library
/// </summary> /// <summary>
/// <param name="assemblyVersion"></param> /// Sets the Assembly version to the version of the Essentials Library
public static void SetAssemblyVersion(string assemblyVersion) /// </summary>
{ /// <param name="assemblyVersion"></param>
AssemblyVersion = assemblyVersion; public static void SetAssemblyVersion(string assemblyVersion)
} {
AssemblyVersion = assemblyVersion;
/// <summary> }
/// Checks to see if the running version meets or exceed the minimum specified version. For beta versions (0.xx.yy), will always return true.
/// </summary> /// <summary>
/// <param name="minimumVersion">Minimum specified version in format of xx.yy.zz</param> /// Checks to see if the running version meets or exceed the minimum specified version. For beta versions (0.xx.yy), will always return true.
/// <returns>Returns true if the running version meets or exceeds the minimum specified version</returns> /// </summary>
public static bool IsRunningMinimumVersionOrHigher(string minimumVersion) /// <param name="minimumVersion">Minimum specified version in format of xx.yy.zz</param>
{ /// <returns>Returns true if the running version meets or exceeds the minimum specified version</returns>
Debug.Console(2, "Comparing running version '{0}' to minimum version '{1}'", AssemblyVersion, minimumVersion); public static bool IsRunningMinimumVersionOrHigher(string minimumVersion)
{
if (String.IsNullOrEmpty(minimumVersion)) Debug.Console(2, "Comparing running version '{0}' to minimum version '{1}'", AssemblyVersion, minimumVersion);
{
Debug.Console(0,"Plugin does not specify a minimum version. Loading plugin may not work as expected. Proceeding with loading plugin"); if (String.IsNullOrEmpty(minimumVersion))
return true; {
} Debug.Console(0,"Plugin does not specify a minimum version. Loading plugin may not work as expected. Proceeding with loading plugin");
return true;
var runtimeVersion = Regex.Match(AssemblyVersion, @"^(\d*).(\d*).(\d*).*"); }
var runtimeVersionMajor = Int16.Parse(runtimeVersion.Groups[1].Value); var runtimeVersion = Regex.Match(AssemblyVersion, @"^(\d*).(\d*).(\d*).*");
var runtimeVersionMinor = Int16.Parse(runtimeVersion.Groups[2].Value);
var runtimeVersionBuild = Int16.Parse(runtimeVersion.Groups[3].Value); var runtimeVersionMajor = Int16.Parse(runtimeVersion.Groups[1].Value);
var runtimeVersionMinor = Int16.Parse(runtimeVersion.Groups[2].Value);
var runtimeVer = new Version(runtimeVersionMajor, runtimeVersionMinor, runtimeVersionBuild); var runtimeVersionBuild = Int16.Parse(runtimeVersion.Groups[3].Value);
Version minimumVer; var runtimeVer = new Version(runtimeVersionMajor, runtimeVersionMinor, runtimeVersionBuild);
try
{ Version minimumVer;
minimumVer = new Version(minimumVersion); try
} {
catch minimumVer = new Version(minimumVersion);
{ }
Debug.Console(2, "unable to parse minimum version {0}. Bypassing plugin load.", minimumVersion); catch
return false; {
} Debug.Console(2, "unable to parse minimum version {0}. Bypassing plugin load.", minimumVersion);
return false;
}
// Check for beta build version
if (runtimeVer.Major != 0)
{ // Check for beta build version
return runtimeVer.CompareTo(minimumVer) >= 0; if (runtimeVer.Major != 0)
} {
return runtimeVer.CompareTo(minimumVer) >= 0;
Debug.Console(2, "Running Local Build. Bypassing Dependency Check."); }
return true;
Debug.Console(2, "Running Local Build. Bypassing Dependency Check.");
/* return true;
var minVersion = Regex.Match(minimumVersion, @"^(\d*).(\d*).(\d*)$");
/*
if(!minVersion.Success) var minVersion = Regex.Match(minimumVersion, @"^(\d*).(\d*).(\d*)$");
{
if(!minVersion.Success)
} {
var minVersionMajor = Int16.Parse(minVersion.Groups[1].Value); }
var minVersionMinor = Int16.Parse(minVersion.Groups[2].Value);
var minVersionBuild = Int16.Parse(minVersion.Groups[3].Value); var minVersionMajor = Int16.Parse(minVersion.Groups[1].Value);
var minVersionMinor = Int16.Parse(minVersion.Groups[2].Value);
var minVersionBuild = Int16.Parse(minVersion.Groups[3].Value);
if (minVersionMajor > runtimeVersionMajor)
return false;
if (minVersionMajor > runtimeVersionMajor)
if (minVersionMinor > runtimeVersionMinor) return false;
return false;
if (minVersionMinor > runtimeVersionMinor)
if (minVersionBuild > runtimeVersionBuild) return false;
return false;
if (minVersionBuild > runtimeVersionBuild)
return true; return false;
*/
} return true;
*/
static Global() }
{
// Fire up CrestronDataStoreStatic
var err = CrestronDataStoreStatic.InitCrestronDataStore();
if (err != CrestronDataStore.CDS_ERROR.CDS_SUCCESS) static Global()
{ {
CrestronConsole.PrintLine("Error starting CrestronDataStoreStatic: {0}", err); // Fire up CrestronDataStoreStatic
return; var err = CrestronDataStoreStatic.InitCrestronDataStore();
} if (err != CrestronDataStore.CDS_ERROR.CDS_SUCCESS)
} {
CrestronConsole.PrintLine("Error starting CrestronDataStoreStatic: {0}", err);
} return;
}
GetEthernetInformation();
}
/// <summary>
/// Populates EthernetInformationCollection
/// </summary>
static void GetEthernetInformation()
{
EthernetAdapterInfoCollection = new Dictionary<short, EthernetAdapterInfo>();
EthernetAdapterType adapterType = EthernetAdapterType.EthernetUnknownAdapter;
List<EthernetAdapterType> adapters = new List<EthernetAdapterType>()
{ EthernetAdapterType.EthernetLANAdapter, EthernetAdapterType.EthernetLAN2Adapter, EthernetAdapterType.EthernetCSAdapter, EthernetAdapterType.EthernetWIFIAdapter };
foreach (var adapter in adapters)
{
try
{
adapterType = EthernetAdapterType.EthernetLANAdapter;
var adapterId = CrestronEthernetHelper.GetAdapterdIdForSpecifiedAdapterType(adapterType);
var adapterInfo = GetEthernetAdapterProperties(adapterId, adapterType);
EthernetAdapterInfoCollection.Add(adapterId, adapterInfo);
}
catch (Exception e)
{
if (e is System.ArgumentException)
{
Debug.Console(1, "Error: {0} not present", adapterType);
}
else
{
Debug.Console(1, "Error: {0}", e);
}
}
}
}
static EthernetAdapterInfo GetEthernetAdapterProperties(short adapterId, EthernetAdapterType adapterType)
{
EthernetAdapterInfo adapterInfo = new EthernetAdapterInfo();
adapterInfo.Type = adapterType;
adapterInfo.DhcpIsOn = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_DHCP_STATE, adapterId) == "on" ? true : false;
adapterInfo.Hostname = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_HOSTNAME, adapterId);
adapterInfo.MacAddress = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_MAC_ADDRESS, adapterId);
adapterInfo.IpAddress = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_ADDRESS, adapterId);
adapterInfo.Subnet = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_MASK, adapterId);
adapterInfo.Gateway = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_ROUTER, adapterId);
adapterInfo.Domain = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_DOMAIN_NAME, adapterId);
string dns = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_DNS_SERVER, adapterId);
if (dns.Contains(","))
{
string[] dnsList = dns.Split(',');
for (var i = 0; i < dnsList.Length; i++)
{
if (i == 0)
adapterInfo.Dns1 = !string.IsNullOrEmpty(dnsList[0]) ? dnsList[0] : "0.0.0.0";
if (i == 1)
adapterInfo.Dns2 = !string.IsNullOrEmpty(dnsList[1]) ? dnsList[1] : "0.0.0.0";
if (i == 2)
adapterInfo.Dns3 = !string.IsNullOrEmpty(dnsList[2]) ? dnsList[2] : "0.0.0.0";
}
}
else
{
adapterInfo.Dns1 = !string.IsNullOrEmpty(dns) ? dns : "0.0.0.0";
adapterInfo.Dns2 = "0.0.0.0";
adapterInfo.Dns3 = "0.0.0.0";
}
return adapterInfo;
}
}
} }

View File

@@ -224,6 +224,7 @@
<Compile Include="Fusion\FusionRviDataClasses.cs" /> <Compile Include="Fusion\FusionRviDataClasses.cs" />
<Compile Include="Gateways\CenRfgwController.cs" /> <Compile Include="Gateways\CenRfgwController.cs" />
<Compile Include="Gateways\EssentialsRfGatewayConfig.cs" /> <Compile Include="Gateways\EssentialsRfGatewayConfig.cs" />
<Compile Include="Global\EthernetAdapterInfo.cs" />
<Compile Include="Queues\ComsMessage.cs" /> <Compile Include="Queues\ComsMessage.cs" />
<Compile Include="Queues\ProcessStringMessage.cs" /> <Compile Include="Queues\ProcessStringMessage.cs" />
<Compile Include="Queues\GenericQueue.cs" /> <Compile Include="Queues\GenericQueue.cs" />