//----------------------------------------------------------------------- // // Copyright (c) 2018-20 In The Hand Ltd, All rights reserved. // This source code is licensed under the MIT License - see License.txt // //----------------------------------------------------------------------- using System; using System.Diagnostics; using System.Threading.Tasks; namespace InTheHand.Bluetooth { [DebuggerDisplay("{Id} ({Name})")] public sealed partial class BluetoothDevice { public string Id { get { return GetId(); } } public string Name { get { return GetName(); } } public RemoteGattServer Gatt { get { return GetGatt(); } } public static Task FromIdAsync(string id) { return PlatformFromId(id); } /* public Task WatchAdvertisementsAsync() { return DoWatchAdvertisements(); } public void UnwatchAdvertisements() { DoUnwatchAdvertisements(); } public bool WatchingAdvertisements { get { return GetWatchingAdvertisements(); } } internal void OnAdvertismentReceived(BluetoothAdvertisingEvent advertisement) { AdvertisementReceived?.Invoke(this, advertisement); } public event EventHandler AdvertisementReceived; */ internal void OnGattServerDisconnected() { GattServerDisconnected?.Invoke(this, EventArgs.Empty); } /// /// Fired when an active GATT connection is lost. /// public event EventHandler GattServerDisconnected; public override bool Equals(object obj) { BluetoothDevice device = obj as BluetoothDevice; if (device != null) { return Id.Equals(device.Id); } return base.Equals(obj); } } }