none
BluetoothGATTRegisterEvent and callback function with the PVOID Context precised RRS feed

  • Question

  • Hi,

    I use the function BluetoothGATTRegisterEvent to register to Bluetooth notification.

    but in my case, i use two thingy from nordic semiconductor and i would like use multiple device.

    the issue is that i don't know wich is the device trigerred the notification (didn't find the handle from de device during notification function call 

    i would like pass in the handle information of the offset of my array information named "index"

    how must i precize "  _In_opt_ PVOID  CallbackContext" ? 

    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
    );

     hr = BluetoothGATTRegisterEvent(

                    hLEDeviceThingy[Index],
                    EventType,
                    &EventParameterIn,
                    SomethingHappenedThingy,
                    NULL,
                    &EventHandleThingy[Index],
                    BLUETOOTH_GATT_FLAG_NONE);

    void CALLBACK SomethingHappenedThingy(BTH_LE_GATT_EVENT_TYPE EventType, PVOID EventOutParameter, PVOID Context)

    Tuesday, May 1, 2018 8:41 AM

Answers

  • If all you want is a number, then just cast the integer to a (PVOID).  A PVOID is always going to be at least 32 bits.

    Alternatively, you could create a small structure containing the index, and pass the address of that structure.  Remember to allocate the structure from the heap and not the stack.


    Tim Roberts, Driver MVP Providenza & Boekelheide, Inc.

    Tuesday, May 1, 2018 5:18 PM

All replies

  • The idea is to use/configure the context to provide information about the device who triggered the event.
    Tuesday, May 1, 2018 8:42 AM
  • If all you want is a number, then just cast the integer to a (PVOID).  A PVOID is always going to be at least 32 bits.

    Alternatively, you could create a small structure containing the index, and pass the address of that structure.  Remember to allocate the structure from the heap and not the stack.


    Tim Roberts, Driver MVP Providenza & Boekelheide, Inc.

    Tuesday, May 1, 2018 5:18 PM