Fake Microsoft Band
Posted on December 1, 2015
Along with my colleague at Microsoft, David Gristwood I have been working on and off on an IOT reference architecture using data from the Microsoft Band. Dave focuses on the Azure side of things and I am traditionally a more client-side developer so we teamed up to create the Band on the Run project. More about that project at a later time but for now I just wanted to share some of the client-side code for developing a band app without connecting up a physical band. This has proven to be fairly useful for us as it has allowed us to generate band data without the need to ensure we had charged up our bands / left our bands somewhere else, etc. More importantly, it has allowed us to prototype an app which consumes data from more than one band easily.
The official Microsoft Band SDK (https://developer.microsoftband.com/bandSDK) has been designed making use of interfaces, for example
The IBandService can easily be faked as can all of the other functionality exposed by the SDK. I have generated fake concrete classes for all of the interfaces I needed for the Band on the Run app and have added the source to a git repo here https://github.com/BandOnTheRun/fake-band . Those that I didn’t need throw NotImplementedException for the time being. If you use this project please feel free to fill those implementations as you go! The library is also available as a nuget package (Install-Package FakeBand) I was mainly concerned with the real-time sensor data so I used an Rx timer to simulate the data updates. Here are some screenshots of the Band on the Run client app in action:
In the app I used dependency injection to choose at run-time between the fakes and the real SDK version:
and the FakeBandService is implemented like this:
For reference the code consuming the fake implementations is all here https://github.com/BandOnTheRun/ms-band-azure