Bluetooth check, avoid crashing
This commit is contained in:
@@ -6,6 +6,10 @@ namespace TuneBoss.Core.BLE;
|
||||
/// <summary>
|
||||
/// Represents a discovered BLE device before connection.
|
||||
/// </summary>
|
||||
/// <summary>Result of a Bluetooth-adapter check: whether BLE is ready to scan, and a
|
||||
/// human-readable reason when it isn't (no adapter / no BLE support / radio off).</summary>
|
||||
public readonly record struct BluetoothAvailability(bool IsReady, string Message);
|
||||
|
||||
public sealed record BleDeviceInfo(
|
||||
ulong Address,
|
||||
string Name,
|
||||
@@ -69,6 +73,10 @@ public interface IBleService : IDisposable
|
||||
|
||||
// ── Scanning ─────────────────────────────────────────────────────────────
|
||||
|
||||
/// <summary>Whether a Bluetooth adapter is present and its radio is on. Call this
|
||||
/// before scanning so a radio that's off gives a friendly message instead of a crash.</summary>
|
||||
Task<BluetoothAvailability> CheckBluetoothAsync();
|
||||
|
||||
/// <summary>Starts BLE advertisement scanning. Emits discovered devices.</summary>
|
||||
IObservable<BleDeviceInfo> StartScan();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user