mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2025-04-21 12:36:28 +02:00
Version 3.0.337
This commit is contained in:
parent
fd0e63cf10
commit
573fe77e12
2336 changed files with 33688 additions and 86082 deletions
|
@ -1,10 +1,10 @@
|
|||
using Plugin.BLE.Abstractions.Contracts;
|
||||
using Plugin.BLE.Abstractions.EventArgs;
|
||||
using Serilog;
|
||||
using System;
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using TINK.Model.Bike.BluetoothLock;
|
||||
using Plugin.BLE.Abstractions.Contracts;
|
||||
using Plugin.BLE.Abstractions.EventArgs;
|
||||
using Serilog;
|
||||
using TINK.Model.Bikes.BikeInfoNS.BluetoothLock;
|
||||
using TINK.Model.Device;
|
||||
using TINK.Services.BluetoothLock.Exception;
|
||||
using TINK.Services.BluetoothLock.Tdo;
|
||||
|
@ -53,7 +53,7 @@ namespace TINK.Services.BluetoothLock.BLE
|
|||
{
|
||||
if (DeviceInfo.Platform != DevicePlatform.Unknown && MainThread.IsMainThread == false)
|
||||
{
|
||||
throw new System.Exception("Can not open lock. Bluetooth code must be run on main thread");
|
||||
throw new System.Exception("Can not open lock. Platform must not be unknown and bluetooth code must be run on main thread.");
|
||||
}
|
||||
|
||||
LockitLockingState? lockingState = (await GetLockStateAsync())?.State;
|
||||
|
@ -88,7 +88,8 @@ namespace TINK.Services.BluetoothLock.BLE
|
|||
{
|
||||
lockStateCharacteristic.ValueUpdated += lockStateCharcteristicChanged;
|
||||
batteryStateCharacteristic.ValueUpdated += batteryStateCharcteristicChanged;
|
||||
} catch (System.Exception ex)
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
Log.ForContext<LockItEventBased>().Error("Subscribing to events when opening lock failed.{Exception}", ex);
|
||||
return await Task.FromResult((LockitLockingState?)null);
|
||||
|
@ -122,13 +123,14 @@ namespace TINK.Services.BluetoothLock.BLE
|
|||
finally
|
||||
{
|
||||
try
|
||||
{
|
||||
{
|
||||
await lockStateCharacteristic.StopUpdatesAsync();
|
||||
await batteryStateCharacteristic.StopUpdatesAsync();
|
||||
|
||||
lockStateCharacteristic.ValueUpdated -= lockStateCharcteristicChanged;
|
||||
batteryStateCharacteristic.ValueUpdated -= batteryStateCharcteristicChanged;
|
||||
} catch (System.Exception ex)
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
Log.ForContext<LockItEventBased>().Error("Sopping updates/ unsubscribing from events when opening lock failed.{Exception}", ex);
|
||||
}
|
||||
|
@ -168,7 +170,7 @@ namespace TINK.Services.BluetoothLock.BLE
|
|||
{
|
||||
if (DeviceInfo.Platform != DevicePlatform.Unknown && MainThread.IsMainThread == false)
|
||||
{
|
||||
throw new System.Exception("Can not close lock. Bluetooth code must be run on main thread");
|
||||
throw new System.Exception("Can not close lock. Platform must not be unknown and bluetooth code must be run on main thread.");
|
||||
}
|
||||
|
||||
// Get current state
|
||||
|
@ -196,8 +198,8 @@ namespace TINK.Services.BluetoothLock.BLE
|
|||
|
||||
EventHandler<CharacteristicUpdatedEventArgs> lockStateCharcteristicChanged = (sender, args) => GetStateValue(tcs, args.Characteristic.Value);
|
||||
|
||||
try
|
||||
{
|
||||
try
|
||||
{
|
||||
lockStateCharacteristic.ValueUpdated += lockStateCharcteristicChanged;
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
|
@ -214,7 +216,7 @@ namespace TINK.Services.BluetoothLock.BLE
|
|||
Log.ForContext<LockItEventBased>().Error("Starting update when closing lock failed.{Exception}", ex);
|
||||
return await Task.FromResult((LockitLockingState?)null);
|
||||
}
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
Log.ForContext<LockItEventBased>().Debug($"Request to closed lock. Current state is {lockingState}, counter value {ActivateLockWriteCounter}.");
|
||||
|
@ -232,11 +234,12 @@ namespace TINK.Services.BluetoothLock.BLE
|
|||
finally
|
||||
{
|
||||
try
|
||||
{
|
||||
{
|
||||
await lockStateCharacteristic.StopUpdatesAsync();
|
||||
|
||||
lockStateCharacteristic.ValueUpdated -= lockStateCharcteristicChanged;
|
||||
} catch (System.Exception ex)
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
Log.ForContext<LockItEventBased>().Error("Sopping update/ unsubscribing from events when closing lock failed.{Exception}", ex);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue