Version 3.0.337

This commit is contained in:
Anja Müller-Meißner 2022-08-30 15:42:25 +02:00
parent fd0e63cf10
commit 573fe77e12
2336 changed files with 33688 additions and 86082 deletions

View file

@ -6,6 +6,7 @@
<TranslationReport Condition="'$(Configuration)' == 'Release'">true</TranslationReport>
<SuppressPseudoWarning Condition="'$(Configuration)' == 'Debug'">true</SuppressPseudoWarning>
<Configurations>Debug;Release</Configurations>
<ReleaseVersion>3.0</ReleaseVersion>
</PropertyGroup>
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
@ -23,7 +24,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="Serilog" Version="2.10.0" />
<PackageReference Include="Serilog" Version="2.11.0" />
</ItemGroup>
<ItemGroup>
<Compile Update="MultilingualResources\Resources.Designer.cs">

View file

@ -1,4 +1,4 @@
namespace TINK.Model.Bike.BluetoothLock
namespace TINK.Model.Bikes.BikeInfoNS.BluetoothLock
{
public interface ILockInfo
{

View file

@ -1,9 +1,9 @@
using TINK.Model.Connector;
using Newtonsoft.Json;
using System;
using System;
using System.Runtime.Serialization;
using Newtonsoft.Json;
using TINK.Model.Connector;
namespace TINK.Model.Bike.BluetoothLock
namespace TINK.Model.Bikes.BikeInfoNS.BluetoothLock
{
/// <summary> Locking states. </summary>
public enum LockingState
@ -53,7 +53,7 @@ namespace TINK.Model.Bike.BluetoothLock
public bool IsGuidValid => Guid != TextToLockItTypeHelper.INVALIDLOCKGUID;
public override bool Equals(object obj) => this.Equals(obj as LockInfo);
public override bool Equals(object obj) => this.Equals(obj as LockInfo);
public bool Equals(LockInfo other)
{
@ -76,7 +76,7 @@ namespace TINK.Model.Bike.BluetoothLock
public static bool operator ==(LockInfo lhs, LockInfo rhs)
{
if (Object.ReferenceEquals(lhs, null))
if (Object.ReferenceEquals(lhs, null))
return Object.ReferenceEquals(rhs, null) ? true /*null == null = true*/: false;
return lhs.Equals(rhs);
@ -101,25 +101,25 @@ namespace TINK.Model.Bike.BluetoothLock
private readonly LockInfo LockInfo = new LockInfo();
public byte[] UserKey { get => LockInfo.UserKey; set => LockInfo.UserKey = value; }
public byte[] UserKey { get => LockInfo.UserKey; set => LockInfo.UserKey = value; }
public byte[] AdminKey { get => LockInfo.AdminKey; set => LockInfo.AdminKey = value; }
public byte[] Seed { get => LockInfo.Seed; set => LockInfo.Seed = value; }
public int Id { get => LockInfo.Id; set => LockInfo.Id = value; }
public Guid Guid { get => LockInfo.Guid; set => LockInfo.Guid = value; }
public LockingState State { get => LockInfo.State; set => LockInfo.State = value; }
public LockingState State { get => LockInfo.State; set => LockInfo.State = value; }
public LockInfo Build()
{
// Ensure consistency.
if ((UserKey?.Length > 0 || Seed?.Length > 0)
if ((UserKey?.Length > 0 || Seed?.Length > 0)
&& (UserKey?.Length == 0 || Seed?.Length == 0 || !LockInfo.IsIdValid))
throw new ArgumentException($"Can not build {typeof(LockInfo).Name}. Lock parameters must either be all know or all unknown.");
throw new ArgumentException($"Can not build {typeof(LockInfo).Name}. Lock parameters must either be all know or all unknown.");
if (UserKey == null) UserKey = new byte[0];
if (AdminKey == null) AdminKey = new byte[0];
if (Seed == null) Seed = new byte[0];

View file

@ -1,4 +1,4 @@
namespace TINK.Model.Bikes.Bike.CopriLock
namespace TINK.Model.Bikes.BikeInfoNS.CopriLock
{
public interface ILockInfo
{

View file

@ -1,8 +1,8 @@
using Newtonsoft.Json;
using System;
using System;
using System.Runtime.Serialization;
using Newtonsoft.Json;
namespace TINK.Model.Bikes.Bike.CopriLock
namespace TINK.Model.Bikes.BikeInfoNS.CopriLock
{
/// <summary> Locking states. </summary>
public enum LockingState

View file

@ -10,7 +10,7 @@ namespace TINK.Model.Connector
/// <summary> Lock GUID which representing a non valid id. </summary>
public readonly static Guid INVALIDLOCKGUID = new Guid();
/// <summary> First part of advertisement name.</summary>
public static string ISHAREITADVERTISMENTTITLE = "ISHAREIT";

View file

@ -58,7 +58,7 @@ namespace TINK.Services.BluetoothLock.Crypto
}
accessKey[accessKey.Length - 1] += 1;
var keyCopri = KeyCopri;
byte[] acccessKeyEncrypted;
try

View file

@ -2,6 +2,6 @@
{
public class AlreadyConnectedException : System.Exception
{
public AlreadyConnectedException() : base("Invalid reconnect call detected. Device is already connected.") {}
public AlreadyConnectedException() : base("Invalid reconnect call detected. Device is already connected.") { }
}
}

View file

@ -1,4 +1,4 @@
using TINK.Model.Bike.BluetoothLock;
using TINK.Model.Bikes.BikeInfoNS.BluetoothLock;
namespace TINK.Services.BluetoothLock.Exception
{

View file

@ -4,6 +4,6 @@ namespace TINK.Services.BluetoothLock.Exception
{
public class ConnectLocationPermissionMissingException : System.Exception
{
public ConnectLocationPermissionMissingException() : base(Resources.ErrorConnectLockLocationPermissingMissingException) { }
public ConnectLocationPermissionMissingException() : base(Resources.ErrorConnectLockLocationPermissingMissingException) { }
}
}

View file

@ -1,4 +1,4 @@
using TINK.Model.Bike.BluetoothLock;
using TINK.Model.Bikes.BikeInfoNS.BluetoothLock;
namespace TINK.Services.BluetoothLock.Exception
{

View file

@ -1,5 +1,5 @@

using TINK.Model.Bike.BluetoothLock;
using TINK.Model.Bikes.BikeInfoNS.BluetoothLock;
using TINK.MultilingualResources;
namespace TINK.Services.BluetoothLock.Exception

View file

@ -1,4 +1,4 @@
using TINK.Model.Bike.BluetoothLock;
using TINK.Model.Bikes.BikeInfoNS.BluetoothLock;
namespace TINK.Services.BluetoothLock.Exception
{

View file

@ -1,4 +1,4 @@
using TINK.Model.Bike.BluetoothLock;
using TINK.Model.Bikes.BikeInfoNS.BluetoothLock;
namespace TINK.Services.BluetoothLock.Exception
{
@ -8,7 +8,7 @@ namespace TINK.Services.BluetoothLock.Exception
public class CouldntOpenBoldIsBlockedException : StateAwareException
{
public CouldntOpenBoldIsBlockedException() : base(
LockingState.UnknownFromHardwareError,
LockingState.UnknownFromHardwareError,
MultilingualResources.Resources.ErrorOpenLockBoldBlocked)
{
}

View file

@ -1,4 +1,4 @@
using TINK.Model.Bike.BluetoothLock;
using TINK.Model.Bikes.BikeInfoNS.BluetoothLock;
namespace TINK.Services.BluetoothLock.Exception
{

View file

@ -1,5 +1,5 @@

using TINK.Model.Bike.BluetoothLock;
using TINK.Model.Bikes.BikeInfoNS.BluetoothLock;
using TINK.MultilingualResources;
namespace TINK.Services.BluetoothLock.Exception

View file

@ -1,6 +1,7 @@
namespace TINK.Services.BluetoothLock.Exception
{
/// <summary> Thrown whenever lock is out of reach.</summary>
/// <remarks> If fired when scan for devices does not result in lock beeing found.</remarks>
public class OutOfReachException : System.Exception
{
}

View file

@ -1,4 +1,4 @@
using TINK.Model.Bike.BluetoothLock;
using TINK.Model.Bikes.BikeInfoNS.BluetoothLock;
namespace TINK.Services.BluetoothLock.Exception
{

View file

@ -18,7 +18,7 @@ namespace TINK.Services.BluetoothLock
Task ReconnectAsync(
LockInfoAuthTdo authInfo,
TimeSpan connectTimeout);
/// <summary> Opens lock. </summary>
/// <returns> State of lock after performing open operation. </returns>
Task<LockitLockingState?> OpenAsync();
@ -42,7 +42,7 @@ namespace TINK.Services.BluetoothLock
/// <param name="doWaitRetry">True if to wait and retry in case of failures. </param>
/// <returns></returns>
Task<LockInfoTdo> GetLockStateAsync(bool doWaitRetry = false);
Task<bool> SetSoundAsync(SoundSettings settings);
Task<bool> SetAlarmSettingsAsync(AlarmSettings settings);

View file

@ -1,7 +1,7 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using TINK.Model.Bike.BluetoothLock;
using TINK.Model.Bikes.BikeInfoNS.BluetoothLock;
using TINK.Services.BluetoothLock.Tdo;
namespace TINK.Services.BluetoothLock
@ -12,22 +12,22 @@ namespace TINK.Services.BluetoothLock
ITimeOutProvider TimeOut { get; set; }
/// <summary> Gets lock info for all lock in reach./// </summary>
/// <param name="connectTimeout">Timeout for connect operation of a single lock.</param>
/// <param name="connectTimeout">Timeout for connect operation of a single lock.</param>
Task<IEnumerable<LockInfoTdo>> GetLocksStateAsync(
IEnumerable<LockInfoAuthTdo> locksInfo,
IEnumerable<LockInfoAuthTdo> locksInfo,
TimeSpan connectTimeout);
/// <summary> Connects to lock.</summary>
/// <param name="authInfo"> Info required to connect to lock.</param>
/// <param name="connectTimeout">Timeout for connect operation.</param>
Task<LockInfoTdo> ConnectAsync(
LockInfoAuthTdo authInfo,
LockInfoAuthTdo authInfo,
TimeSpan connectTimeout);
/// <summary>Gets a lock by bike Id.</summary>
/// <param name="bikeId"></param>
/// <returns>Lock object</returns>
ILockService this[int bikeId] { get; }
ILockService this[int bikeId] { get; }
/// <summary> Disconnects lock.</summary>
/// <param name="bikeId"> Id of lock to disconnect.</param>
@ -41,7 +41,7 @@ namespace TINK.Services.BluetoothLock
public enum AlarmSettings
{
SmallSensivity = 2,
SmallSensivitySilent = 3,
SmallSensivitySilent = 3,
SmallSensitivityPrealarm = 22,
MediumSensivity = 4,
MediumSensivitySilent = 0x05,
@ -60,7 +60,7 @@ namespace TINK.Services.BluetoothLock
LockingStarted = 0x02,
AllOff = 0x03, // Mute
OpenedSuccessfully = 0x04,
LockingStartedOpenedSuccessfully = 0x05,
LockingStartedOpenedSuccessfully = 0x05,
AllOn = 0x06, // All sounds on
OpenedSuccessfullyWarn = 0x07,
}

View file

@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using TINK.Services.BluetoothLock.Tdo;
namespace TINK.Model.Bike.BluetoothLock
namespace TINK.Model.Bikes.BikeInfoNS.BluetoothLock
{
public static class LockInfoHelper
{
@ -12,7 +12,7 @@ namespace TINK.Model.Bike.BluetoothLock
/// <param name="locksInfoTdo">Tdos holding data to updat from</param>
/// <returns></returns>
public static IEnumerable<LockInfo> UpdateById(
this IEnumerable<LockInfo> locksInfo,
this IEnumerable<LockInfo> locksInfo,
IEnumerable<LockInfoTdo> locksInfoTdo)
{
var locksInfoUpdated = new List<LockInfo>();
@ -30,7 +30,7 @@ namespace TINK.Model.Bike.BluetoothLock
var state = lockInfoTdo.State.HasValue ? lockInfoTdo.State.Value.GetLockingState() : LockingState.UnknownDisconnected;
locksInfoUpdated.Add(state != lockInfo.State || lockInfoTdo.Guid != lockInfo.Guid
? new LockInfo.Builder(lockInfo) { Guid = lockInfoTdo.Guid, State = state}.Build() // State has changed, update required.
? new LockInfo.Builder(lockInfo) { Guid = lockInfoTdo.Guid, State = state }.Build() // State has changed, update required.
: lockInfo);
}
@ -65,6 +65,6 @@ namespace TINK.Model.Bike.BluetoothLock
return new LockInfoAuthTdo.Builder() { Id = lockInfo.Id, Guid = lockInfo.Guid, K_u = lockInfo.UserKey, K_a = lockInfo.AdminKey, K_seed = lockInfo.Seed }.Build();
}
}
}

View file

@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace LockItShared.Services.BluetoothLock
{
@ -9,7 +8,7 @@ namespace LockItShared.Services.BluetoothLock
/// <summary>
/// Holds guids of developent locks to ensure that no wrong guid are provided by COPRI
/// </summary>
public static Dictionary<int, Guid> DevelGuids = new Dictionary<int, Guid>
public static Dictionary<int, Guid> DevelGuids = new Dictionary<int, Guid>
{
{ 2200537, new Guid("00000000-0000-0000-0000-d589a8023487") },
{ 2200543, new Guid("00000000-0000-0000-0000-cc141a6f68bb") },

View file

@ -19,44 +19,44 @@ namespace TINK.Services.BluetoothLock
public Task ReconnectAsync(LockInfoAuthTdo authInfo, TimeSpan connectTimeout) =>
throw new NotImplementedException();
public string Name =>
public string Name =>
throw new NotImplementedException();
public Guid Guid =>
public Guid Guid =>
throw new NotImplementedException();
public int Id =>
public int Id =>
throw new NotImplementedException();
public async Task<LockitLockingState?> OpenAsync() =>
await Task.FromResult((LockitLockingState?)null);
public async Task<LockitLockingState?> CloseAsync() =>
public async Task<LockitLockingState?> CloseAsync() =>
await Task.FromResult((LockitLockingState?)null);
public Task<double> GetBatteryPercentageAsync() =>
public Task<double> GetBatteryPercentageAsync() =>
throw new System.Exception($"Can not get battery percentage. Lock {BikeId} not found.");
public DeviceState? GetDeviceState() =>
throw new NotImplementedException();
public Task<bool> GetIsAlarmOffAsync() =>
public Task<bool> GetIsAlarmOffAsync() =>
throw new System.Exception($"Can not get whether alarm is on or off. Lock {BikeId} not found.");
public Task<LockInfoTdo> GetLockStateAsync(bool doWaitRetry = false) =>
throw new NotImplementedException();
public Task SetIsAlarmOffAsync(bool isActivated) =>
public Task SetIsAlarmOffAsync(bool isActivated) =>
throw new System.Exception($"Can not set alarm {isActivated}. Lock {BikeId} not found.");
public async Task<bool> SetSoundAsync(SoundSettings settings) =>
public async Task<bool> SetSoundAsync(SoundSettings settings) =>
await Task.FromResult(false);
public async Task<bool> SetAlarmSettingsAsync(AlarmSettings settings) =>
await Task.FromResult(false);
/// <summary> Disconnect from bluetooth lock. </summary>
public Task Disconnect() =>
public Task Disconnect() =>
throw new NotImplementedException();
}

View file

@ -1,5 +1,5 @@
using TINK.Model.Connector;
using System;
using System;
using TINK.Model.Connector;
namespace TINK.Services.BluetoothLock.Tdo
{

View file

@ -6,15 +6,15 @@ namespace TINK.Services.BluetoothLock.Tdo
public enum LockitLockingState
{
Open = 0x00,
Closed = 0x01,
Unknown = 0x02,
CouldntCloseMoving = 0x03,
CouldntOpenBoldBlocked = 0x04,
CouldntCloseBoldBlocked = 0x05
}

View file

@ -23,8 +23,8 @@ namespace TINK.Services.BluetoothLock
public TimeSpan MultiConnect => TimeOuts.ToArray()[0];
public TimeSpan GetSingleConnect(int countOfTry) => countOfTry < TimeOuts.Count
? TimeOuts.ToArray()[countOfTry]
: new TimeSpan(TimeOuts.ToArray()[0].Ticks * Math.Min(countOfTry, MAXIMUMFACTORTIMEOUT)) ;
public TimeSpan GetSingleConnect(int countOfTry) => countOfTry < TimeOuts.Count
? TimeOuts.ToArray()[countOfTry]
: new TimeSpan(TimeOuts.ToArray()[0].Ticks * Math.Min(countOfTry, MAXIMUMFACTORTIMEOUT));
}
}

View file

@ -1,7 +0,0 @@

namespace TINK.Services.CopriLock.Exception
{
public class CouldntCloseBoldBlockedException : System.Exception
{
}
}

View file

@ -1,7 +0,0 @@

namespace TINK.Services.CopriLock.Exception
{
public class CouldntOpenBoldIsBlockedException : System.Exception
{
}
}

View file

@ -1,7 +0,0 @@

namespace TINK.Services.CopriLock.Exception
{
public class CouldntOpenBoldWasBlockedException : System.Exception
{
}
}

View file

@ -1,7 +0,0 @@

namespace TINK.Services.CopriLock.Exception
{
public class CounldntCloseMovingException : System.Exception
{
}
}

View file

@ -1,7 +0,0 @@

namespace TINK.Services.CopriLock.Exception
{
public class OutOfReachException : System.Exception
{
}
}

View file

@ -1,15 +0,0 @@
using TINK.Model.Bikes.Bike.CopriLock;
namespace TINK.Services.CopriLock.Exception
{
public abstract class StateAwareException : System.Exception
{
public StateAwareException(LockingState state, string description) : base(description)
{
State = state;
}
/// <summary> Holds the state reported by lock.</summary>
public LockingState State { get; }
}
}