Exemplo 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);
                }));
            }
        }