In this post, I’m going to cover the basics of getting your WinRT (Windows Store and Windows Phone) apps set-up with the Microsoft Band SDK and getting you connected to your device.

Adding Microsoft Band Nuget Package

Adding Microsoft Band Nuget Package

As the package is currently a Nuget pre-release, you’ll have to manually add the package using the Package Manager Console. You’ll then need to paste in the following line of into the console to install it to your project.

Install-Package Microsoft.Band -Pre

Doing this will get you set-up and ready to start developing for the Microsoft Band as is expected. One thing it does for you that you’ll need to know if you don’t install the package through Nuget is that it adds a DeviceCapability into your Package.appxmanifest file which enables the Bluetooth capabilities for the Band which is as follows:

    <DeviceCapability Name="bluetooth.rfcomm" xmlns="">
      <Device Id="any">
        <!-- Used by the Microsoft Band SDK Preview -->
        <Function Type="serviceId:A502CA9A-2BA5-413C-A4E0-13804E47B38F" />
        <!-- Used by the Microsoft Band SDK Preview -->
        <Function Type="serviceId:C742E1A2-6320-5ABC-9643-D206C677E580" />
Adding the Proximity capability

Adding the Proximity capability

If you have to manually add this, you can do it by right-clicking your manifest file and opening it with the XML text editor. However, there is one manual step you DO need to perform to get going and that is to add the Proximity capability in your manifest. You’ll find that under the Capabilities tab if you open the file using the default editor.

Getting connected

Before we get you connecting your app to your Band, you’ll first need to pair the device with your phone (which you’ll probably have done if you’re using the Band on a day-to-day basis).

To get yourself going, you’ll want to add Microsoft.Band using directive to your class. From there you can using the BandClientManager to get a list of the paired bands with the phone the app will be running on. You’ll do this as follows:

var bandInfo = (await BandClientManager.Instance.GetBandsAsync()).FirstOrDefault();

You’ll most likely only have one Band connected to your device for calling FirstOrDefault from the System.Linq namespace will return your the first device in the array that is returned from the GetBandsAsync method. If no device is connected, it will return null which you’ll have to handle in your application.

Now that you hold a reference to your Band, you’ll want to get yourself connected which is as simple as using the BandClientManager. You’ll do that as follows:

                using (var bandClient = await BandClientManager.Instance.ConnectAsync(bandInfo))
            catch (BandException be)

While it is possible that your device is connected to your phone, there will be occasions when the user is not with their mobile device and the Band becomes disconnected. You’ll have to handle that in your application as shown above.

Now you’ve got yourself connected with your Band. I’ll be writing up further blogs which will cover everything from creating your app tile on the Band to taking advantages of the Bands sensor to create applications as I work through updating my PhysiHealth application to use the new SDK.

Join the discussion 2 Comments

  • AltShift says:

    Hi James, nice work!

    Do I need to have a Windows Phone (8.1) to be able to develop for the Band?

    I was hoping to be able to program it from and communicate with my laptop, so that I can use the Band for real-time data acquisition and analysis, but everything I’ve read seems to assume there is a Windows Phone in the loop.

  • Karl S says:

    hi, I’m creating a WIn 8.1 app, very simple routine where it grabs the X movements and tries to move a html hand. I wonder if you can help, I’ve connected my band to the laptop via bluetooth but when calling ‘var pairedBands = await manager.GetBandsAsync();’ it returns null. It doesn’t the band info etc. Have you heard of any issues where this doesn’t return a value?

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.