Skip to content

Commit

Permalink
Device SerialNumber
Browse files Browse the repository at this point in the history
  • Loading branch information
Rans4ckeR committed Jan 5, 2024
1 parent d045845 commit 4fd7e70
Show file tree
Hide file tree
Showing 11 changed files with 44 additions and 40 deletions.
6 changes: 3 additions & 3 deletions RS.Fritz.Manager.API/Entities/InternetGatewayDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ public sealed record InternetGatewayDevice(IFritzServiceOperationHandler FritzSe
public IEnumerable<ServiceListItem> Services
=> services ??= UPnPDescription.Device.GetServices().ToArray();

internal Task<TResult> ExecuteAsync<TResult>(Func<IFritzServiceOperationHandler, InternetGatewayDevice, Task<TResult>> operation)
=> operation(FritzServiceOperationHandler, this);

public async ValueTask InitializeAsync()
{
SecurityPort = (await this.DeviceInfoGetSecurityPortAsync().ConfigureAwait(false)).SecurityPort;
Users = (await UsersService.GetUsersAsync(this).ConfigureAwait(false)).ToArray();
}

internal Task<TResult> ExecuteAsync<TResult>(Func<IFritzServiceOperationHandler, InternetGatewayDevice, Task<TResult>> operation)
=> operation(FritzServiceOperationHandler, this);
}
2 changes: 1 addition & 1 deletion RS.Fritz.Manager.API/Extensions/DeviceExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public static IEnumerable<ServiceListItem> GetServices(this Device device)
{
IEnumerable<ServiceListItem> serviceListItems = device.ServiceList;

foreach (Device deviceListItem in device.DeviceList ?? Array.Empty<Device>())
foreach (Device deviceListItem in device.DeviceList ?? [])
{
serviceListItems = serviceListItems.Concat(GetServices(deviceListItem));
}
Expand Down
4 changes: 2 additions & 2 deletions RS.Fritz.Manager.API/RS.Fritz.Manager.API.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<RootNamespace>RS.Fritz.Manager.API</RootNamespace>
<Title>RS.Fritz.Manager.API</Title>
<Product>RS.Fritz.Manager.API</Product>
<Copyright>Copyright 2023 (c) RS. All rights reserved.</Copyright>
<Copyright>Copyright 2021-2024 (c) RS. All rights reserved.</Copyright>
<Company>Rans4ckeR</Company>
<Configuration></Configuration>
<Trademark></Trademark>
Expand Down Expand Up @@ -39,7 +39,7 @@
<None Include="..\README.md" Pack="true" PackagePath="\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.507">
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.556">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ private static IEnumerable<Dictionary<string, string>> GetFormattedDeviceRespons
StringComparer.OrdinalIgnoreCase));
}

private static async ValueTask ReceiveAsync(Socket socket, ICollection<string> responses, int receiveTimeout, CancellationToken cancellationToken)
private static async ValueTask ReceiveAsync(Socket socket, List<string> responses, int receiveTimeout, CancellationToken cancellationToken)
{
using IMemoryOwner<byte> memoryOwner = MemoryPool<byte>.Shared.Rent(4096);
using var timeoutCancellationTokenSource = new CancellationTokenSource(receiveTimeout);
Expand Down
11 changes: 6 additions & 5 deletions RS.Fritz.Manager.API/Services/Discovery/Entities/Device.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ public readonly record struct Device(
[property: DataMember(Name = "modelNumber", Order = 6)] string ModelNumber,
[property: DataMember(Name = "modelURL", Order = 7)] string ModelUrl,

Check warning on line 14 in RS.Fritz.Manager.API/Services/Discovery/Entities/Device.cs

View workflow job for this annotation

GitHub Actions / build

Change the type of property 'Device.ModelUrl' from 'string' to 'System.Uri' (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1056)
[property: DataMember(Name = "UDN", Order = 8)] string UniqueDeviceName,
[property: DataMember(Name = "UPC", Order = 9)] string Upc,
[property: DataMember(Name = "iconList", Order = 10)] IconListItem[] IconList,
[property: DataMember(Name = "serviceList", Order = 11)] ServiceListItem[] ServiceList,
[property: DataMember(Name = "deviceList", Order = 12)] Device[]? DeviceList,
[property: DataMember(Name = "presentationURL", Order = 13)] string PresentationUrl);
[property: DataMember(Name = "serialNumber", Order = 9)] string SerialNumber,
[property: DataMember(Name = "UPC", Order = 10)] string Upc,
[property: DataMember(Name = "iconList", Order = 11)] IconListItem[] IconList,

Check warning on line 18 in RS.Fritz.Manager.API/Services/Discovery/Entities/Device.cs

View workflow job for this annotation

GitHub Actions / build

Properties should not return arrays (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1819)
[property: DataMember(Name = "serviceList", Order = 12)] ServiceListItem[] ServiceList,
[property: DataMember(Name = "deviceList", Order = 13)] Device[]? DeviceList,
[property: DataMember(Name = "presentationURL", Order = 14)] string PresentationUrl);
4 changes: 2 additions & 2 deletions RS.Fritz.Manager.UI/MainWindow/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ internal sealed class MainWindowViewModel : FritzServiceViewModel
private const int ZIndexNoOverlay = -1;

private readonly IDeviceSearchService deviceSearchService;
private ObservableCollection<ObservableInternetGatewayDevice> devices = new();
private ObservableCollection<User> users = new();
private ObservableCollection<ObservableInternetGatewayDevice> devices = [];
private ObservableCollection<User> users = [];
private ObservableObject? activeView;
private string? userMessage;
private bool deviceAndLoginControlsEnabled = true;
Expand Down
4 changes: 2 additions & 2 deletions RS.Fritz.Manager.UI/RS.Fritz.Manager.UI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<RootNamespace>RS.Fritz.Manager.UI</RootNamespace>
<Title>RS.Fritz.Manager.UI</Title>
<Product>RS.Fritz.Manager.UI</Product>
<Copyright>Copyright 2023 (c) RS. All rights reserved.</Copyright>
<Copyright>Copyright 2021-2024 (c) RS. All rights reserved.</Copyright>
<Company>Rans4ckeR</Company>
<Configuration></Configuration>
<Trademark></Trademark>
Expand Down Expand Up @@ -41,7 +41,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" />
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.507">
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.556">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
23 changes: 13 additions & 10 deletions RS.Fritz.Manager.UI/Resources/UPnPResourceDictionary.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
Expand All @@ -151,11 +152,12 @@
<Label Grid.Row="6" Grid.Column="0" Target="{Binding ElementName=ModelNumber}" Content="_ModelNumber" ToolTip="Model number of the device."/>
<Label Grid.Row="7" Grid.Column="0" Target="{Binding ElementName=ModelUrl}" Content="_ModelUrl" ToolTip="URL to the Web site for this model."/>
<Label Grid.Row="8" Grid.Column="0" Target="{Binding ElementName=UniqueDeviceName}" Content="_UniqueDeviceName" ToolTip="Name that uniquely identifies a specific device."/>
<Label Grid.Row="9" Grid.Column="0" Target="{Binding ElementName=Upc}" Content="_Upc" ToolTip="Universal Product Code."/>
<Label Grid.Row="10" Grid.Column="0" Target="{Binding ElementName=PresentationUrl}" Content="_PresentationUrl" ToolTip="URL to a device representation Web page."/>
<Label Grid.Row="11" Grid.Column="0" Target="{Binding ElementName=IconList}" Content="_IconList" ToolTip="Icon to depict device in a control point UI."/>
<Label Grid.Row="12" Grid.Column="0" Target="{Binding ElementName=ServiceList}" Content="_ServiceList" ToolTip="List of UPnP services."/>
<Label Grid.Row="13" Grid.Column="0" Target="{Binding ElementName=DeviceList}" Content="_DeviceList" ToolTip="List of embedded UPnP devices."/>
<Label Grid.Row="9" Grid.Column="0" Target="{Binding ElementName=SerialNumber}" Content="_SerialNumber"/>
<Label Grid.Row="10" Grid.Column="0" Target="{Binding ElementName=Upc}" Content="_Upc" ToolTip="Universal Product Code."/>
<Label Grid.Row="11" Grid.Column="0" Target="{Binding ElementName=PresentationUrl}" Content="_PresentationUrl" ToolTip="URL to a device representation Web page."/>
<Label Grid.Row="12" Grid.Column="0" Target="{Binding ElementName=IconList}" Content="_IconList" ToolTip="Icon to depict device in a control point UI."/>
<Label Grid.Row="13" Grid.Column="0" Target="{Binding ElementName=ServiceList}" Content="_ServiceList" ToolTip="List of UPnP services."/>
<Label Grid.Row="14" Grid.Column="0" Target="{Binding ElementName=DeviceList}" Content="_DeviceList" ToolTip="List of embedded UPnP devices."/>
<TextBlock x:Name="DeviceType" Grid.Row="0" Grid.Column="1" Text="{Binding DeviceType}"/>
<TextBlock x:Name="FriendlyName" Grid.Row="1" Grid.Column="1" Text="{Binding FriendlyName}"/>
<TextBlock x:Name="Manufacturer" Grid.Row="2" Grid.Column="1" Text="{Binding Manufacturer}"/>
Expand All @@ -165,15 +167,16 @@
<TextBlock x:Name="ModelNumber" Grid.Row="6" Grid.Column="1" Text="{Binding ModelNumber}"/>
<ContentControl x:Name="ModelUrl" ContentTemplate="{StaticResource UrlDataTemplate}" Content="{Binding ModelUrl}" Grid.Row="7" Grid.Column="1"/>
<TextBlock x:Name="UniqueDeviceName" Grid.Row="8" Grid.Column="1" Text="{Binding UniqueDeviceName}"/>
<TextBlock x:Name="Upc" Grid.Row="9" Grid.Column="1" Text="{Binding Upc}"/>
<ContentControl x:Name="PresentationUrl" ContentTemplate="{StaticResource UrlDataTemplate}" Content="{Binding PresentationUrl}" Grid.Row="10" Grid.Column="1"/>
<ItemsControl x:Name="IconList" Grid.Row="11" Grid.Column="1" ItemsSource="{Binding IconList}"/>
<Border Style="{StaticResource BorderStyle}" Grid.Row="12" Grid.Column="1">
<TextBlock x:Name="SerialNumber" Grid.Row="9" Grid.Column="1" Text="{Binding SerialNumber}"/>
<TextBlock x:Name="Upc" Grid.Row="10" Grid.Column="1" Text="{Binding Upc}"/>
<ContentControl x:Name="PresentationUrl" ContentTemplate="{StaticResource UrlDataTemplate}" Content="{Binding PresentationUrl}" Grid.Row="11" Grid.Column="1"/>
<ItemsControl x:Name="IconList" Grid.Row="12" Grid.Column="1" ItemsSource="{Binding IconList}"/>
<Border Style="{StaticResource BorderStyle}" Grid.Row="13" Grid.Column="1">
<Expander Header="ServiceList">
<ui:NoScrollDataGrid x:Name="ServiceList" ItemsSource="{Binding ServiceList}"/>
</Expander>
</Border>
<ItemsControl x:Name="DeviceList" Grid.Row="13" Grid.Column="1" ItemsSource="{Binding DeviceList}"/>
<ItemsControl x:Name="DeviceList" Grid.Row="14" Grid.Column="1" ItemsSource="{Binding DeviceList}"/>
</Grid>
</Expander>
</Border>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ protected override void FritzServiceViewModelPropertyChanged(object? sender, Pro
protected override bool GetCanExecuteDefaultCommand()
=> base.GetCanExecuteDefaultCommand() && (WanCommonInterfaceConfigGetOnlineMonitorResponse is null || SyncGroupIndex < WanCommonInterfaceConfigGetOnlineMonitorResponse!.Value.Key!.Value.TotalNumberSyncGroups);

private static void CreateUiElements(double yScale, double xScale, uint min, uint range, ICollection<UIElement> uiElements, IReadOnlyList<uint> values, Brush brush)
private static void CreateUiElements(double yScale, double xScale, uint min, uint range, List<UIElement> uiElements, IReadOnlyList<uint> values, Brush brush)
{
for (int i = 1; i < values.Count; i++)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ internal sealed class WanDslInterfaceConfigDslInfoViewModel : ObservableObject

public WanDslInterfaceConfigDslInfoViewModel()
{
DownstreamSnrElements = new();
DownstreamSnrElements = [];

maxBrush.Freeze();
minBrush.Freeze();
Expand All @@ -43,7 +43,7 @@ public List<UIElement>? DownstreamSnrElements
private set => _ = SetProperty(ref downstreamSnrElements, value);
}

private static void CreateUiElements(double yScale, double xScale, uint min, uint range, ICollection<UIElement> uiElements, IReadOnlyList<uint> values, Brush brush)
private static void CreateUiElements(double yScale, double xScale, uint min, uint range, List<UIElement> uiElements, IReadOnlyList<uint> values, Brush brush)
{
for (int i = 1; i < values.Count; i++)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ internal sealed class WanDslInterfaceConfigInfoViewModel : ObservableObject
private readonly Brush minBrush = Brushes.Orange;
private readonly Brush lineBrush = Brushes.Green;
private readonly ScaleTransform scaleYTransform = new() { ScaleY = -1d };
private readonly List<WanDslInterfaceConfigGetInfoResponse> wanDslInterfaceConfigGetInfoResponses = new();
private readonly List<WanDslInterfaceConfigGetInfoResponse> wanDslInterfaceConfigGetInfoResponses = [];

private KeyValuePair<WanDslInterfaceConfigGetInfoResponse?, UPnPFault?>? wanDslInterfaceConfigGetInfoResponse;
private List<UIElement>? downstreamMaxRateHistory;
Expand All @@ -27,16 +27,16 @@ internal sealed class WanDslInterfaceConfigInfoViewModel : ObservableObject

public WanDslInterfaceConfigInfoViewModel()
{
UpstreamCurrRateHistory = new();
DownstreamCurrRateHistory = new();
UpstreamMaxRateHistory = new();
DownstreamMaxRateHistory = new();
UpstreamNoiseMarginHistory = new();
DownstreamNoiseMarginHistory = new();
UpstreamAttenuationHistory = new();
DownstreamAttenuationHistory = new();
UpstreamPowerHistory = new();
DownstreamPowerHistory = new();
UpstreamCurrRateHistory = [];
DownstreamCurrRateHistory = [];
UpstreamMaxRateHistory = [];
DownstreamMaxRateHistory = [];
UpstreamNoiseMarginHistory = [];
DownstreamNoiseMarginHistory = [];
UpstreamAttenuationHistory = [];
DownstreamAttenuationHistory = [];
UpstreamPowerHistory = [];
DownstreamPowerHistory = [];

maxBrush.Freeze();
minBrush.Freeze();
Expand Down

0 comments on commit 4fd7e70

Please sign in to comment.