Esempio n. 1
0
        private async Task DiscoverDevices()
        {
            var devices = await CargoClient.GetConnectedDevicesAsync();

            if (devices.Count() > 0)
            {
                // must create on the UI thread for various Binding reasons
                _deviceInfo = devices[0];

                Application.Current.Dispatcher.BeginInvoke(new Action(async() =>
                {
                    // TODO: support more than one device?
                    InitializeCargoLogging();
                    CargoClient = await CargoClient.CreateAsync(_deviceInfo);

                    IsConnected = true;

                    //TODO: call an "OnConnected" function
                    Properties = new BandProperties(CargoClient);
                    Theme      = new BandTheme(CargoClient);
                    Sensors    = new BandSensors(CargoClient);
                    Tiles      = new BandTiles(CargoClient);
                }));
            }
        }
Esempio n. 2
0
        private async Task ConnectDevice()
        {
            if (DesktopSyncAppIsRunning())
            {
                return;
            }

            // We support connecting to a device over USB and Bluetooth.
            // Since USB is super fast (the device is either there or not), search there first and then fallback
            // on Bluetooth, since that can take a little longer.

            var device = await GetUSBBand();

            if (device == null)
            {
                // now try Bluetooth
                device = await GetBluetoothBand();
            }

            if (device != null)
            {
                // since this will trigger binding, invoke on the UI thread
                Application.Current.Dispatcher.BeginInvoke(new Action(async() =>
                {
                    // TODO: support more than one device?
                    CargoClient = device;

                    IsConnected = true;

                    //TODO: call an "OnConnected" function

                    // Bluetooth is sensitive to multiple things going on at once across different threads
                    // so let's make sure we go about this serially

                    Properties = new BandProperties(CargoClient);
                    await Properties.InitAsync();

                    Theme = new BandTheme(CargoClient);
                    await Theme.InitAsync();

                    Sensors = new BandSensors(CargoClient);
                    await Sensors.InitAsync();

                    Tiles = new BandTiles(CargoClient);
                    await Tiles.InitAsync();
                }));
            }
        }
Esempio n. 3
0
        private async Task ConnectDevice()
        {
            if (DesktopSyncAppIsRunning())
                return;

            // We support connecting to a device over USB and Bluetooth.
            // Since USB is super fast (the device is either there or not), search there first and then fallback
            // on Bluetooth, since that can take a little longer.

            var device = await GetUSBBand();

            if (device == null)
            {
                // now try Bluetooth
                device = await GetBluetoothBand();
            }

            if (device != null)
            {
                // since this will trigger binding, invoke on the UI thread
                Application.Current.Dispatcher.BeginInvoke(new Action(async () =>
                {
                    // TODO: support more than one device?
                    CargoClient = device;

                    IsConnected = true;

                    //TODO: call an "OnConnected" function

                    // Bluetooth is sensitive to multiple things going on at once across different threads
                    // so let's make sure we go about this serially

                    Properties = new BandProperties(CargoClient);
                    await Properties.InitAsync();
                    
                    Theme = new BandTheme(CargoClient);
                    await Theme.InitAsync();

                    Sensors = new BandSensors(CargoClient);
                    await Sensors.InitAsync();

                    Tiles = new BandTiles(CargoClient);
                    await Tiles.InitAsync();
                }));
            }
        }