sharee.bike-App/LockIt.BLE/Services/BluetoothLock/BLE/PluginBleHelper.cs

36 lines
970 B
C#
Raw Permalink Normal View History

2022-08-30 15:42:25 +02:00
using System;
2024-04-09 12:53:23 +02:00
namespace ShareeBike.Services.BluetoothLock.BLE
2022-08-30 15:42:25 +02:00
{
2022-09-06 16:08:19 +02:00
public static class PluginBleHelper
{
/// <summary>
2024-04-09 12:53:23 +02:00
/// Maps Plugin.BLE device state to LockIt.BusinessLogic device state.
2022-09-06 16:08:19 +02:00
/// </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;
2022-08-30 15:42:25 +02:00
2022-09-06 16:08:19 +02:00
case Plugin.BLE.Abstractions.DeviceState.Connecting:
return DeviceState.Connecting;
2022-08-30 15:42:25 +02:00
2022-09-06 16:08:19 +02:00
case Plugin.BLE.Abstractions.DeviceState.Connected:
return DeviceState.Connected;
2022-08-30 15:42:25 +02:00
2022-09-06 16:08:19 +02:00
case Plugin.BLE.Abstractions.DeviceState.Limited:
return DeviceState.Limited;
2022-08-30 15:42:25 +02:00
2022-09-06 16:08:19 +02:00
default:
throw new ArgumentException($"Can not convert state Plugin.BLE-{state}.");
}
}
2022-08-30 15:42:25 +02:00
2022-09-06 16:08:19 +02:00
}
2022-08-30 15:42:25 +02:00
}