Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SensorDecoder URL #54

Merged
merged 2 commits into from
Dec 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@
<MudTextField @bind-Value="@_deviceModel.AppEUI" For="@(() => _deviceModel.AppEUI)" Margin="Margin.Dense" Variant="Variant.Outlined"></MudTextField>
</MudItem>
</MudItem>
<MudItem xs="12" Class="custom-form">
<MudItem xs="12" md="2" sm="7">
<MudText>Sensor Decoder URL :</MudText>
</MudItem>
<MudItem xs="12" md="4" sm="10">
<MudTextField @bind-Value="@_deviceModel.SensorDecoderURL" For="@(() => _deviceModel.SensorDecoderURL)" Margin="Margin.Dense" Variant="Variant.Outlined"></MudTextField>
</MudItem>
</MudItem>
<MudItem xs="12" Class="custom-form">
<MudItem xs="12" md="2" sm="7">
<MudText>Image :</MudText>
Expand Down Expand Up @@ -171,7 +179,7 @@

if (_selectedImage != null)
{
using (var ms = _selectedImage.OpenReadStream(maxAllowedSize: 512000*4))
using (var ms = _selectedImage.OpenReadStream(maxAllowedSize: 512000 * 4))
{
var streamContent = new StreamContent(ms);
streamContent.Headers.ContentType = new MediaTypeHeaderValue(_selectedImage.ContentType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@
<MudTextField @bind-Value="@DeviceModel.AppEUI" For="@(() => DeviceModel.AppEUI)" Margin="Margin.Dense" Variant="Variant.Outlined"></MudTextField>
</MudItem>
</MudItem>
<MudItem xs="12" Class="custom-form">
<MudItem xs="12" md="2" sm="7">
<MudText>Sensor Decoder URL :</MudText>
</MudItem>
<MudItem xs="12" md="4" sm="10">
<MudTextField @bind-Value="@DeviceModel.SensorDecoderURL" For="@(() => DeviceModel.SensorDecoderURL)" Margin="Margin.Dense" Variant="Variant.Outlined"></MudTextField>
</MudItem>
</MudItem>
<MudItem xs="12" Class="custom-form">
<MudItem xs="12" md="2" sm="7">
<MudText>Image :</MudText>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@
protected override async Task OnInitializedAsync()
{
Device.DeviceType = "LoRa Device";

// Enable device by default
Device.IsEnabled = true;

Expand Down Expand Up @@ -228,6 +228,7 @@
Device.ModelName = model.Name;
Device.ImageUrl = new Uri(model.ImageUrl);
Device.AppEUI = model.AppEUI ?? "Selected model contains no AppEUI value";
Device.SensorDecoder = model.SensorDecoderURL;
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ public DeviceModel CreateDeviceModel(TableEntity entity)
ImageUrl = this.deviceModelImageManager.ComputeImageUri(entity.RowKey).ToString(),
Name = entity[nameof(DeviceModel.Name)]?.ToString(),
Description = entity[nameof(DeviceModel.Description)]?.ToString(),
AppEUI = entity[nameof(DeviceModel.AppEUI)]?.ToString()
AppEUI = entity[nameof(DeviceModel.AppEUI)]?.ToString(),
SensorDecoderURL = entity[nameof(DeviceModel.SensorDecoderURL)]?.ToString()
};
}

Expand All @@ -33,6 +34,7 @@ public void UpdateTableEntity(TableEntity entity, DeviceModel model)
entity[nameof(DeviceModel.Name)] = model.Name;
entity[nameof(DeviceModel.Description)] = model.Description;
entity[nameof(DeviceModel.AppEUI)] = model.AppEUI;
entity[nameof(DeviceModel.SensorDecoderURL)] = model.SensorDecoderURL;
}
}
}
2 changes: 2 additions & 0 deletions src/AzureIoTHub.Portal/Server/Mappers/DeviceTwinMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public DeviceDetails CreateDeviceDetails(Twin twin)
AppKey = Helpers.DeviceHelper.RetrievePropertyValue(twin, nameof(DeviceDetails.AppKey)),
LocationCode = Helpers.DeviceHelper.RetrieveTagValue(twin, nameof(DeviceDetails.LocationCode)),
AssetID = Helpers.DeviceHelper.RetrieveTagValue(twin, nameof(DeviceDetails.AssetID)),
SensorDecoder = Helpers.DeviceHelper.RetrievePropertyValue(twin, nameof(DeviceDetails.SensorDecoder)),
DeviceType = Helpers.DeviceHelper.RetrieveTagValue(twin, nameof(DeviceDetails.DeviceType)),
Commands = this.RetrieveCommands(modelName)
};
Expand Down Expand Up @@ -72,6 +73,7 @@ public void UpdateTwin(Twin twin, DeviceDetails item)
// Update the twin properties
twin.Properties.Desired[nameof(item.AppEUI)] = item.AppEUI;
twin.Properties.Desired[nameof(item.AppKey)] = item.AppKey;
twin.Properties.Desired[nameof(item.SensorDecoder)] = item.SensorDecoder;
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ public class DeviceDetails

public string ModelName { get; set; }

public string SensorDecoder { get; set; }

public List<Command> Commands { get; set; } = new List<Command>();
}
}
2 changes: 2 additions & 0 deletions src/AzureIoTHub.Portal/Shared/Models/DeviceModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ public class DeviceModel
[Required]
public string AppEUI { get; set; }

public string SensorDecoderURL { get; set; }

public List<DeviceModelCommand> Commands { get; set; }

public DeviceModel()
Expand Down