IBluetooth.cs 1.3 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. }
  12. public interface IConnectedBluetoothDevice : IBluetoothDevice
  13. {
  14. Task<bool> WriteBytesAsync(Guid serviceid, Guid characteristicid, byte[] data);
  15. Task<bool> WriteStringAsync(Guid serviceid, Guid characteristicid, string data);
  16. Task<byte[]?> ReadBytesAsync(Guid serviceid, Guid characteristicid);
  17. Task<string?> ReadStringAsync(Guid serviceid, Guid characteristicid);
  18. }
  19. public interface IBluetooth : ILoggable
  20. {
  21. Logger? Logger { get; set; }
  22. Task<bool> IsAvailable();
  23. //Task<IBluetoothDevice?> FindDevice(Guid serviceId, TimeSpan timeout);
  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. }