예제 #1
0
        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;
        }
예제 #2
0
        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);
            }
        }