MS 波段:高度计传感器报告数据后所有传感器数据报告停止 [可能的错误?]
MS Band : All sensor data reporting stops after Altimeter sensor reports data [Possible Bug ?]
我正在为 Microsoft Band 开发 UWP 应用程序,最近从 Band SDK ver 1.3.11121 升级到 Microsoft Band SDK ver 1.3.20115。
我注意到,如果我订阅了多个传感器(包括 Altimeter 传感器)的 ReadingChanged 事件,一旦 Altimeter 传感器首次报告数据,我就不会收到任何传感器(包括 Altimeter)的数据。
我有简化版的代码,但还是能看出问题所在:
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
}
}
- 通过上面的代码,我看到了陀螺仪传感器的一系列更新,但是一旦高度计传感器报告了数据,陀螺仪和高度计的所有进一步数据报告就会停止。
- 代码显示调试和发布(使用 .Net Native 编译器工具链)构建的问题
- 如果我使用 Microsoft Band SDK 1.3.11121,此代码可以正常工作,但不适用于 SDK 1.3.20115。
我是否遗漏了某些代码或在代码中做错了什么?
已确认这是一个问题。此问题现已在 SDK 版本 20217 中修复。
我正在为 Microsoft Band 开发 UWP 应用程序,最近从 Band SDK ver 1.3.11121 升级到 Microsoft Band SDK ver 1.3.20115。
我注意到,如果我订阅了多个传感器(包括 Altimeter 传感器)的 ReadingChanged 事件,一旦 Altimeter 传感器首次报告数据,我就不会收到任何传感器(包括 Altimeter)的数据。
我有简化版的代码,但还是能看出问题所在:
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
}
}
- 通过上面的代码,我看到了陀螺仪传感器的一系列更新,但是一旦高度计传感器报告了数据,陀螺仪和高度计的所有进一步数据报告就会停止。
- 代码显示调试和发布(使用 .Net Native 编译器工具链)构建的问题
- 如果我使用 Microsoft Band SDK 1.3.11121,此代码可以正常工作,但不适用于 SDK 1.3.20115。
我是否遗漏了某些代码或在代码中做错了什么?
已确认这是一个问题。此问题现已在 SDK 版本 20217 中修复。