IBluetooth.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. using System.Collections.ObjectModel;
  2. using System.Security.Cryptography.X509Certificates;
  3. using InABox.Core;
  4. namespace InABox.Avalonia.Platform;
  5. public interface IBluetoothDevice : IDisposable
  6. {
  7. String ID { get; }
  8. String Name { get; }
  9. Guid[] AvailableServices { get; }
  10. DateTime LastSeen { get; set; }
  11. byte[]? ManufacturerData { get; set; }
  12. }
  13. public interface IConnectedBluetoothDevice : IBluetoothDevice
  14. {
  15. Task<bool> WriteBytesAsync(Guid serviceid, Guid characteristicid, byte[] data);
  16. Task<bool> WriteStringAsync(Guid serviceid, Guid characteristicid, string data);
  17. Task<byte[]?> ReadBytesAsync(Guid serviceid, Guid characteristicid);
  18. Task<string?> ReadStringAsync(Guid serviceid, Guid characteristicid);
  19. }
  20. public interface IBluetooth : ILoggable
  21. {
  22. Logger? Logger { get; set; }
  23. Task<bool> IsAvailable();
  24. Task<bool> StartScanningAsync(Guid configServiceId);
  25. Task<bool> StopScanningAsync();
  26. Task<IConnectedBluetoothDevice?> Connect(IBluetoothDevice deviceid);
  27. Task<bool> Disconnect(IConnectedBluetoothDevice device);
  28. event EventHandler? Changed;
  29. CoreObservableCollection<IBluetoothDevice> Devices { get; }
  30. }