feat: BE prefix filter, fail-loud error notifications
This commit is contained in:
3 files changed
+37
-6
No files matched your search
@@ -4,10 +4,10 @@
|
||||
<TargetFramework>net8.0-windows10.0.19041.0</TargetFramework>
|
||||
<UseWPF>true</UseWPF>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<Version>0.3.1</Version>
|
||||
<AssemblyVersion>0.3.1.0</AssemblyVersion>
|
||||
<FileVersion>0.3.1.0</FileVersion>
|
||||
<InformationalVersion>0.3.1</InformationalVersion>
|
||||
<Version>0.3.2</Version>
|
||||
<AssemblyVersion>0.3.2.0</AssemblyVersion>
|
||||
<FileVersion>0.3.2.0</FileVersion>
|
||||
<InformationalVersion>0.3.2</InformationalVersion>
|
||||
<AssemblyProduct>Fristy.RgbLedStripController</AssemblyProduct>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
|
||||
@@ -39,6 +39,7 @@ public sealed class BleDeviceService : IBleTransport
|
||||
await MergeWindowsDeviceInventoryAsync(captures);
|
||||
|
||||
return captures.Values
|
||||
.Where(capture => IsSupportedAddress(capture.Address))
|
||||
.Select(capture => new BleScanResult
|
||||
{
|
||||
DeviceId = FormatAddress(capture.Address),
|
||||
@@ -299,6 +300,9 @@ public sealed class BleDeviceService : IBleTransport
|
||||
|| normalized.Contains("DUOCO");
|
||||
}
|
||||
|
||||
internal static bool IsSupportedAddress(ulong address)
|
||||
=> FormatAddress(address).StartsWith("BE:", StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
private static async Task RunScanPassAsync(
|
||||
ConcurrentDictionary<ulong, ScanCapture> captures,
|
||||
BluetoothLEScanningMode mode,
|
||||
@@ -360,7 +364,8 @@ public sealed class BleDeviceService : IBleTransport
|
||||
|
||||
if (!device.Properties.TryGetValue("System.Devices.Aep.DeviceAddress", out var addressValue)
|
||||
|| addressValue is not string addressText
|
||||
|| !TryParseBluetoothAddress(addressText, out var address))
|
||||
|| !TryParseBluetoothAddress(addressText, out var address)
|
||||
|| !IsSupportedAddress(address))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -99,6 +99,11 @@ public sealed class MultiDeviceController : IAsyncDisposable
|
||||
|
||||
public async Task<ConnectedDeviceViewModel> ConnectAsync(BleScanResult device, CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (!BleDeviceService.IsSupportedAddress(device.AddressValue))
|
||||
{
|
||||
throw new ArgumentException($"Desteklenmeyen cihaz adresi: {device.BluetoothAddress}", nameof(device));
|
||||
}
|
||||
|
||||
DeviceConnectionContext? existing;
|
||||
lock (_stateLock)
|
||||
{
|
||||
@@ -583,6 +588,11 @@ public sealed class MultiDeviceController : IAsyncDisposable
|
||||
|
||||
private void UpsertKnownDevice(BleScanResult device)
|
||||
{
|
||||
if (!BleDeviceService.IsSupportedAddress(device.AddressValue))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var alias = GetAlias(device.BluetoothAddress);
|
||||
var profile = new DeviceProfile(
|
||||
string.IsNullOrWhiteSpace(alias) ? device.NativeName : alias,
|
||||
@@ -675,6 +685,19 @@ public sealed class MultiDeviceController : IAsyncDisposable
|
||||
: connections.Any(context => context.ViewModel.ConnectionStatus == DeviceConnectionStatus.Faulted)
|
||||
? DeviceConnectionStatus.Faulted
|
||||
: DeviceConnectionStatus.Disconnected;
|
||||
|
||||
if (State.ConnectionStatus == DeviceConnectionStatus.Faulted
|
||||
&& !State.StatusText.Contains("Hata:", StringComparison.Ordinal))
|
||||
{
|
||||
var firstFault = connections
|
||||
.Where(context => context.ViewModel.ConnectionStatus == DeviceConnectionStatus.Faulted)
|
||||
.Select(context => context.ViewModel.StatusText)
|
||||
.FirstOrDefault(text => !string.IsNullOrWhiteSpace(text));
|
||||
if (!string.IsNullOrWhiteSpace(firstFault))
|
||||
{
|
||||
State.StatusText = firstFault;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void EnsureTargetsAvailable()
|
||||
@@ -708,7 +731,10 @@ public sealed class MultiDeviceController : IAsyncDisposable
|
||||
: $"İşlem başarısız oldu: {firstFailureMessage}";
|
||||
}
|
||||
|
||||
return $"{successMessage} {successCount}/{totalCount} hedef başarılı, {failureCount} hata.";
|
||||
var partialMessage = $"{successMessage} {successCount}/{totalCount} hedef başarılı, {failureCount} hata.";
|
||||
return string.IsNullOrWhiteSpace(firstFailureMessage)
|
||||
? partialMessage
|
||||
: $"{partialMessage} Hata: {firstFailureMessage}";
|
||||
}
|
||||
|
||||
private sealed class DeviceConnectionContext
|
||||
|
||||
Reference in new issue
Block a user