Search code examples
c#win-universal-appmicrosoft-band

MS Band : All sensor data reporting stops after Altimeter sensor reports data [Possible Bug ?]


I am developing a UWP app for Microsoft Band and upgraded recently to Microsoft Band SDK ver 1.3.20115 from Band SDK ver 1.3.11121.

I noticed that if I am subscribed to ReadingChanged event of several sensors (including Altimeter sensor), I don't receive data for any sensor (including Altimeter) once the Altimeter sensor reports the data for the first time.

I have the simplified version of the code, where I can still see the problem:

    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
        }

    }
  1. With the above code I see bunch of updates for Gyroscope sensor, but once the Altimeter sensor reports the data, all further reporting of data for Gyroscope and Altimeter stops.
  2. The code shows issue for both Debug and Release (with .Net Native compiler tool chain) builds
  3. This code works fine if I use the Microsoft Band SDK 1.3.11121, but does not work for SDK 1.3.20115.

Am I missing something or doing incorrectly in the code ?


Solution

  • This was confirmed to be an issue. This issue has been fixed in SDK version 20217 now.