Click here to Skip to main content
15,886,199 members
Articles / Desktop Programming / Universal Windows Platform
Tip/Trick

Fake Band - The Microsoft Band Emulator

Rate me:
Please Sign up or sign in to vote.
5.00/5 (4 votes)
1 Feb 2016CPOL 10.5K   4  
Want to develop apps for Microsoft Band, while having no band device? It is now possible. Test out your app with Band on the Run.

Introduction

Wearable devices are very famous now a days. Microsoft band is one of them. Currently, Microsoft Band 2 is in the market with a price of $249.99. Microsoft Band comes with a number of sensors, including GPS sensor for footstep counts, heart beat monitoring and many more. If you want to develop apps for Microsoft Band while having no band, you would not test your apps without Microsoft Band till today. But now, it is not a problem.

Fake Band is available now. Fake Band enables you to test your Band apps without Band. Fake Band is a library for developing and testing Band apps without connecting to physical Band device.

Steps are quite simple.

Step 1

Download and install the Band SDK from https://developer.microsoftband.com/bandSDK.

Step 2

Create a UWP project in Visual Studio.

Step 3

Get the Fake Band.

Write the following command in Package Manager console of Visual Studio.

C#
Install-Package FakeBand  

Step 4

Now, you are able to use the FakeBand library. The following code snippet helps you to understand the working.

C#
FakeBandClientManager.Configure(new FakeBandClientManagerOptions
  {
      Bands = new List<IBandInfo>
      {
          new FakeBandInfo(BandConnectionType.Bluetooth, "Fake Band 1"),
          new FakeBandInfo(BandConnectionType.Bluetooth, "Fake Band 2"),
      }
  });

  // Use the fake band client manager
  IBandClientManager clientManager = FakeBandClientManager.Instance;

  // Microsoft Band SDK code
  var bands = await clientManager.GetBandsAsync();
  var bandInfo = bands.First();

  var bandClient = await FakeBandClientManager.Instance.ConnectAsync(bandInfo);
  var meTile = await bandClient.PersonalizationManager.GetMeTileImageAsync();

  var wb = meTile.ToWriteableBitmap();
  MeTileImage.Source = wb; //MeTileImage is the name of Image XAML tag

Get Data from Sensors

C#
var uc = bandClient.SensorManager.Accelerometer.GetCurrentUserConsent();
bool isConsented = false;

if (uc == UserConsent.NotSpecified)
{
    isConsented = await bandClient.SensorManager.Accelerometer.RequestUserConsentAsync();
}

if (isConsented || uc == UserConsent.Granted)
{
    bandClient.SensorManager.Accelerometer.ReadingChanged += async (obj, ev) =>
    {
        await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
        {
            // Update User Interface...
        });
    };

    await bandClient.SensorManager.Accelerometer.StartReadingsAsync();
}

Image 1

For more details, check out http://peted.azurewebsites.net/fake-microsoft-band/.

Fake Band on GitHub can be found at https://github.com/BandOnTheRun/fake-band.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
Pakistan Pakistan
I am passionate about programming, playing with data is all time my favorite hobby. Making things, processes intelligent and convenient is my ultimate goal. Love to work with real-time systems. Cloud is my life.

Comments and Discussions

 
-- There are no messages in this forum --