private async void OnScanButtonClicked(object sender, EventArgs e) { var btn = (Button)sender; btn.IsEnabled = false; _scanProgress.Text = "Scanning devices..."; await _ble.ContinousScan((s, a) => { Device.BeginInvokeOnMainThread(() => { var btAddr = _ble.GetAddress(a.Device); _labelDictionary[btAddr].Text = btAddr + " " + a.Device.Rssi; }); }, int.Parse(_scanEntry.Text)); _scanProgress.Text = "Scan completed"; btn.IsEnabled = true; }
private async Task ScanDevices() { _scanProgress.Text = "Scanning for devices..."; ResetScanResults(); var devs = await _ble.ScanDevices(); _scanProgress.Text = "Scan completed!"; foreach (var dev in devs) { var btn = new Button { Text = _ble.GetAddress(dev) + ";" + dev.Rssi }; btn.Clicked += OnScanResultButtonClicked; _layout.Children.Add(btn); ScanResultList.Add(btn); } }