public override void OnConnect() { Console.WriteLine("Device Connected!"); Windesheart.PairedDevice = this; //Check if bluetooth-state changes to off and then on, to enable reconnection management BluetoothService.StartListeningForAdapterChanges(); Characteristics?.Clear(); CharacteristicDisposable?.Dispose(); //Find unique characteristics CharacteristicDisposable = IDevice.WhenAnyCharacteristicDiscovered().Subscribe(async characteristic => { if (characteristic != null && !Characteristics.Contains(characteristic)) { Characteristics.Add(characteristic); //Check if authCharacteristic has been found, then authenticate if (characteristic.Uuid == MiBand3Resource.GuidCharacteristicAuth) { //Check if this is a new connection that needs authentication await _authenticationService.Authenticate(); } } }); }
public override void DisposeDisposables() { _authenticationService.AuthenticationDisposable?.Dispose(); _stepsService.realtimeDisposable?.Dispose(); _heartrateService.RealtimeDisposible?.Dispose(); _batteryService.RealTimeDisposible?.Dispose(); ConnectionDisposable?.Dispose(); CharacteristicDisposable?.Dispose(); }