none
Help ! How to get the Bluetooth Low Energy device handle? RRS feed

  • Question

  • I want to get the Bluetooth Low Energy device handle (hLEDevice), like this:

      hr = BluetoothGATTGetServices(
                hLEDevice,
                0,
                NULL,
                &serviceBufferCount,
                BLUETOOTH_GATT_FLAG_NONE);

    I try to use BluetoothFindFirstDevice or BluetoothSelectDevices  ,I failed!!!

    I want to achieve the effect of just like C:\Program Files (x86)\Windows Kits\8.1\Tools\x86\Bluetooth\BthGATTDump\bthgattdump.exe   thank!!

    Monday, September 14, 2015 12:32 AM

Answers

  • Thanks for your question. You will find this forum post contains the answer to your question:

    https://social.msdn.microsoft.com/Forums/en-US/e5e1058d-5a64-4e60-b8e2-0ce327c13058/erroraccessdenied-error-when-trying-to-receive-data-from-bluetooth-low-energy-devices?forum=wdk

    Tuesday, September 15, 2015 2:21 PM

All replies

  • Thanks for your question. You will find this forum post contains the answer to your question:

    https://social.msdn.microsoft.com/Forums/en-US/e5e1058d-5a64-4e60-b8e2-0ce327c13058/erroraccessdenied-error-when-trying-to-receive-data-from-bluetooth-low-energy-devices?forum=wdk

    Tuesday, September 15, 2015 2:21 PM
  • thank , this is useful,very thank!
    Wednesday, November 4, 2015 2:11 AM
  • Hope the below code will work for you
    BLUETOOTH_DEVICE_INFO DeviceInfo;
     HBLUETOOTH_RADIO_FIND Find = NULL;
     HBLUETOOTH_DEVICE_FIND hBthDeviceFind = NULL;
     HANDLE hRadio = NULL;
     BLUETOOTH_DEVICE_SEARCH_PARAMS SearchParams = { sizeof(BLUETOOTH_DEVICE_SEARCH_PARAMS),
     1, //// fReturnAuthenticated
     0, // fReturnRemembered
     1, // fReturnUnknown
     1, // fReturnConnected
     1, // fIssueInquiry
     15, // cTimeoutMultiplier
     NULL // hRadio
     };
     while (TRUE)
     {
     Find = BluetoothFindFirstRadio(&params, &hRadio);
     DWORD Ret = 0;
     do
     {
     Ret = BluetoothGetRadioInfo(hRadio, &Info);
     if (ERROR_SUCCESS == Ret)
    {
     CString csRadioName = CString(Info.szName);
     SearchParams.dwSize = sizeof(BLUETOOTH_DEVICE_SEARCH_PARAMS);
     SearchParams.hRadio = hRadio;
     ZeroMemory(&DeviceInfo, sizeof(BLUETOOTH_DEVICE_INFO));
     DeviceInfo.dwSize = sizeof(BLUETOOTH_DEVICE_INFO);
     hBthDeviceFind = BluetoothFindFirstDevice(&SearchParams, &DeviceInfo);
     if (NULL != hBthDeviceFind)
     {
     do
     {
     // Get the device name.
     CString csBthDeviceName(DeviceInfo.szName); // BT device detected.
     if (!BluetoothFindNextDevice(hBthDeviceFind, &DeviceInfo))
     {
     break;
     }
    
    } while (BluetoothFindNextDevice(hBthDeviceFind, &DeviceInfo));
    
    // Close te blue tooth device handle
     if (!BluetoothFindDeviceClose(hBthDeviceFind))
     {
     MessageBox(L"Error occured BluetoothFindDeviceClose() ");
     }
     }
     }
     if (!BluetoothFindNextRadio(&params, &hRadio))
     {
     break;
     }
     } while (BluetoothFindNextRadio(&params, &hRadio));
    
    if (!BluetoothFindRadioClose(Find))
     {
    MessageBox(L"Error occured BluetoothFindRadioClose() ");
    }
    

    Thursday, November 19, 2015 12:06 PM