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

36 lines
956 B
C#
Raw Normal View History

2022-08-30 15:42:25 +02:00
using System;
namespace TINK.Services.BluetoothLock.BLE
{
2022-09-06 16:08:19 +02:00
public static class PluginBleHelper
{
/// <summary>
/// Maps Plugin.BLE device state to LockItShared 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;
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
}