コード例 #1
0
ファイル: MainPage.xaml.cs プロジェクト: inthehand/Charming
 private async void MainPage_Loaded(object sender, RoutedEventArgs e)
 {
     p = await InTheHand.Devices.Sensors.Pedometer.GetDefaultAsync();
     if (p != null)
     {
         var r = p.GetCurrentReadings();
         foreach (KeyValuePair<InTheHand.Devices.Sensors.PedometerStepKind, InTheHand.Devices.Sensors.PedometerReading> readingentry in r)
         {
             System.Diagnostics.Debug.WriteLine(readingentry.Value.Timestamp.ToString() + " " + readingentry.Value.CumulativeSteps.ToString() + " " + readingentry.Value.StepKind);
         }
     }
 }
コード例 #2
0
ファイル: MainPage.xaml.cs プロジェクト: baskren/Pontoon
        private async void MainPage_Loaded(object sender, RoutedEventArgs e)
        {
            Windows.Devices.Radios.RadioAccessStatus s = await Windows.Devices.Radios.Radio.RequestAccessAsync();

            //await Windows.Devices.WiFi.WiFiAdapter.RequestAccessAsync();

            /*string rsel = Windows.Devices.Radios.Radio.GetDeviceSelector();
             * foreach(DeviceInformation di in await Windows.Devices.Enumeration.DeviceInformation.FindAllAsync(rsel))
             * {
             *  Debug.WriteLine(di.Name);
             *  await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async () =>
             *  {
             *      Radio r = await Windows.Devices.Radios.Radio.FromIdAsync(di.Id);
             *      Debug.WriteLine(r.Name);
             *      Debug.WriteLine(r.Kind);
             *      Debug.WriteLine(r.State);
             *  });
             * }*/

            var radios = await Windows.Devices.Radios.Radio.GetRadiosAsync();


            foreach (Windows.Devices.Radios.Radio r in radios)
            {
                System.Diagnostics.Debug.WriteLine(r.Name);
                Debug.WriteLine(r.Kind);
                Debug.WriteLine(r.State);
            }

            p = await InTheHand.Devices.Sensors.Pedometer.GetDefaultAsync();

            if (p != null)
            {
                var r = p.GetCurrentReadings();
                foreach (KeyValuePair <InTheHand.Devices.Sensors.PedometerStepKind, InTheHand.Devices.Sensors.PedometerReading> readingentry in r)
                {
                    System.Diagnostics.Debug.WriteLine(readingentry.Value.Timestamp.ToString() + " " + readingentry.Value.CumulativeSteps.ToString() + " " + readingentry.Value.StepKind);
                }
            }


            var sel = InTheHand.Devices.Bluetooth.BluetoothLEDevice.GetDeviceSelector();
            //var sel = Windows.Devices.Bluetooth.GenericAttributeProfile.GattDeviceService.GetDeviceSelectorFromUuid(InTheHand.Devices.Bluetooth.GenericAttributeProfile.GattServiceUuids.DeviceInformation);
            var devs = await Windows.Devices.Enumeration.DeviceInformation.FindAllAsync(sel);

            foreach (DeviceInformation di in devs)
            {
                //var s = await Windows.Devices.Bluetooth.GenericAttributeProfile.GattDeviceService.FromIdAsync(di.Id);

                //var d = await InTheHand.Devices.Bluetooth.GenericAttributeProfile.GattDeviceService.FromIdAsync(di.Id);
                var d = await InTheHand.Devices.Bluetooth.BluetoothLEDevice.FromIdAsync(di.Id);

                foreach (InTheHand.Devices.Bluetooth.GenericAttributeProfile.GattDeviceService serv in d.GattServices)
                {
                    System.Diagnostics.Debug.WriteLine(serv.Uuid.ToString());
                    if (serv.Uuid == GattServiceUuids.DeviceInformation)
                    {
                        foreach (InTheHand.Devices.Bluetooth.GenericAttributeProfile.GattCharacteristic ch in serv.GetCharacteristics(GattCharacteristicUuids.ManufacturerNameString))
                        {
                            if (ch.CharacteristicProperties.HasFlag(GattCharacteristicProperties.Notify))
                            {
                                ch.ValueChanged += MainPage_ValueChanged;
                            }
                            InTheHand.Devices.Bluetooth.GenericAttributeProfile.GattReadResult rr = await ch.ReadValueAsync();

                            var vl = rr.Value;
                            System.Diagnostics.Debug.WriteLine(System.Text.Encoding.UTF8.GetString(vl));
                        }
                    }
                    foreach (InTheHand.Devices.Bluetooth.GenericAttributeProfile.GattCharacteristic c in serv.GetAllCharacteristics())
                    {
                        System.Diagnostics.Debug.WriteLine(c.Uuid.ToString());


                        /*foreach(InTheHand.Devices.Bluetooth.GenericAttributeProfile.GattDescriptor ds in c.GetAllDescriptors())
                         * {
                         *  InTheHand.Devices.Bluetooth.GenericAttributeProfile.GattReadResult r = await ds.ReadValueAsync();
                         *  object raw = r.Value;
                         * }*/
                    }
                }
                System.Diagnostics.Debug.WriteLine(di.Name);
            }



            if (ApiInformation.IsTypePresent("Windows.UI.ViewManagment.StatusBar"))
            {
                StatusBar.GetForCurrentView()?.ProgressIndicator.HideAsync();
            }
        }