Skip to content

Commit

Permalink
Re-order lora device properties in model
Browse files Browse the repository at this point in the history
  • Loading branch information
kbeaugrand committed Mar 12, 2022
1 parent 45a2e3b commit 3f0d156
Show file tree
Hide file tree
Showing 3 changed files with 107 additions and 93 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,105 +8,99 @@
</CardHeaderContent>
</MudCardHeader>
<MudCardContent>
<MudGrid>

<MudItem xs="12" Class="mb-4">
<MudText >@(LoRaDeviceModel.UseOTAA ? "OTAA setting enable" : "APB setting enable")</MudText>
<MudGrid>
<MudItem xs="12">
<MudText>@(LoRaDeviceModel.UseOTAA ? "OTAA setting enable" : "APB setting enable")</MudText>
</MudItem>

<MudDivider Class="my-4"></MudDivider>

<MudItem xs="12">
@if (LoRaDeviceModel.UseOTAA)
{
<MudItem xs="12" Class="mb-4">
<MudItem md="6" xs=12>
<MudGrid>
@if (LoRaDeviceModel.UseOTAA)
{
<MudItem xs="12">
<MudTextField @bind-Value="@LoRaDeviceModel.AppEUI" Label="OTAA AppEUI" For="@(() => LoRaDeviceModel.AppEUI)" Margin="Margin.Dense" Variant="Variant.Outlined" Required="true"></MudTextField>
</MudItem>
}
else
{
<MudItem xs="12" Class="mb-4">
}
else
{
<MudItem xs="12">
<MudSwitch T="bool?" @bind-Checked="@LoRaDeviceModel.ABPRelaxMode" For="@(() => LoRaDeviceModel.ABPRelaxMode)" Label="Disable ABP relax mode" Color="Color.Primary"></MudSwitch>
</MudItem>
}
<MudItem xs="12" Class="mb-4">
<MudTextField @bind-Value="@LoRaDeviceModel.SensorDecoder" Label="Sensor Decoder URL" For="@(() => LoRaDeviceModel.SensorDecoder)" Margin="Margin.Dense" Variant="Variant.Outlined"></MudTextField>
</MudItem>

}
<MudItem xs="12">
<MudTextField @bind-Value="@LoRaDeviceModel.SensorDecoder" Label="Sensor Decoder URL" For="@(() => LoRaDeviceModel.SensorDecoder)" Margin="Margin.Dense" Variant="Variant.Outlined"></MudTextField>
</MudItem>
</MudGrid>
</MudItem>
<MudItem xs="12" md=6>

<MudItem xs="12" Class="mb-4">
<MudSwitch T=bool? @bind-Checked="@LoRaDeviceModel.Downlink" For="@(() => LoRaDeviceModel.Downlink)" Label="Enable/disable downstream messages" Color="Color.Primary"></MudSwitch>
</MudItem>

<MudItem xs="12" Class="mb-4">
<MudSelect T=string @bind-Value="@LoRaDeviceModel.Deduplication" For="@(() => LoRaDeviceModel.Deduplication)" AnchorOrigin="Origin.BottomCenter" Label="Message Deduplication" Margin="Margin.Dense" Variant="Variant.Outlined">
<MudSelectItem Value="@("Mark")"></MudSelectItem>
<MudSelectItem Value="@("Drop")"></MudSelectItem>
<MudSelectItem Value="@("None")"></MudSelectItem>
</MudSelect>
</MudItem>
<MudItem md="6" xs=12>
<MudGrid>
<MudItem md="6" xs="12">
<MudNumericField @bind-Value="@LoRaDeviceModel.KeepAliveTimeout" For="@(() => LoRaDeviceModel.KeepAliveTimeout)" Min=1 Label="Device Connection Timeout" Margin="Margin.Dense" Variant="Variant.Outlined"></MudNumericField>
</MudItem>
<MudItem md="6" xs="12">
<MudSelect T=string @bind-Value="@LoRaDeviceModel.Deduplication" For="@(() => LoRaDeviceModel.Deduplication)" AnchorOrigin="Origin.BottomCenter" Label="Message Deduplication" Margin="Margin.Dense" Variant="Variant.Outlined">
<MudSelectItem Value="@("Mark")"></MudSelectItem>
<MudSelectItem Value="@("Drop")"></MudSelectItem>
<MudSelectItem Value="@("None")"></MudSelectItem>
</MudSelect>
</MudItem>
</MudGrid>
</MudItem>
<MudItem xs="6">

<MudItem xs="12" Class="mb-4">
<MudNumericField T="int?" @bind-Value="@LoRaDeviceModel.KeepAliveTimeout" For="@(() => LoRaDeviceModel.KeepAliveTimeout)" Min=1 Label="Device Connection Timeout" Margin="Margin.Dense" Variant="Variant.Outlined"></MudNumericField>
</MudItem>

<MudItem xs="12" Class="mb-4">
<MudNumericField T="int?" @bind-Value="@LoRaDeviceModel.PreferredWindow" For="@(() => LoRaDeviceModel.PreferredWindow)" Min="1" Max="2" Label="Preferred receive window" Margin="Margin.Dense" Variant="Variant.Outlined"></MudNumericField>
</MudItem>

</MudItem>


</MudGrid>

<MudDivider Class="my-4"></MudDivider>

<MudGrid >

<MudGrid>
<MudItem xs="12" md="6">
<MudText Typo=Typo.h5 Class="mb-4">Test RX Thingy</MudText>

<MudItem xs="12" md="8" Class="mb-4">
<MudNumericField T="int?" @bind-Value="@LoRaDeviceModel.RX1DROffset" For="@(() => LoRaDeviceModel.RX1DROffset)" Label="RX1 Datarate Offset" Margin="Margin.Dense" Variant="Variant.Outlined"></MudNumericField>
</MudItem>

<MudItem xs="12" md="8" Class="mb-4">
<MudNumericField T=int? @bind-Value="@LoRaDeviceModel.RX2DataRate" For="@(() => LoRaDeviceModel.RX2DataRate)" Label="RX2 Datarate" Margin="Margin.Dense" Variant="Variant.Outlined"></MudNumericField>
</MudItem>

<MudItem xs="12" md="8" Class="mb-4">
<MudNumericField T="int?" @bind-Value="@LoRaDeviceModel.RXDelay" For="@(() => LoRaDeviceModel.RXDelay)" Min=1 Label="RX Delay" Margin="Margin.Dense" Variant="Variant.Outlined"></MudNumericField>
</MudItem>

<MudText Typo=Typo.h5 Class="mb-4">Receive Windows</MudText>
<MudGrid>
<MudItem xs="12">
<MudSwitch @bind-Checked="@LoRaDeviceModel.Downlink" For="@(() => LoRaDeviceModel.Downlink)" Label="Enable/disable downstream messages" Color="Color.Primary"></MudSwitch>
</MudItem>
@if (LoRaDeviceModel.Downlink.HasValue && LoRaDeviceModel.Downlink.Value)
{
<MudItem xs="12" md="6">
<MudNumericField @bind-Value="@LoRaDeviceModel.PreferredWindow" For="@(() => LoRaDeviceModel.PreferredWindow)" Min="1" Max="2" Label="Preferred receive window" Margin="Margin.Dense" Variant="Variant.Outlined"></MudNumericField>
</MudItem>
<MudItem xs="12" md="6">
<MudNumericField @bind-Value="@LoRaDeviceModel.RXDelay" For="@(() => LoRaDeviceModel.RXDelay)" Min=1 Label="RX Delay" Margin="Margin.Dense" Variant="Variant.Outlined"></MudNumericField>
</MudItem>
<MudItem xs="12" md="6">
<MudNumericField @bind-Value="@LoRaDeviceModel.RX1DROffset" For="@(() => LoRaDeviceModel.RX1DROffset)" Label="RX1 Datarate Offset" Margin="Margin.Dense" Variant="Variant.Outlined"></MudNumericField>
</MudItem>
<MudItem xs="12" md="6">
<MudNumericField @bind-Value="@LoRaDeviceModel.RX2DataRate" For="@(() => LoRaDeviceModel.RX2DataRate)" Label="RX2 Datarate" Margin="Margin.Dense" Variant="Variant.Outlined"></MudNumericField>
</MudItem>
}
</MudGrid>
</MudItem>

<MudItem xs="6">
<MudText Typo=Typo.h5 Class="mb-4">Test Counter Thingy</MudText>

<MudItem xs="12" md="8" Class="mb-4">
<MudNumericField T="int?" @bind-Value="@LoRaDeviceModel.FCntUpStart" For="@(() => LoRaDeviceModel.FCntUpStart)" Min=1 Label="Specify frame counter up start value" Margin="Margin.Dense" Variant="Variant.Outlined"></MudNumericField>
</MudItem>

<MudItem xs="12" md="8" Class="mb-4">
<MudNumericField @bind-Value="@LoRaDeviceModel.FCntDownStart" For="@(() => LoRaDeviceModel.FCntDownStart)" Min=1 Label="Specify frame counter down start value" Margin="Margin.Dense" Variant="Variant.Outlined"></MudNumericField>
</MudItem>

<MudItem xs="12" md="8" Class="mb-4">
<MudNumericField T="int?" @bind-Value="@LoRaDeviceModel.FCntResetCounter" For="@(() => LoRaDeviceModel.FCntResetCounter)" Min=1 Label="Reset counter" Margin="Margin.Dense" Variant="Variant.Outlined"></MudNumericField>
</MudItem>

<MudItem xs="12" md="8" Class="mb-4">
<MudSwitch T="bool?" @bind-Checked="@LoRaDeviceModel.Supports32BitFCnt" For="@(() => LoRaDeviceModel.Supports32BitFCnt)" Label="32bit counter support" Color="Color.Primary" Margin="Margin.Dense" Variant="Variant.Outlined"></MudSwitch>
</MudItem>

<MudText Typo=Typo.h5 Class="mb-4">Frame Counters</MudText>
<MudGrid>
<MudItem xs="12">
<MudSwitch @bind-Checked="@LoRaDeviceModel.Supports32BitFCnt" For="@(() => LoRaDeviceModel.Supports32BitFCnt)" Label="32bit counter support" Color="Color.Primary" Margin="Margin.Dense" Variant="Variant.Outlined"></MudSwitch>
</MudItem>
<MudItem xs="12" md="6">
<MudNumericField @bind-Value="@LoRaDeviceModel.FCntUpStart" For="@(() => LoRaDeviceModel.FCntUpStart)" Min=0 Label="Frame counter up start value" Margin="Margin.Dense" Variant="Variant.Outlined"></MudNumericField>
</MudItem>
@if (LoRaDeviceModel.Downlink.HasValue && LoRaDeviceModel.Downlink.Value)
{
<MudItem xs="12" md="6">
<MudNumericField @bind-Value="@LoRaDeviceModel.FCntDownStart" For="@(() => LoRaDeviceModel.FCntDownStart)" Min=0 Label="Frame counter down start value" Margin="Margin.Dense" Variant="Variant.Outlined"></MudNumericField>
</MudItem>
<MudItem xs="12" md="6">
<MudNumericField @bind-Value="@LoRaDeviceModel.FCntResetCounter" For="@(() => LoRaDeviceModel.FCntResetCounter)" Min=0 Label="Frame counter reset counter value" Margin="Margin.Dense" Variant="Variant.Outlined"></MudNumericField>
</MudItem>
}
</MudGrid>
</MudItem>

</MudGrid>

<MudDivider Class="my-4"></MudDivider>

@if (LoRaDeviceModel.Downlink.HasValue && LoRaDeviceModel.Downlink.Value)
{
<MudItem xs="12">
<MudTable Items="@Commands" Dense=true Hover=true Bordered=true Striped=true>
<ToolBarContent>
Expand All @@ -130,10 +124,10 @@
<MudTextField @bind-Value="@CommandContext.Name" Label="Name" For="@(() => CommandContext.Name)" Margin="Margin.Dense" Variant="Variant.Outlined" Required="true" Disabled="CommandContext.IsBuiltin"></MudTextField>
</MudTd>
<MudTd DataLabel="Frame" Style="word-break: break-all; ">
<MudTextField @bind-Value="@CommandContext.Frame" Label="Frame" For="@(() => CommandContext.Frame)" Margin="Margin.Dense" Variant="Variant.Outlined" Required="true" Disabled="CommandContext.IsBuiltin"></MudTextField>
<MudTextField @bind-Value="@CommandContext.Frame" Label="Frame" For="@(() => CommandContext.Frame)" Margin="Margin.Dense" Variant="Variant.Outlined" Required="true" Disabled="CommandContext.IsBuiltin"></MudTextField>
</MudTd>
<MudTd DataLabel="Port" Style="text-align: center;">
<MudNumericField @bind-Value="@CommandContext.Port" Label="Port" For="@(() => CommandContext.Port)" Margin="Margin.Dense" Variant="Variant.Outlined" Disabled="CommandContext.IsBuiltin"></MudNumericField>
<MudNumericField @bind-Value="@CommandContext.Port" Label="Port" For="@(() => CommandContext.Port)" Margin="Margin.Dense" Variant="Variant.Outlined" Disabled="CommandContext.IsBuiltin"></MudNumericField>
</MudTd>
<MudTd DataLabel="Delete" Style="text-align: center">
<MudIconButton Color="Color.Default" Icon="@Icons.Material.Filled.Delete" Size="Size.Medium" Disabled="@CommandContext.IsBuiltin" OnClick="@(() => DeleteCommand(CommandContext))"></MudIconButton>
Expand All @@ -144,7 +138,7 @@
</FooterContent>
</MudTable>
</MudItem>

}
</MudCardContent>
<MudCardActions Class="pb-4 pl-4">
<MudButton Variant="Variant.Filled" Color="Color.Primary" Class="ml-auto" OnClick="OnSaveClick">Save Changes</MudButton>
Expand Down
15 changes: 15 additions & 0 deletions src/AzureIoTHub.Portal/Shared/Models/v1.0/LoRaWAN/ClassType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright (c) CGI France. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

namespace AzureIoTHub.Portal.Shared.Models.v10.LoRaWAN
{
using System.Text.Json.Serialization;

[JsonConverter(typeof(JsonStringEnumConverter))]
public enum ClassType
{
A,
B,
C
}
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
// Copyright (c) CGI France. All rights reserved.
// Copyright (c) CGI France. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

namespace AzureIoTHub.Portal.Shared.Models.v10.LoRaWAN
{
using System.ComponentModel.DataAnnotations;
using AzureIoTHub.Portal.Shared.Models.V10.DeviceModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

public class LoRaDeviceModelBase : DeviceModel
{
/// <summary>
/// The LoRa device class.
/// </summary>
public ClassType ClassType { get; set; }

/// <summary>
/// The status of OTAA setting.
/// </summary>
Expand Down Expand Up @@ -75,22 +76,25 @@ public class LoRaDeviceModelBase : DeviceModel
/// Allows to explicitly specify a frame counter up start value.
/// If the device joins, this value will be used to validate the first frame and initialize the server state for the device.
/// </summary>
[Range(0, 4294967295)]
public int? FCntUpStart { get; set; }

/// <summary>
/// Allows to explicitly specify a frame counter down start value.
/// </summary>
[Range(0, 4294967295)]
public int? FCntDownStart { get; set; }

/// <summary>
/// Allow the usage of 32bit counters on your device.
/// Allows to reset the frame counters to the FCntUpStart/FCntDownStart values respectively.
/// </summary>
public bool? Supports32BitFCnt { get; set; }
[Range(0, 4294967295)]
public int? FCntResetCounter { get; set; }

/// <summary>
/// Allows to reset the frame counters to the FCntUpStart/FCntDownStart values respectively.
/// Allow the usage of 32bit counters on your device.
/// </summary>
public int? FCntResetCounter { get; set; }
public bool? Supports32BitFCnt { get; set; }

/// <summary>
/// Allows defining a sliding expiration to the connection between the leaf device and IoT/Edge Hub.
Expand All @@ -100,6 +104,7 @@ public class LoRaDeviceModelBase : DeviceModel

public LoRaDeviceModelBase()
{
this.ClassType = ClassType.A;
this.Downlink = true;
this.PreferredWindow = 1;
this.Deduplication = "None";
Expand Down

0 comments on commit 3f0d156

Please sign in to comment.