sharee.bike-App/LockItShared/Services/BluetoothLock/Tdo/LockInfoAuthTdo.cs

62 lines
2 KiB
C#
Raw Normal View History

2022-08-30 15:42:25 +02:00
using System;
using TINK.Model.Connector;
2021-05-13 17:07:16 +02:00
namespace TINK.Services.BluetoothLock.Tdo
{
2022-09-06 16:08:19 +02:00
/// <summary> Data required to connect to a blutooth lock.</summary>
public class LockInfoAuthTdo
{
/// <summary> Identification number of bluetooth lock, 6-digits, second part of advertisement name.</summary>
public int Id { get; private set; }
2021-05-13 17:07:16 +02:00
2022-09-06 16:08:19 +02:00
/// <summary> GUID to the device. </summary>
public Guid Guid { get; private set; }
2021-05-13 17:07:16 +02:00
2022-09-06 16:08:19 +02:00
/// <summary> Seed used to generate key for connecting to bluetooth lock.</summary>
public byte[] K_seed { get; private set; }
2021-05-13 17:07:16 +02:00
2022-09-06 16:08:19 +02:00
/// <summary> Key for connect to bluetooth lock as user.</summary>
public byte[] K_u { get; private set; }
2021-05-13 17:07:16 +02:00
2022-09-06 16:08:19 +02:00
/// <summary> Key for connect to bluetooth lock as admin.</summary>
public byte[] K_a { get; private set; }
2021-05-13 17:07:16 +02:00
2022-09-06 16:08:19 +02:00
public bool IsIdValid => Id != TextToLockItTypeHelper.INVALIDLOCKID;
2021-05-13 17:07:16 +02:00
2022-09-06 16:08:19 +02:00
public bool IsGuidValid => Guid != TextToLockItTypeHelper.INVALIDLOCKGUID;
2021-05-13 17:07:16 +02:00
2022-09-06 16:08:19 +02:00
public class Builder
{
private LockInfoAuthTdo lockInfoTdo = new LockInfoAuthTdo();
2021-05-13 17:07:16 +02:00
2022-09-06 16:08:19 +02:00
public Builder() { }
2021-05-13 17:07:16 +02:00
2022-09-06 16:08:19 +02:00
/// <summary> Identification number of bluetooth lock, 6-digits, second part of advertisement name.</summary>
public int Id { get => lockInfoTdo.Id; set { lockInfoTdo.Id = value; } }
2021-05-13 17:07:16 +02:00
2022-09-06 16:08:19 +02:00
/// <summary> GUID to the device. </summary>
public Guid Guid { get => lockInfoTdo.Guid; set { lockInfoTdo.Guid = value; } }
2021-05-13 17:07:16 +02:00
2022-09-06 16:08:19 +02:00
/// <summary> Seed used to generate key for connecting to bluetooth lock.</summary>
public byte[] K_seed { get => lockInfoTdo.K_seed; set { lockInfoTdo.K_seed = value; } }
2021-05-13 17:07:16 +02:00
2022-09-06 16:08:19 +02:00
/// <summary> Key for connect to bluetooth lock as user.</summary>
public byte[] K_u { get => lockInfoTdo.K_u; set { lockInfoTdo.K_u = value; } }
2021-05-13 17:07:16 +02:00
2022-09-06 16:08:19 +02:00
/// <summary> Key for connect to bluetooth lock as admin.</summary>
public byte[] K_a { get => lockInfoTdo.K_a; set { lockInfoTdo.K_a = value; } }
2021-05-13 17:07:16 +02:00
2022-09-06 16:08:19 +02:00
public LockInfoAuthTdo Build()
{
if (K_seed == null) K_seed = new byte[0];
2021-05-13 17:07:16 +02:00
2022-09-06 16:08:19 +02:00
if (K_u == null) K_u = new byte[0];
2021-05-13 17:07:16 +02:00
2022-09-06 16:08:19 +02:00
if (K_a == null) K_a = new byte[0];
2021-05-13 17:07:16 +02:00
2022-09-06 16:08:19 +02:00
return lockInfoTdo;
}
}
}
2021-05-13 17:07:16 +02:00
}