Fix the GetStationTwinAsync to be handle non existing twins (#2074)
* Change get twin to return null when non existing device * Change to be like other patterns
This commit is contained in:
Родитель
d9848b6d0e
Коммит
d301be6799
|
@ -4,19 +4,13 @@
|
|||
namespace LoRaTools.IoTHubImpl
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Net.Http;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using LoRaWan;
|
||||
using Microsoft.Azure.Devices;
|
||||
using Microsoft.Azure.Devices.Shared;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
public sealed class IoTHubRegistryManager : IDeviceRegistryManager, IDisposable
|
||||
{
|
||||
|
@ -83,9 +77,6 @@ namespace LoRaTools.IoTHubImpl
|
|||
return new IoTHubLoRaDeviceTwinPageResult(q);
|
||||
}
|
||||
|
||||
public async Task<IStationTwin> GetStationTwinAsync(StationEui stationEui, CancellationToken? cancellationToken = null)
|
||||
=> new IoTHubStationTwin(await this.instance.GetTwinAsync(stationEui.ToString(), cancellationToken ?? CancellationToken.None));
|
||||
|
||||
public IRegistryPageResult<ILoRaDeviceTwin> GetLastUpdatedLoRaDevices(DateTime lastUpdateDateTime)
|
||||
{
|
||||
var formattedDateTime = lastUpdateDateTime.ToString(Constants.RoundTripDateTimeStringFormat, CultureInfo.InvariantCulture);
|
||||
|
@ -116,5 +107,7 @@ namespace LoRaTools.IoTHubImpl
|
|||
|
||||
public async Task<IDeviceTwin> GetTwinAsync(string deviceId, CancellationToken? cancellationToken = null)
|
||||
=> await this.instance.GetTwinAsync(deviceId, cancellationToken ?? CancellationToken.None) is { } twin ? new IoTHubDeviceTwin(twin) : null;
|
||||
public async Task<IStationTwin> GetStationTwinAsync(StationEui stationEui, CancellationToken? cancellationToken = null)
|
||||
=> await this.instance.GetTwinAsync(stationEui.ToString(), cancellationToken ?? CancellationToken.None) is { } twin ? new IoTHubStationTwin(twin) : null;
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче