Powering up with BLE in Windows 8.1

Sign in to queue


Today's Windows Wednesday post is kind of a hardware thing, but I sort of cheated in last Friday's Hardware post, Building your own Office Remote like project... so I'm going to make up for it today... I guess... Hey! It's a Windows post, and kind of cool to, who cares if it's a little hardware related... right? So let's get too it!

Today Dan Ardelean gives us a great introduction to Windows 8.1 and its Bluetooth Low Energy API's...

BLE for developers in Windows 8.1 Part I

For who doesn't know Bluetooth Smart/Low Energy devices are devices optimized for low power consumption. Devices can act as an GATT Server, GATT client or both at the same time. In Server mode the device exposes one or more services. Each service has one or more characteristics with properties attached to it (read, write, notify, broadcast,...). The GATT Client connects to the Server and "consumes" its services.
   Windows 8.1 has added support for communicating with Bluetooth devices from the store applications. This opened the development for a lot of accessories including the Bluetooth Low Energy devices. Windows 8.1 supports only GATT client mode. This is the first iteration of the Bluetooth api and, from some points of view, it is not complete and kinda rushed out to be available. Here are some missing features:

  1. The User eXperience when connecting to an Bluetooth device is bad. The common scenario for this kind of device is that you buy the device you see the application for the Windows Store is available, download it and run the app to play with the device. Here comes the "fun" part: form inside the store application you cannot connect to devices that were not previously paired from PC Settings - Devices - Bluetooth. So, for the first connection, when the user launches the application and you don't find any device to connect to, you will have to find a way to explain and convince the user to open Settings ->Change PC Settings->.... Bluetooth and then come back to your application. Also it is not possible to launch the  Bluetooth screen directly like in Windows Phone case.
  2. For the BLE devices the whole idea of the application is to consume less but have a connection between the device (server) and the application (client). Too bad that is there is no to make teh application run in the background or receive notifications from the devices when the application is suspended. This missing feature "kills" a little bit the BLE principles and without it the protocol from the app side is not better than the classical SPP. The application should be able to connect, receive notifications in the background, be aware when the device disconnects and to be able to reconnect when available again.
  3. Without being able to connect to devices that were not previously paired beacon scenarios are not possible.
  4. Missing api's to discover the services and the characteristics of each service for any BLE device.

     Beside that let's have a first look at how the new apis work.

I have bought several BLE devices: The Texas Instruments CC2541 SensorTAG, Estimote tagKensington Proximo TAG. (I actually bought the devices in inverse order: Kensington, Estimote TI ).

       If you want to start testing/demo the BLE api I think the SensorTAG  is the best choice. The Texas Instruments chipset CC2540/1 is one of the most used chipset in BLE devices and the price of this kit is around 25$. It includes 6 sensors inside: IR temperature Sensor, Humidity Sensor, Pressure Sensor, Accelerometer, Gyroscope, Magnetometer so you can simulate various scenarios.




  When interacting with the device you will have to find the devices that expose the services we want to connect to and then connect to the desired service. For this we will call Enumeration.DeviceInformation.FindAllAsync passing an AQS string to filter the devices. Let's say we want to connect to the devices that expose the Generic Access Service as it is an standard service. We can actually generate the AQS in 3 different ways for this service:

  1. Using the the standard implemented GattServiceUuids GetDeviceSelectorFromUuid(GattServiceUuids.GenericAccess)
  2. Generating an standard UUID from an shortID GetDeviceSelectorFromShortId(0x1800) -what it actually does is to add  "-0000-1000-8000-00805f9b34fb" to the id
  3. When the service is not a standard one you will have to use GetDeviceSelectorFromUuid(new Guid(serviceGuid)) and pass the custom service guid in our case serviceGuid="00001800-0000-1000-8000-00805f9b34fb"

   The code below shows how to read the device name using the Generic Access Service of the Sensor Tag. Here are the standard characteristics of the generic access service link.


[Click through for more information, tips and tricks]

The Discussion

  • User profile image

    When will we get BLE support on Windows Phone?

  • User profile image

    @Hegey: There's no official word yet. Nokia phones are getting the hardware, (http://developer.nokia.com/community/wiki/Introduction_to_Bluetooth_support_on_Windows_Phone_8), but there's no public API's yet. Given there's a huge update coming with Windows Phone 8.1...

  • User profile image
    Rabin Neslo

    Hi Greg Duncan,

    Is it possible to read the RSSI signal from the estimate tag?



  • User profile image

    @Rabin Neslo: Hate to say this, but I have no idea. Best bet would be to ask the expert, or at least someone in the know, click through,BLE for developers in Windows 8.1 Part I, and drop Dan a comment (via email, or Google+)...

  • User profile image
    Jay Will

    I also got the SensorTag but the problem is that to really develop with it you need to have IAR Workbench for 8051, otherwise it doesn't work. It took me a while but I find the information in the comparison of <a href="http://www.argenox.com/library/wp_bluetooth.php">nRF51822 vs cc2540 2541</a>. So, you have to be careful. Nordic seems to be supporting an open source toolchain.

  • User profile image

    Hey could you please let me know may i connect windows store app with BLE device like OLP-425, if yes then provide me some reference or code example which are using this. I am newbie...

    I have visual studio 2013, windows 8.1 and OLP-425 BLE Device.

  • User profile image

    @mukesh:You are able to use a BLE device with Win 8.1.  The example code is shown for the TI Sensor Tag with default programming.   The secret is in your notes to tester when you submit your app.  Make sure to explain your BLE scenario in the notes to testers. Handle errors when device is not paired or otherwise unresponsive.

    Otherwise I would suggest that you purchase the TI sensor tag and use this example.  I know 25 bucks US is a lot of money, but the TI sensor is definitely worth it.

  • User profile image

    @Sammy Thanks for your answer, I am able to connect my BLE device OLP425 with the windows 8.1 and also able to get in my code, But the problem i am facing is when I am trying to write value to BLE device, it show me error "The attribute cannot be written. (Exception from HRESULT: 0x80650003)". Do you know why?

    here my code is

    var devices = await Windows.Devices.Enumeration.DeviceInformation.FindAllAsync(GattDeviceService.GetDeviceSelectorFromUuid(new Guid("0000ffd0-0000-1000-8000-00805f9b34fb")));

    //Connect to the service
    var accService = await GattDeviceService.FromIdAsync(devices[0].Id);
    if (accService == null)
    //Get the RED LED Service data characteristic with UUID ffd1
    var accData = accService.GetCharacteristics(new Guid("0000ffd1-0000-1000-8000-00805f9b34fb"))[0];
    //Set configuration to notify
    //here show it error
    await accData.WriteClientCharacteristicConfigurationDescriptorAsync(GattClientCharacteristicConfigurationDescriptorValue.Notify);
    //Get the ble tag configuration characteristic
    var accConfig = accService.GetCharacteristics(new Guid("0000ffd1-0000-1000-8000-00805f9b34fb"))[0];
    //Write 1 to start blink red led sbor tag
    await accConfig.WriteValueAsync((new byte[] { 1 }).AsBuffer());

  • User profile image
    Efrat Levy

    Can Win phone BLE be in a peripheral device?

Add Your 2 Cents