* Upgrade device sdk versions

* Fix Mac issues

* Fix indentation

* Correct test
This commit is contained in:
Mandur 2021-05-16 14:11:28 +02:00 коммит произвёл GitHub
Родитель b37938ea21
Коммит 83caedb89f
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
9 изменённых файлов: 55 добавлений и 14 удалений

Просмотреть файл

@ -5,7 +5,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Docker.DotNet.X509" Version="3.125.2" />
<PackageReference Include="Microsoft.Azure.Devices" Version="1.31.0" />
<PackageReference Include="Microsoft.Azure.Devices" Version="1.33.0" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="3.1.5" />
<PackageReference Include="Microsoft.Azure.Functions.Extensions" Version="1.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.1.5" />

Просмотреть файл

@ -10,7 +10,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.Devices.Client" Version="1.31.0" />
<PackageReference Include="Microsoft.Azure.Devices.Client" Version="1.37.1" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="2.1.1" />

Просмотреть файл

@ -5,7 +5,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.Devices.Client" Version="1.31.0" />
<PackageReference Include="Microsoft.Azure.Devices.Client" Version="1.37.1" />
</ItemGroup>
<!-- StyleCop Setup -->

Просмотреть файл

@ -5,6 +5,7 @@ namespace LoRaTools
{
using System;
using System.Collections.Generic;
using LoRaTools.Mac;
using LoRaTools.Utils;
using Newtonsoft.Json;
@ -85,12 +86,12 @@ namespace LoRaTools
}
else
{
throw new Exception("LinkADRRequest C2D properties must be in String Integer style");
throw new MacCommandException("LinkADRRequest C2D properties must be in String Integer style");
}
}
else
{
throw new Exception("LinkADRRequest C2D must have have the following message properties set : datarate, txpower, chMask, chMaskCntl, nbTrans");
throw new MacCommandException("LinkADRRequest C2D must have have the following message properties set : datarate, txpower, chMask, chMaskCntl, nbTrans");
}
}

Просмотреть файл

@ -50,9 +50,9 @@ namespace LoRaTools
int pointer = 0;
var macCommands = new List<MacCommand>(3);
while (pointer < input.Length)
try
{
try
while (pointer < input.Length)
{
CidEnum cid = (CidEnum)input.Span[pointer];
switch (cid)
@ -111,10 +111,10 @@ namespace LoRaTools
MacCommand addedMacCommand = macCommands[macCommands.Count - 1];
Logger.Log(deviceId, $"{addedMacCommand.Cid} mac command detected in upstream payload: {addedMacCommand.ToString()}", LogLevel.Debug);
}
catch (MacCommandException ex)
{
Logger.Log(deviceId, ex.ToString(), LogLevel.Error);
}
}
catch (MacCommandException ex)
{
Logger.Log(deviceId, ex.ToString(), LogLevel.Error);
}
return macCommands;

Просмотреть файл

@ -5,6 +5,7 @@ namespace LoRaTools
{
using System;
using System.Collections.Generic;
using LoRaTools.Mac;
using Newtonsoft.Json;
/// <summary>
@ -36,7 +37,7 @@ namespace LoRaTools
{
if (readOnlySpan.Length < this.Length)
{
throw new Exception("RXParamSetupAnswer detected but the byte format is not correct");
throw new MacCommandException("RXParamSetupAnswer detected but the byte format is not correct");
}
else
{

Просмотреть файл

@ -14,7 +14,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.Devices" Version="1.31.0" />
<PackageReference Include="Microsoft.Azure.Devices" Version="1.33.0" />
<PackageReference Include="Microsoft.Azure.EventHubs" Version="4.2.0" />
<PackageReference Include="Microsoft.Azure.EventHubs.Processor" Version="4.2.0" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="3.1.5" />

Просмотреть файл

@ -10,7 +10,7 @@
<ItemGroup>
<PackageReference Include="Docker.DotNet" Version="3.125.2" />
<PackageReference Include="Microsoft.Azure.Devices" Version="1.31.0" />
<PackageReference Include="Microsoft.Azure.Devices" Version="1.33.0" />
<PackageReference Include="Microsoft.Azure.EventHubs" Version="4.2.0" />
<PackageReference Include="Microsoft.Azure.EventHubs.Processor" Version="4.2.0" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="3.1.5" />

Просмотреть файл

@ -9,6 +9,8 @@ namespace LoRaWan.NetworkServer.Test
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using LoRaTools.LoRaMessage;
using LoRaTools.LoRaPhysical;
using LoRaTools.Mac;
using LoRaWan.NetworkServer;
using LoRaWan.Test.Shared;
using Microsoft.Azure.Devices.Client;
@ -200,6 +202,43 @@ namespace LoRaWan.NetworkServer.Test
Assert.Equal(10U, loraDevice.FCntUp);
}
[Fact]
public void When_Faulty_MAC_Message_Is_Received_Processing_Abort_Without_Infinite_Loop()
{
var simulatedDevice = new SimulatedDevice(TestDeviceInfo.CreateABPDevice(1, gatewayID: this.ServerConfiguration.GatewayID));
var payload = simulatedDevice.CreateUnconfirmedDataUpMessage("1234", fcnt: 10);
simulatedDevice.FrmCntUp = 9;
// Create Rxpk
var rxpk = payload.SerializeUplink(simulatedDevice.AppSKey, simulatedDevice.NwkSKey).Rxpk[0];
var loraDevice = this.CreateLoRaDevice(simulatedDevice);
this.LoRaDeviceClient.Setup(x => x.SendEventAsync(It.IsNotNull<LoRaDeviceTelemetry>(), null))
.ReturnsAsync(true);
this.LoRaDeviceClient.Setup(x => x.ReceiveAsync(It.IsNotNull<TimeSpan>()))
.ReturnsAsync((Message)null);
var deviceRegistry = new LoRaDeviceRegistry(this.ServerConfiguration, this.NewNonEmptyCache(loraDevice), this.LoRaDeviceApi.Object, this.LoRaDeviceFactory);
// Send to message processor
var messageProcessor = new MessageDispatcher(
this.ServerConfiguration,
deviceRegistry,
this.FrameCounterUpdateStrategyProvider);
var request = new LoRaRequest(
new Rxpk
{
Data = "QDDaAAGxfh0FAI6wAENHbvgt1UK5Je1uPo/bLPB9HlnOXLGlLRUrTtA0KOHrZhusGl+L4g=="
},
null,
DateTime.Now);
messageProcessor.DispatchRequest(request);
}
[Fact]
public async Task OTAA_Confirmed_Message_Should_Send_Data_To_IotHub_Update_FcntUp_And_Return_DownstreamMessage()
{