Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Fake Band - The Microsoft Band Emulator

0.00/5 (No votes)
1 Feb 2016 1  
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.

Install-Package FakeBand  

Step 4

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

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

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();
}

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 has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here