From 10cbd951752c3f980569da337430d32313d0363c Mon Sep 17 00:00:00 2001 From: Aviv Cohn Date: Thu, 14 Nov 2024 12:26:37 -0800 Subject: [PATCH] fix: ip address pulled from socket as defined in config --- src/SamsungMdc.cs | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/SamsungMdc.cs b/src/SamsungMdc.cs index bb93e7c..d89815b 100644 --- a/src/SamsungMdc.cs +++ b/src/SamsungMdc.cs @@ -16,6 +16,7 @@ using System.Linq; using System.Text; using Feedback = PepperDash.Essentials.Core.Feedback; +using GenericTcpIpClient = PepperDash.Core.GenericTcpIpClient; namespace PepperDashPluginSamsungMdcDisplay { @@ -211,6 +212,15 @@ public SamsungMdcDisplayController(string key, string name, SamsungMdcDisplayPro ResetDebugLevels(); DeviceInfo = new DeviceInfo(); + + + if (comms is ISocketStatus socket) + { + if (comms is GenericTcpIpClient tcpip) + { + DeviceInfo.IpAddress = tcpip.Hostname; + } + } Init(); } @@ -1463,21 +1473,26 @@ private double ConvertFahrenheitToCelsius(double f) #region Implementation of IDeviceInfoProvider + //needs testing public void UpdateDeviceInfo() { + /*This is an example structure used in other Get Commands + SendBytes(new byte[] { SamsungMdcCommands.Header, SamsungMdcCommands.PowerControl, 0x00, 0x00, 0x00 }); + */ + if (DeviceInfo == null) { DeviceInfo = new DeviceInfo(); } //get serial number (0x0B) - SendBytes(new byte[] { SamsungMdcCommands.Header, SamsungMdcCommands.SerialNumberControl, Id, 0x00 }); + SendBytes(new byte[] { SamsungMdcCommands.Header, SamsungMdcCommands.SerialNumberControl, 0x00, 0x00, 0x00, }); //get firmware version (0x0E) - SendBytes(new byte[] { SamsungMdcCommands.Header, SamsungMdcCommands.SwVersionControl, Id, 0x00 }); + SendBytes(new byte[] { SamsungMdcCommands.Header, SamsungMdcCommands.SwVersionControl, 0x00, 0x00, 0x00 }); //get IP Info (0x1B, 0x82) - SendBytes(new byte[] { SamsungMdcCommands.Header, SamsungMdcCommands.SystemConfiguration, Id, 0x01, SamsungMdcCommands.NetworkConfiguration }); + SendBytes(new byte[] { SamsungMdcCommands.Header, SamsungMdcCommands.NetworkConfiguration, 0x00, 0x00, 0x00 }); //get MAC address (0x1B, 0x81) - SendBytes(new byte[] { SamsungMdcCommands.Header, SamsungMdcCommands.SystemConfiguration, Id, 0x01, SamsungMdcCommands.SystemConfigurationMacAddress }); + SendBytes(new byte[] { SamsungMdcCommands.Header, SamsungMdcCommands.SystemConfigurationMacAddress, 0x00, 0x00, 0x00 }); } public DeviceInfo DeviceInfo { get; private set; }