Microsoft Band SDK是否支持Windows 10上的UWP应用程序从带中提取数据?

时间:2016-01-14 18:49:27

标签: raspberry-pi2 microsoft-band windows-10-iot-core

我想在Windows 10上使用覆盆子pi上的UWP应用程序从乐队中提取传感器数据。该应用程序在Windows 10机器上运行时运行良好,但是,当在Windows 10上运行时,它会显示错误。

执行在App.g.i.cs文件中的自动生成代码中断:

#if DEBUG && !DISABLE_XAML_GENERATED_BREAK_ON_UNHANDLED_EXCEPTION
        UnhandledException += (sender, e) =>
        {
            if (global::System.Diagnostics.Debugger.IsAttached)global::System.Diagnostics.Debugger.Break();
        }; 
#endif

在调用堆栈中显示:

  

FFM.exe!FFM.App.InitializeComponent.AnonymousMethod__5_1(object sender,Windows.UI.Xaml.UnhandledExceptionEventArgs e)第53行C#

第53行是自动生成的代码:

if (global::System.Diagnostics.Debugger.IsAttached)global::System.Diagnostics.Debugger.Break();

调试输出显示如下:

Exception thrown: 'System.NotImplementedException' in mscorlib.ni.dll

乐队能够连接到Windows 10 iot Raspi,但只要有代码要求用户同意访问心率传感器数据,就会出现上述错误。

以下是获取用户同意的代码。其中大部分来自SDK文档:

private async void connect()
{
    //Get a list of paired bands
    IBandInfo[] pairedBands = await BandClientManager.Instance.GetBandsAsync();
    string band_name = pairedBands[0].Name;
    if (band_name.Length > 0)
    {
        bandName.Text = "Band Name is: " + band_name;
        try
        {
            fwVer.Text = "Will try to connect to band";
            IBandClient bandClient = await BandClientManager.Instance.ConnectAsync(pairedBands[0]);

            fwVer.Text = "Connected to Band";

            fwVersion = await bandClient.GetFirmwareVersionAsync();
            hwVersion = await bandClient.GetHardwareVersionAsync();

            fwVer.Text = "Firmware Version is " + fwVersion;
            hwVer.Text = "Hardware Version is " + hwVersion;

            string band1v = "9";
            if (hwVersion.Equals(band1v, StringComparison.Ordinal))
            {
                // Do work with Version 1 of the band
                bandVer.Text = "Band is Version 1";

                //User consent check to use heartbeat sensor data
                if (bandClient.SensorManager.HeartRate.GetCurrentUserConsent() != UserConsent.Granted)
                {     
                    //Get user consent
                    await bandClient.SensorManager.HeartRate.RequestUserConsentAsync();
                }   
                if (bandClient.SensorManager.HeartRate.GetCurrentUserConsent() == UserConsent.Granted)
                {
                    //DO work
                }
                else
                {
                    hrConsent.Text = "Access to HeartReat sensor is denied";
                }
            }
            else //Its a 2nd version of band
            {
                //Do work with version 2 of the band
                bandVer.Text = "Band is Version 2";
            }
        }
        catch (BandException ex)
        {
            //handle a band connection exception
            fwVer.Text = "Could not connect to above band";
        }
    }
    else
    {
        bandName.Text = "No Available Bands";
    }
}

以下是我正在使用的库:

using System;
using System.Threading;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI;
using Windows.UI.Core;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;

using Microsoft.Band;
using Microsoft.Band.Sensors;
using Microsoft.IoT;

using Windows.Devices.Bluetooth;
using Windows.Devices.Bluetooth.GenericAttributeProfile;

1 个答案:

答案 0 :(得分:2)

当应用程序调用{​​{1}}时,Band SDK会向用户显示一条对话框消息,以获取该同意。但是,Windows IoT Core似乎尚不支持Windows.UI.Popups.MessageDialog(请参阅unavailable API list)。

这可能是例外的原因。