/// <summary>
        /// Callback for the devices list which navigates to the <see cref="DeviceSetup"/> page with the selected device
        /// </summary>
        private async void pairedDevices_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var selectedDevice = ((ListView)sender).SelectedItem as BluetoothLEDevice;

            if (selectedDevice != null)
            {
                initFlyout.ShowAt(pairedDevices);
                var board      = MetaWearBoard.getMetaWearBoardInstance(selectedDevice);
                var initResult = await board.Initialize();

                await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(
                    CoreDispatcherPriority.Normal, async() => {
                    initFlyout.Hide();

                    if (initResult == Status.ERROR_TIMEOUT)
                    {
                        await new ContentDialog()
                        {
                            Title             = "Error",
                            Content           = "API initialization timed out.  Try re-pairing the MetaWear or moving it closer to the host device",
                            PrimaryButtonText = "OK"
                        }.ShowAsync();
                    }
                    else
                    {
                        this.Frame.Navigate(typeof(DeviceSetup), selectedDevice);
                    }
                });
            }
        }
Example #2
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            var mwBoard = MetaWearBoard.getMetaWearBoardInstance(e.Parameter as BluetoothLEDevice);

            cppBoard = mwBoard.cppBoard;

            // cppBoard is initialized at this point and can be used
        }
Example #3
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            var mwBoard = MetaWearBoard.getMetaWearBoardInstance(e.Parameter as BluetoothLEDevice);

            board = mwBoard.cppBoard;

            deviceSetupPage = this;

            triggered_gpio_already = false;

            this.gyroCheckbox.IsChecked  = useGyro;
            this.accelCheckbox.IsChecked = useAccel;
            this.spillCheckbox.IsChecked = useSpill;
        }
        /// <summary>
        /// Callback for the devices list which navigates to the <see cref="DeviceSetup"/> page with the selected device
        /// </summary>
        private void pairedDevices_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var selectedDevice = ((ListView)sender).SelectedItem as BluetoothLEDevice;

            if (selectedDevice != null)
            {
                initFlyout.ShowAt(pairedDevices);
                var board = MetaWearBoard.getMetaWearBoardInstance(selectedDevice);
                board.Initialize(new FnVoid(async() => {
                    await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(
                        CoreDispatcherPriority.Normal, () => {
                        initFlyout.Hide();
                        this.Frame.Navigate(typeof(DeviceSetup), selectedDevice);
                    });
                }));
            }
        }
Example #5
0
        private async Task <bool> retrieveBoard()
        {
            DeviceInformationCollection set = await DeviceInformation.FindAllAsync(BluetoothLEDevice.GetDeviceSelector());

            foreach (var devInfo in set)
            {
                try
                {
                    Debug.WriteLine("device = " + devInfo.Name + ", " + devInfo.Pairing);
                    if (devInfo.Name.Contains("MetaWear"))
                    {
                        BluetoothLEDevice selectedDevice = await BluetoothLEDevice.FromIdAsync(devInfo.Id);

                        if (selectedDevice != null)
                        {
                            var newBoard   = MetaWearBoard.getMetaWearBoardInstance(selectedDevice);
                            var initResult = await newBoard.Initialize();

                            if (initResult == 0)
                            {
                                board = newBoard.cppBoard;
                                return(true);
                            }
                        }
                        else
                        {
                            Debug.WriteLine("windows is confused; found a BLE device-info (" + devInfo.Name + ") but could not find it");
                        }
                    }
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex.Message);
                }
            }
            return(false);
        }