private async void PairDeviceButton_Click(object sender, RoutedEventArgs e)
        {
            if (_heartRateMonitor.IsConnected)
            {
                SelectedDeviceId   = string.Empty;
                SelectedDeviceName = string.Empty;

                await _heartRateMonitor.DisconnectAsync();
            }

            var devicePicker = new DevicePicker();
            var result       = devicePicker.ShowDialog();

            if (result.Value)
            {
                SelectedDeviceId   = devicePicker.SelectedDeviceId;
                SelectedDeviceName = devicePicker.SelectedDeviceName;

                var connectResult = await _heartRateMonitor.ConnectAsync(SelectedDeviceId);

                if (!connectResult.IsConnected)
                {
                    MessageBox.Show(connectResult.ErrorMessage);
                }
            }
        }
Beispiel #2
0
        private async void PairDeviceButton_Click(object sender, RoutedEventArgs e)
        {
            if (_heartRateMonitor.IsConnected)
            {
                SelectedDeviceId   = string.Empty;
                SelectedDeviceName = string.Empty;

                //await _heartRateMonitor.DisableNotificationsAsync();
                await _heartRateMonitor.DisconnectAsync();
            }

            var devicePicker = new DevicePicker();
            var result       = devicePicker.ShowDialog();

            if (result.Value)
            {
                SelectedDeviceId   = devicePicker.SelectedDeviceId;
                SelectedDeviceName = devicePicker.SelectedDeviceName;

                await _heartRateMonitor.ConnectAsync(SelectedDeviceId);

                //await _heartRateMonitor.EnableNotificationsAsync();
            }
        }