In my previous post I wrote on how to connect a Microsoft Band to a Windows 10 device using Bluetooth. Today I will show the 5 lines of code that we should use to access the Band from a Windows 10 Universal App project and also to show information from the band sensors.
1. Once we have paired the device with our computer, we can now create a Universal Windows App in Visual Studio 2015.
2. We must install the specific NuGet package for Microsoft Band for Windows 10 apps.
3. The MSBand SDK, includes a special class that is what allows us to work with the band [Microsoft.Band.BandClientManager]. This class allows us to
a. to list the bands associated with a device
b. connect to one Band
4. In the following code sample
a. lines 41 and 42, displays how to access to the instance of the manager and get the associated Bands.
b. line 55, connect to the MSBand
5. To display information for the band, I use a class that Iris wrote some time ago. This information is then displayed in a Text Block in Windows 10 app.
6. Our next step is to access the information from any of the sensors of the Band. To do this we use the [SensorManager] class. The following code example displays
a. lines 69 and 70, request user grant to access information from a sensor. This is not necessary for all sensors, although some like the Heart Rate one, requires this.
b. line 71, subscription to the change of values
c. line 72, beginning of reading of values
d. line 76, processing and reading of values
7. In my ugly Windows 10 app, this information is also displayed in a text block.
8. Finally, the following video shows the application in raw mode showing the band information.
In the next posts we will see how to send information to the band and how to interact with the same.
Saludos @ Madrid
– Iris Classon, Connect to a Band and retrieve Band information