我正在为Microsoft Band开发一个UWP应用程序,并最近从Band SDK ver 1.3.11121升级到Microsoft Band SDK ver 1.3.20115。
我注意到如果我订阅了几个传感器的ReadingChanged事件(包括高度计传感器),一旦高度计传感器第一次报告数据,我就不会收到任何传感器(包括高度计)的数据。
我有代码的简化版本,我仍然可以看到问题:
IBandClient bandClient;
async void SetupBand()
{
IBandInfo[] pairedBands = await BandClientManager.Instance.GetBandsAsync();
try
{
bandClient = await BandClientManager.Instance.ConnectAsync(pairedBands[0]);
if (bandClient.SensorManager.Gyroscope.GetCurrentUserConsent() != UserConsent.Granted)
{
await bandClient.SensorManager.Gyroscope.RequestUserConsentAsync();
}
if (bandClient.SensorManager.Altimeter.GetCurrentUserConsent() != UserConsent.Granted)
{
await bandClient.SensorManager.Altimeter.RequestUserConsentAsync();
}
IEnumerable<TimeSpan> supportedAltimeterReportingIntervals = bandClient.SensorManager.Altimeter.SupportedReportingIntervals;
TimeSpan T1 = supportedAltimeterReportingIntervals.First();
bandClient.SensorManager.Altimeter.ReportingInterval = T1;
IEnumerable<TimeSpan> supportedGyroscopeReportingIntervals = bandClient.SensorManager.Gyroscope.SupportedReportingIntervals;
TimeSpan T2 = supportedGyroscopeReportingIntervals.First();
bandClient.SensorManager.Gyroscope.ReportingInterval = T2;
bandClient.SensorManager.Altimeter.ReadingChanged += (sender, args) =>
{
System.Diagnostics.Debug.WriteLine("Input received for Altimeter");
};
bandClient.SensorManager.Gyroscope.ReadingChanged += (sender, args) =>
{
System.Diagnostics.Debug.WriteLine("Input received for Gyroscope");
};
await bandClient.SensorManager.Gyroscope.StartReadingsAsync();
await bandClient.SensorManager.Altimeter.StartReadingsAsync();
}
catch (BandException ex)
{
// handle a Band connection exception
}
}
我在代码中遗漏了什么或做错了吗?
答案 0 :(得分:1)
这被证实是一个问题。此问题已在SDK版本20217中得到修复。