sharee.bike-App/LockIt.BLE/Services/BluetoothLock/BLE/PluginBleHelper.cs
2024-04-09 12:53:23 +02:00

36 lines
970 B
C#

using System;
namespace ShareeBike.Services.BluetoothLock.BLE
{
public static class PluginBleHelper
{
/// <summary>
/// Maps Plugin.BLE device state to LockIt.BusinessLogic device state.
/// </summary>
/// <param name="state">State to convert</param>
/// <returns></returns>
/// <exception cref="ArgumentException">Unexpected state detected.</exception>
public static DeviceState GetDeviceState(this Plugin.BLE.Abstractions.DeviceState state)
{
switch (state)
{
case Plugin.BLE.Abstractions.DeviceState.Disconnected:
return DeviceState.Disconnected;
case Plugin.BLE.Abstractions.DeviceState.Connecting:
return DeviceState.Connecting;
case Plugin.BLE.Abstractions.DeviceState.Connected:
return DeviceState.Connected;
case Plugin.BLE.Abstractions.DeviceState.Limited:
return DeviceState.Limited;
default:
throw new ArgumentException($"Can not convert state Plugin.BLE-{state}.");
}
}
}
}