Skip to content

Commit

Permalink
feat: added DeviceInfoProvider interface
Browse files Browse the repository at this point in the history
  • Loading branch information
ngenovese11 committed Feb 1, 2024
1 parent ff5def6 commit 2481431
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion src/NvxEpi/Devices/NvxBaseDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
using NvxEpi.Services.Utilities;
using NvxEpi.Services.Messages;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.DeviceInfo;
using PepperDash.Essentials.Core.Queues;
using PepperDash.Essentials.Core.Config;

Expand All @@ -30,7 +31,8 @@ public abstract class NvxBaseDevice :
ICurrentStream,
ICurrentSecondaryAudioStream,
ICurrentNaxInput,
ICommunicationMonitor
ICommunicationMonitor,
IDeviceInfoProvider
{
private ICurrentSecondaryAudioStream _currentSecondaryAudioStream;
private ICurrentStream _currentVideoStream;
Expand Down Expand Up @@ -119,6 +121,8 @@ public override bool CustomActivate()

RegisterForFeedback();
CommunicationMonitor.Start();
Hardware.Network.NetworkChange += (sender, args) => UpdateDeviceInfo();

_queue.Enqueue(new BuildNvxDeviceMessage(Key, Hardware));

if (IsTransmitter || Hardware == null) return base.CustomActivate();
Expand Down Expand Up @@ -283,5 +287,25 @@ public BoolFeedback IsOnline
}

public StatusMonitorBase CommunicationMonitor { get; private set; }

public void UpdateDeviceInfo()
{
DeviceInfo = new DeviceInfo
{
IpAddress = Hardware.Network.IpAddressFeedback.StringValue,
HostName = Hardware.Network.HostNameFeedback.StringValue,
MacAddress = string.Empty,
FirmwareVersion = string.Empty
};

var handler = DeviceInfoChanged;
if (handler == null)
return;

handler(this, new DeviceInfoEventArgs { DeviceInfo = DeviceInfo });
}

public DeviceInfo DeviceInfo { get; private set; }
public event DeviceInfoChangeHandler DeviceInfoChanged;
}
}

0 comments on commit 2481431

Please sign in to comment.