diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Comm and IR/CommFactory.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Comm and IR/CommFactory.cs index 7556cbcd..a8fa67e4 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Comm and IR/CommFactory.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Comm and IR/CommFactory.cs @@ -1,120 +1,120 @@ -using System; -using Crestron.SimplSharp; -using Crestron.SimplSharpPro; -using Crestron.SimplSharpPro.DM; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using PepperDash.Core; -using PepperDash.Essentials.Core.Config; - -namespace PepperDash.Essentials.Core -{ - /// - /// - /// - public class CommFactory - { - public static EssentialsControlPropertiesConfig GetControlPropertiesConfig(DeviceConfig deviceConfig) - { - try - { - return JsonConvert.DeserializeObject - (deviceConfig.Properties["control"].ToString()); - //Debug.Console(2, "Control TEST: {0}", JsonConvert.SerializeObject(controlConfig)); - } - catch (Exception e) - { - - Debug.Console(0, "ERROR: [{0}] Control properties deserialize failed:\r{1}", deviceConfig.Key, e); - return null; - } - } - - - /// - /// Returns a comm method of either com port, TCP, SSH, and puts this into the DeviceManager - /// - /// The Device config object - public static IBasicCommunication CreateCommForDevice(DeviceConfig deviceConfig) - { - EssentialsControlPropertiesConfig controlConfig = GetControlPropertiesConfig(deviceConfig); - if (controlConfig == null) - return null; - - IBasicCommunication comm = null; - try - { - var c = controlConfig.TcpSshProperties; - switch (controlConfig.Method) - { - case eControlMethod.Com: - comm = new ComPortController(deviceConfig.Key + "-com", GetComPort, controlConfig.ComParams, controlConfig); - break; - case eControlMethod.Cec: - comm = new CecPortController(deviceConfig.Key + "-cec", GetCecPort, controlConfig); - break; - case eControlMethod.IR: - break; - case eControlMethod.Ssh: - { - var ssh = new GenericSshClient(deviceConfig.Key + "-ssh", c.Address, c.Port, c.Username, c.Password); - ssh.AutoReconnect = c.AutoReconnect; - if(ssh.AutoReconnect) - ssh.AutoReconnectIntervalMs = c.AutoReconnectIntervalMs; - comm = ssh; - break; - } - case eControlMethod.Tcpip: - { - var tcp = new GenericTcpIpClient(deviceConfig.Key + "-tcp", c.Address, c.Port, c.BufferSize); - tcp.AutoReconnect = c.AutoReconnect; - if (tcp.AutoReconnect) - tcp.AutoReconnectIntervalMs = c.AutoReconnectIntervalMs; - comm = tcp; - break; - } - case eControlMethod.Udp: - { - var udp = new GenericUdpServer(deviceConfig.Key + "-udp", c.Address, c.Port, c.BufferSize); - comm = udp; - break; - } - case eControlMethod.Telnet: - break; - default: - break; - } - } - catch (Exception e) - { - Debug.Console(0, "Cannot create communication from JSON:\r{0}\r\rException:\r{1}", - deviceConfig.Properties.ToString(), e); - } - - // put it in the device manager if it's the right flavor - var comDev = comm as Device; - if (comDev != null) - DeviceManager.AddDevice(comDev); - return comm; - } - - public static ComPort GetComPort(EssentialsControlPropertiesConfig config) - { - var comPar = config.ComParams; - var dev = GetIComPortsDeviceFromManagedDevice(config.ControlPortDevKey); - if (dev != null && config.ControlPortNumber <= dev.NumberOfComPorts) - return dev.ComPorts[config.ControlPortNumber]; - Debug.Console(0, "GetComPort: Device '{0}' does not have com port {1}", config.ControlPortDevKey, config.ControlPortNumber); - return null; - } - - /// - /// Gets an ICec port from a RoutingInput or RoutingOutput on a device - /// - /// - /// - public static ICec GetCecPort(ControlPropertiesConfig config) - { +using System; +using Crestron.SimplSharp; +using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro.DM; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using PepperDash.Core; +using PepperDash.Essentials.Core.Config; + +namespace PepperDash.Essentials.Core +{ + /// + /// + /// + public class CommFactory + { + public static EssentialsControlPropertiesConfig GetControlPropertiesConfig(DeviceConfig deviceConfig) + { + try + { + return JsonConvert.DeserializeObject + (deviceConfig.Properties["control"].ToString()); + //Debug.Console(2, "Control TEST: {0}", JsonConvert.SerializeObject(controlConfig)); + } + catch (Exception e) + { + + Debug.Console(0, "ERROR: [{0}] Control properties deserialize failed:\r{1}", deviceConfig.Key, e); + return null; + } + } + + + /// + /// Returns a comm method of either com port, TCP, SSH, and puts this into the DeviceManager + /// + /// The Device config object + public static IBasicCommunication CreateCommForDevice(DeviceConfig deviceConfig) + { + EssentialsControlPropertiesConfig controlConfig = GetControlPropertiesConfig(deviceConfig); + if (controlConfig == null) + return null; + + IBasicCommunication comm = null; + try + { + var c = controlConfig.TcpSshProperties; + switch (controlConfig.Method) + { + case eControlMethod.Com: + comm = new ComPortController(deviceConfig.Key + "-com", GetComPort, controlConfig.ComParams, controlConfig); + break; + case eControlMethod.Cec: + comm = new CecPortController(deviceConfig.Key + "-cec", GetCecPort, controlConfig); + break; + case eControlMethod.IR: + break; + case eControlMethod.Ssh: + { + var ssh = new GenericSshClient(deviceConfig.Key + "-ssh", c.Address, c.Port, c.Username, c.Password); + ssh.AutoReconnect = c.AutoReconnect; + if(ssh.AutoReconnect) + ssh.AutoReconnectIntervalMs = c.AutoReconnectIntervalMs; + comm = ssh; + break; + } + case eControlMethod.Tcpip: + { + var tcp = new GenericTcpIpClient(deviceConfig.Key + "-tcp", c.Address, c.Port, c.BufferSize); + tcp.AutoReconnect = c.AutoReconnect; + if (tcp.AutoReconnect) + tcp.AutoReconnectIntervalMs = c.AutoReconnectIntervalMs; + comm = tcp; + break; + } + case eControlMethod.Udp: + { + var udp = new GenericUdpServer(deviceConfig.Key + "-udp", c.Address, c.Port, c.BufferSize); + comm = udp; + break; + } + case eControlMethod.Telnet: + break; + default: + break; + } + } + catch (Exception e) + { + Debug.Console(0, "Cannot create communication from JSON:\r{0}\r\rException:\r{1}", + deviceConfig.Properties.ToString(), e); + } + + // put it in the device manager if it's the right flavor + var comDev = comm as Device; + if (comDev != null) + DeviceManager.AddDevice(comDev); + return comm; + } + + public static ComPort GetComPort(EssentialsControlPropertiesConfig config) + { + var comPar = config.ComParams; + var dev = GetIComPortsDeviceFromManagedDevice(config.ControlPortDevKey); + if (dev != null && config.ControlPortNumber <= dev.NumberOfComPorts) + return dev.ComPorts[config.ControlPortNumber]; + Debug.Console(0, "GetComPort: Device '{0}' does not have com port {1}", config.ControlPortDevKey, config.ControlPortNumber); + return null; + } + + /// + /// Gets an ICec port from a RoutingInput or RoutingOutput on a device + /// + /// + /// + public static ICec GetCecPort(ControlPropertiesConfig config) + { var dev = DeviceManager.GetDeviceForKey(config.ControlPortDevKey); 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: Device '{0}' is not a valid device.", config.ControlPortDevKey); - - return null; - } - - /// - /// Helper to grab the IComPorts device for this PortDeviceKey. Key "controlSystem" will - /// return the ControlSystem object from the Global class. - /// - /// IComPorts device or null if the device is not found or does not implement IComPorts - 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; - } - } - } - - /// - /// - /// - public class EssentialsControlPropertiesConfig : - PepperDash.Core.ControlPropertiesConfig - { - - [JsonConverter(typeof(ComSpecJsonConverter))] - public ComPort.ComPortSpec ComParams { get; set; } - - public string CresnetId { get; set; } - - /// - /// Attempts to provide uint conversion of string CresnetId - /// - 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)); - } - } + Debug.Console(0, "GetCecPort: Device '{0}' is not a valid device.", config.ControlPortDevKey); + + return null; } - public string InfinetId { get; set; } - + /// + /// Helper to grab the IComPorts device for this PortDeviceKey. Key "controlSystem" will + /// return the ControlSystem object from the Global class. + /// + /// IComPorts device or null if the device is not found or does not implement IComPorts + 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; + } + } + } + + /// + /// + /// + public class EssentialsControlPropertiesConfig : + PepperDash.Core.ControlPropertiesConfig + { + + [JsonConverter(typeof(ComSpecJsonConverter))] + public ComPort.ComPortSpec ComParams { get; set; } + + public string CresnetId { get; set; } + + /// + /// Attempts to provide uint conversion of string CresnetId + /// + 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; } + /// /// Attepmts to provide uiont conversion of string InifinetId /// @@ -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)); } } - } - } - - public class IrControlSpec - { - public string PortDeviceKey { get; set; } - public uint PortNumber { get; set; } - public string File { get; set; } - } + } + } + + public class IrControlSpec + { + public string PortDeviceKey { get; set; } + public uint PortNumber { get; set; } + public string File { get; set; } + } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Config/InfoConfig.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Config/InfoConfig.cs index d5cf16f1..3191a8f6 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Config/InfoConfig.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Config/InfoConfig.cs @@ -1,5 +1,5 @@ using System; - +using System.Collections.Generic; using Crestron.SimplSharp; using Crestron.SimplSharp.Reflection; @@ -81,7 +81,7 @@ namespace PepperDash.Essentials.Core.Config // } //} - /// + /// , /// The OS Version of the processor (Firmware Version) /// [JsonProperty("osVersion")] @@ -92,5 +92,18 @@ namespace PepperDash.Essentials.Core.Config // return Crestron.SimplSharp.CrestronEnvironment.OSVersion.Firmware; // } //} + + /// + /// The information gathered by the processor at runtime about it's NICs and their IP addresses. + /// + [JsonProperty("ipInfo")] + public Dictionary IpInfo + { + get + { + return Global.EthernetAdapterInfoCollection; + } + } } + } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Global/EthernetAdapterInfo.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Global/EthernetAdapterInfo.cs new file mode 100644 index 00000000..c21df098 --- /dev/null +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Global/EthernetAdapterInfo.cs @@ -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; } + } +} \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Global/Global.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Global/Global.cs index b540b3d6..911c148e 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Global/Global.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Global/Global.cs @@ -1,175 +1,260 @@ -using System; -using System.Text.RegularExpressions; -using Crestron.SimplSharp; -using Crestron.SimplSharp.CrestronIO; -using Crestron.SimplSharp.CrestronDataStore; -using Crestron.SimplSharpPro; - -using PepperDash.Core; -using PepperDash.Essentials.License; - -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using Newtonsoft.Json.Schema; - - -namespace PepperDash.Essentials.Core -{ - public static class Global - { +using System; +using System.Text.RegularExpressions; +using Crestron.SimplSharp; +using System.Collections.Generic; +using Crestron.SimplSharp.CrestronIO; +using Crestron.SimplSharp.CrestronDataStore; +using Crestron.SimplSharpPro; + +using PepperDash.Core; +using PepperDash.Essentials.License; + +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using Newtonsoft.Json.Schema; + + +namespace PepperDash.Essentials.Core +{ + public static class Global + { public static CrestronControlSystem ControlSystem { get; set; } - public static LicenseManager LicenseManager { get; set; } - - /// - /// The file path prefix to the folder containing configuration files - /// - public static string FilePathPrefix { get; private set; } - - /// - /// The file path prefix to the applciation directory - /// - public static string ApplicationDirectoryPathPrefix - { - get - { - return Crestron.SimplSharp.CrestronIO.Directory.GetApplicationDirectory(); - } - } - - /// - /// Returns the directory separator character based on the running OS - /// - public static char DirectorySeparator - { - get - { - return System.IO.Path.DirectorySeparatorChar; - } - } - - /// - /// Wildcarded config file name for global reference - /// - public const string ConfigFileName = "*configurationFile*.json"; - - /// - /// Sets the file path prefix - /// - /// - public static void SetFilePathPrefix(string prefix) - { - FilePathPrefix = prefix; - } - - static string _AssemblyVersion; - - /// - /// Gets the Assembly Version of Essentials - /// - /// The Assembly Version at Runtime - public static string AssemblyVersion - { - get - { - return _AssemblyVersion; - } - private set - { - _AssemblyVersion = value; - } - } - - /// - /// Sets the Assembly version to the version of the Essentials Library - /// - /// - public static void SetAssemblyVersion(string assemblyVersion) - { - AssemblyVersion = assemblyVersion; - } - - /// - /// Checks to see if the running version meets or exceed the minimum specified version. For beta versions (0.xx.yy), will always return true. - /// - /// Minimum specified version in format of xx.yy.zz - /// Returns true if the running version meets or exceeds the minimum specified version - public static bool IsRunningMinimumVersionOrHigher(string minimumVersion) - { - Debug.Console(2, "Comparing running version '{0}' to minimum version '{1}'", AssemblyVersion, minimumVersion); - - if (String.IsNullOrEmpty(minimumVersion)) - { - 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 runtimeVersionMinor = Int16.Parse(runtimeVersion.Groups[2].Value); - var runtimeVersionBuild = Int16.Parse(runtimeVersion.Groups[3].Value); - - var runtimeVer = new Version(runtimeVersionMajor, runtimeVersionMinor, runtimeVersionBuild); - - Version minimumVer; - try - { - minimumVer = new Version(minimumVersion); - } - catch - { - Debug.Console(2, "unable to parse minimum version {0}. Bypassing plugin load.", minimumVersion); - return false; - } - - - // Check for beta build version - if (runtimeVer.Major != 0) - { - return runtimeVer.CompareTo(minimumVer) >= 0; - } - - Debug.Console(2, "Running Local Build. Bypassing Dependency Check."); - return true; - - /* - 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); - - - - if (minVersionMajor > runtimeVersionMajor) - return false; - - if (minVersionMinor > runtimeVersionMinor) - return false; - - if (minVersionBuild > runtimeVersionBuild) - return false; - - return true; - */ - } - - static Global() - { - // Fire up CrestronDataStoreStatic - var err = CrestronDataStoreStatic.InitCrestronDataStore(); - if (err != CrestronDataStore.CDS_ERROR.CDS_SUCCESS) - { - CrestronConsole.PrintLine("Error starting CrestronDataStoreStatic: {0}", err); - return; - } - } - - } + public static LicenseManager LicenseManager { get; set; } + + public static Dictionary EthernetAdapterInfoCollection {get; private set;} + + /// + /// The file path prefix to the folder containing configuration files + /// + public static string FilePathPrefix { get; private set; } + + /// + /// The file path prefix to the applciation directory + /// + public static string ApplicationDirectoryPathPrefix + { + get + { + return Crestron.SimplSharp.CrestronIO.Directory.GetApplicationDirectory(); + } + } + + /// + /// Returns the directory separator character based on the running OS + /// + public static char DirectorySeparator + { + get + { + return System.IO.Path.DirectorySeparatorChar; + } + } + + /// + /// Wildcarded config file name for global reference + /// + public const string ConfigFileName = "*configurationFile*.json"; + + /// + /// Sets the file path prefix + /// + /// + public static void SetFilePathPrefix(string prefix) + { + FilePathPrefix = prefix; + } + + static string _AssemblyVersion; + + /// + /// Gets the Assembly Version of Essentials + /// + /// The Assembly Version at Runtime + public static string AssemblyVersion + { + get + { + return _AssemblyVersion; + } + private set + { + _AssemblyVersion = value; + } + } + + /// + /// Sets the Assembly version to the version of the Essentials Library + /// + /// + public static void SetAssemblyVersion(string assemblyVersion) + { + AssemblyVersion = assemblyVersion; + } + + /// + /// Checks to see if the running version meets or exceed the minimum specified version. For beta versions (0.xx.yy), will always return true. + /// + /// Minimum specified version in format of xx.yy.zz + /// Returns true if the running version meets or exceeds the minimum specified version + public static bool IsRunningMinimumVersionOrHigher(string minimumVersion) + { + Debug.Console(2, "Comparing running version '{0}' to minimum version '{1}'", AssemblyVersion, minimumVersion); + + if (String.IsNullOrEmpty(minimumVersion)) + { + 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 runtimeVersionMinor = Int16.Parse(runtimeVersion.Groups[2].Value); + var runtimeVersionBuild = Int16.Parse(runtimeVersion.Groups[3].Value); + + var runtimeVer = new Version(runtimeVersionMajor, runtimeVersionMinor, runtimeVersionBuild); + + Version minimumVer; + try + { + minimumVer = new Version(minimumVersion); + } + catch + { + Debug.Console(2, "unable to parse minimum version {0}. Bypassing plugin load.", minimumVersion); + return false; + } + + + // Check for beta build version + if (runtimeVer.Major != 0) + { + return runtimeVer.CompareTo(minimumVer) >= 0; + } + + Debug.Console(2, "Running Local Build. Bypassing Dependency Check."); + return true; + + /* + 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); + + + + if (minVersionMajor > runtimeVersionMajor) + return false; + + if (minVersionMinor > runtimeVersionMinor) + return false; + + if (minVersionBuild > runtimeVersionBuild) + return false; + + return true; + */ + } + + + + static Global() + { + // Fire up CrestronDataStoreStatic + var err = CrestronDataStoreStatic.InitCrestronDataStore(); + if (err != CrestronDataStore.CDS_ERROR.CDS_SUCCESS) + { + CrestronConsole.PrintLine("Error starting CrestronDataStoreStatic: {0}", err); + return; + } + + GetEthernetInformation(); + + } + + /// + /// Populates EthernetInformationCollection + /// + static void GetEthernetInformation() + { + + EthernetAdapterInfoCollection = new Dictionary(); + + EthernetAdapterType adapterType = EthernetAdapterType.EthernetUnknownAdapter; + + List adapters = new List() + { 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; + } + } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj b/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj index e0cf8dcb..36afcac4 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj @@ -224,6 +224,7 @@ +