none
How to discover, connect/disconnect and reconnect to bluetooth low energy device from windows 8.1? RRS feed

  • Question

  • Hi,

    I create application works with my device via bluetooth low energy. 

    1 I need discover available to connection devices and automatically connect to send settings. And reconnect if connection is broken.

    2 Also I need monitor connection state (with signal power)

    Now I use BLED112 (serial port) and BLE112.

    But I have notebook with win 8.1 and embedded Bluetooth LE. I would like to use it.

    Please tell me how I can use embedded BLE?

    I am working on C#.

    Sunday, November 10, 2013 6:36 PM

Answers

  • The way to use Bluetooth LE devices in Windows Store Apps in Windows 8.1 is through the GenericAttributeProfile namespace (http://msdn.microsoft.com/en-us/library/windows/apps/windows.devices.bluetooth.genericattributeprofile.aspx)

    1. In order to uses your device with Windows, it must first be paired, once paired the Windows Bluetooth stack handles connections to your device automatically, if you need to write something to the device, just call WriteCharacteristicValueAsync, that will automatically attempt to establish a connection to the device if it's not already connected, if a connection attempt failed because the device was not there, you'll get an Unreachable GattCommunicationStatus.

    2. If you need to monitor the connection state you can use a DeviceWatcher to monitor the PnP Connected State of the device. If your requirements also include auto-reconnecting when the device is in reach, you'll need to register for notifications or indications on a characteristic value that supports them, this will make sure that a connection is automatically established when your device is in range.

    This sample shows how to accomplish all those things:

    http://code.msdn.microsoft.com/windowsapps/Bluetooth-Generic-5a99ef95

    Bluetooth drivers should be installed automatically for the Bluetooth LE device in your laptop, one way to check that Bluetooth LE is running normally is by going to Device Manager->Check the status of your inbox Bluetooth radio (it should be listed under Bluetooth, you should also see a "Microsoft Bluetooth LE Enumerator", that means that your Bluetooth LE radio is working properly, if you don't se it please give us more details about what laptop/radio combination you are using.

    Thank you,

    Florin

    Wednesday, November 13, 2013 7:07 PM

All replies

  • The way to use Bluetooth LE devices in Windows Store Apps in Windows 8.1 is through the GenericAttributeProfile namespace (http://msdn.microsoft.com/en-us/library/windows/apps/windows.devices.bluetooth.genericattributeprofile.aspx)

    1. In order to uses your device with Windows, it must first be paired, once paired the Windows Bluetooth stack handles connections to your device automatically, if you need to write something to the device, just call WriteCharacteristicValueAsync, that will automatically attempt to establish a connection to the device if it's not already connected, if a connection attempt failed because the device was not there, you'll get an Unreachable GattCommunicationStatus.

    2. If you need to monitor the connection state you can use a DeviceWatcher to monitor the PnP Connected State of the device. If your requirements also include auto-reconnecting when the device is in reach, you'll need to register for notifications or indications on a characteristic value that supports them, this will make sure that a connection is automatically established when your device is in range.

    This sample shows how to accomplish all those things:

    http://code.msdn.microsoft.com/windowsapps/Bluetooth-Generic-5a99ef95

    Bluetooth drivers should be installed automatically for the Bluetooth LE device in your laptop, one way to check that Bluetooth LE is running normally is by going to Device Manager->Check the status of your inbox Bluetooth radio (it should be listed under Bluetooth, you should also see a "Microsoft Bluetooth LE Enumerator", that means that your Bluetooth LE radio is working properly, if you don't se it please give us more details about what laptop/radio combination you are using.

    Thank you,

    Florin

    Wednesday, November 13, 2013 7:07 PM
  • Hi,

    Are there any BLE discovery and pairing APIs  available in Windows 8.1 ?

    Basically looking for an API which can discover and pair and unpaired device.

    thanks,


    - P -

    Monday, January 27, 2014 10:17 PM
  • I'm no expert, but everything I've read says you can't do that at this time.  You have to pair it through the Win8 UI and then you're good to go.  If you're attempting a Beacon app (whatever that is), you can't do it.

    There's an update coming this week or next and it might be in there.  Check out the Build 2014 conference.

    Wednesday, April 2, 2014 2:49 PM
  • Hey i have to pair first time with BLE, Isn't it possible to detect BLE device and connect automatically using code. Any idea?

    muke

    Wednesday, July 23, 2014 5:14 PM
  • Hey i have to pair first time with BLE, Isn't it possible to detect BLE device and connect automatically using code. Any idea?

    muke

    Perhaps using the dll located in the %windir%\ImmersiveControlPanel folder...

    But I don't know of a... (word meaning instruction manual, written to describe how to use a program for advanced users) for this dll.


    It is not my fault if your computer combusts. If this helped, press the /\ arrow over ↖there. If it answers the question, click Propose as Answer ↓there. If you asked the question in the first place, click Mark as answer ↓below.

    Tuesday, March 24, 2015 8:32 PM