sharee.bike-App/TINKLib/Model/Bikes/BikeInfoNS/BluetoothLock/LockInfoMutable.cs
Anja Müller-Meißner 573fe77e12 Version 3.0.337
2022-08-30 15:42:25 +02:00

53 lines
2.2 KiB
C#

using System;
namespace TINK.Model.Bikes.BikeInfoNS.BluetoothLock
{
public class LockInfoMutable : TINK.Model.Bikes.BikeInfoNS.BluetoothLock.ILockInfoMutable
{
/// <summary> Lock info object. </summary>
private Model.Bikes.BikeInfoNS.BluetoothLock.LockInfo LockInfo { get; set; }
/// <summary> Constructs a bluetooth lock info object. </summary>
/// <param name="id">Id of lock must always been known when constructing an lock info object.</param>
public LockInfoMutable(
int id,
Guid guid,
byte[] userKey,
byte[] adminKey,
byte[] seed,
Model.Bikes.BikeInfoNS.BluetoothLock.LockingState state)
{
LockInfo = new Model.Bikes.BikeInfoNS.BluetoothLock.LockInfo.Builder() { Id = id, Guid = guid, UserKey = userKey, AdminKey = adminKey, Seed = seed, State = state }.Build();
}
public int Id => LockInfo.Id;
/// <summary> Changes during runtime: Can be unknown when set from copri and chang to a valid value when set from lock.</summary>
public Guid Guid
{
get => LockInfo.Guid;
set => LockInfo = new Model.Bikes.BikeInfoNS.BluetoothLock.LockInfo.Builder(LockInfo) { Guid = value }.Build();
}
public byte[] Seed => LockInfo.Seed;
public byte[] UserKey => LockInfo.UserKey;
public byte[] AdminKey => LockInfo.AdminKey;
public Model.Bikes.BikeInfoNS.BluetoothLock.LockingState State
{
get => LockInfo.State;
set => LockInfo = new Model.Bikes.BikeInfoNS.BluetoothLock.LockInfo.Builder(LockInfo) { State = value }.Build();
}
/// <summary> Holds the percentage of lock battery.</summary>
public double BatteryPercentage { get; set; } = double.NaN;
/// <summary> Loads lock info object from values. </summary>
public void Load(int id, Guid guid, byte[] seed, byte[] userKey, byte[] adminKey)
{
LockInfo = new Model.Bikes.BikeInfoNS.BluetoothLock.LockInfo.Builder(LockInfo) { Id = id, Guid = guid, Seed = seed, UserKey = userKey, AdminKey = adminKey }.Build();
}
}
}