Exemplo n.º 1
0
        private async Task InitAsync()
        {
            try
            {
                this.selectedBand = await this.FindDevicesAsync();

                if (this.selectedBand == null)
                {
                    return;
                }

                this.bandClient = await this.ConnectAsync();

                if (this.bandClient == null)
                {
                    return;
                }

                //await this.LoadBandRegistrySensor();
                //if (this.bandRegistrySensor == null)
                //{
                //    return;
                //}

                //RemoveTile();

                bandVersion = await this.bandClient.GetHardwareVersionAsync();

                AddingTile();

                this.StartStreams();

                StartConnectionChecker();
            }
            catch (Exception x)
            {
                Debug.WriteLine(x.Message);
                await c.saveStringToLocalFile("DebugLogs.txt", "TimeStamp: " + BandController.CurrentDate() + " Debug: " + "Connecting to the Band - " + x.Message);
            }
            finally
            {
                this.initializingTask = null;
            }
        }
Exemplo n.º 2
0
        private async void OnLoaded(object sender, Windows.UI.Xaml.RoutedEventArgs e)
        {
            //AddingTyle();
            ComboBoxItem typeItem   = (ComboBoxItem)ComboBox1.SelectedItem;
            string       valueCombo = typeItem.Content.ToString();

            ComboBoxItem typeItem2   = (ComboBoxItem)ComboBox2.SelectedItem;
            string       valueCombo2 = typeItem2.Content.ToString();

            interv     = Convert.ToInt32(valueCombo);
            classValue = Convert.ToInt32(valueCombo2);

            StartLogs();


            BandManager.GetInstance(interv, classValue).Initialize();
            BandManager.Done += (source, args) =>
            {
                Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async() =>
                {
                    switch (args.EventInfo.channelName)
                    {
                    case "Accelerometer":
                        AcceDisplay.Text = "Accelerometer: " + args.EventInfo.sensorMessage;
                        break;

                    case "HeartRate":
                        HeartRateDisplay.Text = "HeartRate: " + args.EventInfo.sensorMessage;
                        await c.saveStringToLocalFile("BandHRLogs.txt", "TimeStamp: " + args.EventInfo.timeStamp + " HeartRate: " + args.EventInfo.sensorMessage);
                        break;

                    case "SkinTemperature":
                        SkinTemperatureDisplay.Text = "Skin Temperature: " + args.EventInfo.sensorMessage;
                        await c.saveStringToLocalFile("BandSkinTempLogs.txt", "TimeStamp: " + args.EventInfo.timeStamp + " Skin Temperature: " + args.EventInfo.sensorMessage);
                        break;

                    case "Contact":
                        ContactBandDisplay.Text = args.EventInfo.sensorMessage;
                        await c.saveStringToLocalFile("BandContactLogs.txt", "TimeStamp: " + args.EventInfo.timeStamp + " " + args.EventInfo.sensorMessage);
                        break;

                    case "Pedometer":
                        PedometerDisplay.Text = "Pedometer: " + args.EventInfo.sensorMessage;
                        await c.saveStringToLocalFile("BandPedometerLogs.txt", "TimeStamp: " + args.EventInfo.timeStamp + " Pedometer: " + args.EventInfo.sensorMessage);
                        break;

                    case "UVIndex":
                        UVDisplay.Text = "UV: " + args.EventInfo.sensorMessage;
                        await c.saveStringToLocalFile("BandUVLogs.txt", "TimeStamp: " + args.EventInfo.timeStamp + " UV: " + args.EventInfo.sensorMessage);
                        break;

                    case "Calories":
                        CaloriesDisplay.Text = "Calories: " + args.EventInfo.sensorMessage;
                        await c.saveStringToLocalFile("BandCaloriesLogs.txt", "TimeStamp: " + args.EventInfo.timeStamp + " Calories: " + args.EventInfo.sensorMessage);
                        break;

                    case "Gsr":
                        GSRDisplay.Text = "Gsr: " + args.EventInfo.sensorMessage;
                        await c.saveStringToLocalFile("BandGsrLogs.txt", "TimeStamp: " + args.EventInfo.timeStamp + " Gsr: " + args.EventInfo.sensorMessage);
                        break;

                    case "AmbientLight":
                        AmbientLightDisplay.Text = "AmbientLight: " + args.EventInfo.sensorMessage;
                        await c.saveStringToLocalFile("BandAmbientLightLogs.txt", "TimeStamp: " + args.EventInfo.timeStamp + " AmbientLight: " + args.EventInfo.sensorMessage);
                        break;

                    case "Altimeter":
                        AltimeterDisplay.Text = "Altimeter: " + args.EventInfo.sensorMessage;
                        await c.saveStringToLocalFile("BandAltimeterLogs.txt", "TimeStamp: " + args.EventInfo.timeStamp + " Altimeter: " + args.EventInfo.sensorMessage);
                        break;

                    case "Barometer":
                        BarometerDisplay.Text = args.EventInfo.sensorMessage;
                        await c.saveStringToLocalFile("BandBarometerLogs.txt", "TimeStamp: " + args.EventInfo.timeStamp + " " + args.EventInfo.sensorMessage);
                        break;

                    case "RRInterval":
                        RrIntervalDisplay.Text = "RRInterval: " + args.EventInfo.sensorMessage;
                        await c.saveStringToLocalFile("BandRRIntervalLogs.txt", "TimeStamp: " + args.EventInfo.timeStamp + " RRInterval: " + args.EventInfo.sensorMessage);
                        break;

                    default:
                        Debug.WriteLine("Default case - Error on reading sensors info");
                        break;
                    }
                }).AsTask();
            };



            //bandHelper = new BandReativeExtensionsWrapper();

            //var bands = await BandClientManager.Instance.GetBandsAsync();
            //if (bands.Length < 1)
            //{
            //    var t = new MessageDialog("Can't find the Band", "Failed to Connect").ShowAsync();
            //    return;
            //}

            //await bandHelper.Connect();
            //ManageBand(bandHelper);
        }