public void UnPairAsync(string name) { // Also need to check if current device. // Status is failed by default BTUnPairOperationStatus status = new BTUnPairOperationStatus() { Name = name, }; Task.Run(() => { try { var d = BluetoothAdapter.DefaultAdapter.BondedDevices.FirstOrDefault(dev => dev != null && dev.Name == name); if (d != null) { var mi = d.Class.GetMethod("removeBond", null); var sdfd = mi.Invoke(d, null); // Need to sleep a bit for the method invocation to complete Thread.Sleep(200); // Suppose it to be successful if exception not thrown. Reload list to see if it is still there status.IsSuccessful = true; status.UnpairStatus = BT_UnpairingStatus.Success; } else { this.log.Error(9999, "UnPairAsync", "Already unpaired - null device or not of name"); status.UnpairStatus = BT_UnpairingStatus.AlreadyUnPaired; } } catch (Exception e) { this.log.Exception(9999, "UnPairAsync", "", e); status.UnpairStatus = BT_UnpairingStatus.Failed; } this.BT_UnPairStatus?.Invoke(this, status); }); }
private void BTClassic_UnPairStatus(object sender, BTUnPairOperationStatus e) { ErrReport report; WrapErr.ToErrReport(out report, 20016, "Failure on BTClassic_UnPairStatus", () => { this.BT_UnPairStatus?.Invoke(sender, e); }); this.RaiseIfException(report); }
private void unPairStatusHandler(object sender, BTUnPairOperationStatus e) { this.Dispatcher.Invoke(() => { Log.InfoEntry("BTSettings", "unPairStatusHandler"); this.gridWait.Collapse(); DI.Wrapper.BT_UnPairStatus -= this.unPairStatusHandler; if (!e.IsSuccessful) { App.ShowMsg(e.UnpairStatus.ToString()); } }); }
private void BT_UnPairStatusHandler(object sender, BTUnPairOperationStatus e) { Device.BeginInvokeOnMainThread(() => { if (e.IsSuccessful) { this.btnDiscover_Clicked(null, null); } else { this.OnErr(e.UnpairStatus.ToString()); } }); }
private void BT_UnPairStatusHandler(object sender, BTUnPairOperationStatus e) { this.log.InfoEntry("BT_UnPairStatusHandler"); this.Dispatcher.Invoke(() => { this.gridWait.Collapse(); if (e.IsSuccessful) { this.BT_RemoveEntry(e.Name); this.SetBTCheckUncheckButtons(); } else { this.ShowMsgBox(this.wrapper.GetText(MsgCode.Error), e.UnpairStatus.ToString()); } }); }