BluetoothGATTRegisterEvent function () any samples on how to use this ? what is this HANDLE hService ? poor documentation RRS feed

  • Question

  • HRESULT WINAPI BluetoothGATTRegisterEvent( _In_      HANDLE hService, _In_      BTH_LE_GATT_EVENT_TYPE EventType, _In_      PVOID EventParameterIn, _In_      PFNBLUETOOTH_GATT_EVENT_CALLBACK Callback, _In_opt_  PVOID CallbackContext, _Out_     BLUETOOTH_GATT_EVENT_HANDLE * pEventHandle, _In_      ULONG Flags );

    what is hService ? how to create it ?

    i tried to use the device handle created using CreateFile() on the BLE Device and i got a invalid handle error message.

    kindly help.



    - P -

    Friday, February 7, 2014 4:24 AM


  • Hello Pradeep,

    The hService handle must be a handle to a Bluetooth LE service. Upon successful pairing the Bluetooth LE device enumerates it's services as individual device nodes, each with it's own device interface, the handle must point to a specific service device interface, as opposed to the device's Device Interface.

    Depending on the context of how you're using this there are several approaches at your disposal:

    1. If you're trying to use this from a user-mode application the you're better off using the Windows Runtime API:

    Sample code:

    2. If you're building you own driver, you can build a UMDF WPD driver, which you install on the specific device node and you can perform I/O to the device using the WPD API.

    Sample driver code, is in the Window 8 sample bundle, under the Bluetooth folder:

    All the other ways to get a handle to a device still apply, but just keep in mind that it must be a handle to an LE Service Device Interface, and not a handle to the Device's Device Interface.

    Please let us know if you need any more information and how we can help.

    Thank you!

    Monday, February 10, 2014 11:15 PM