title: How to get services and characteristics from bluetooth LE device
body: <p>I'm writing desktop app in Windows 8.1, and I need to get services from paired device using BluetoothGATTGetServices function. To make it I need to get handle to the device, that I've done and get handle using CreateFile function. But when I try to get service function return error: HRESULT_FROM_WIN32(ERROR_NOT_SUPORTED). Does anyone know how to fix it or tell what I'm doing wrong.
  My device I'm trying to get services is iPhone 5s.</p>
  
  <p>Here is code example:</p>
  
  <pre><code> HRESULT WinBluetoothDeviceProvider::GetBleHandle(OUT HANDLE* hBluetooth, WinBluetoothDevice* blDev)
  {
      GUID bthGuid;
      CLSIDFromString(TEXT(BLE_INTERFACE_GUID), &amp;bthGuid); // BLE_INTERFACE_GUID  this is GUID of my Device Interface GUID
      //#define BLE_INTERFACE_GUID "{00f40965-e89d-4487-9890-87c3abb211f4}"
  
      HRESULT result = S_OK;
      HDEVINFO hDevInfo;
      SP_DEVINFO_DATA devInfoData;
      HANDLE hBle;
  
      hDevInfo = SetupDiGetClassDevs(&amp;bthGuid, NULL, NULL, DIGCF_PRESENT | DIGCF_DEVICEINTERFACE);
      if (hDevInfo == INVALID_HANDLE_VALUE)
          return E_FAIL;
  
      devInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
      SP_DEVICE_INTERFACE_DATA devInterfData = { 0 };
      devInterfData.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA);
      DWORD DataT;
      LPTSTR buffer = NULL;
      DWORD buffersize = 0;
  
  
      devInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
  
      for (DWORD i = 0; SetupDiEnumDeviceInterfaces(hDevInfo, NULL, &amp;bthGuid, i, &amp;devInterfData); i++)
      {
          DWORD d = GetLastError();
          DWORD size = 0;
  
          if (!SetupDiGetDeviceInterfaceDetail(hDevInfo, &amp;devInterfData, NULL, 0, &amp;size, 0))
          {
              if (GetLastError() == ERROR_NO_MORE_ITEMS)
              {
                  result = S_OK;
                  break;
              }
  
              PSP_DEVICE_INTERFACE_DETAIL_DATA pInterfaceDetailData = (PSP_DEVICE_INTERFACE_DETAIL_DATA)LocalAlloc(LPTR, size);
              pInterfaceDetailData-&gt;cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA);
  
              if (!SetupDiGetDeviceInterfaceDetail(hDevInfo, &amp;devInterfData, pInterfaceDetailData, size, &amp;size, &amp;devInfoData))
              {
                  result = E_FAIL;
                  break;
              }
  
              hBle = CreateFile(pInterfaceDetailData-&gt;DevicePath, 
                  GENERIC_READ | GENERIC_WRITE,
                  FILE_SHARE_READ | FILE_SHARE_WRITE,
                  NULL,
                  OPEN_EXISTING,
                  FILE_ATTRIBUTE_NORMAL,
                  NULL);
  
              USHORT serviceBuffActual;
              PBTH_LE_GATT_SERVICE servicesBuff = new _BTH_LE_GATT_SERVICE;
              HRESULT result = S_OK;
  
              result = BluetoothGATTGetServices(hBle,
                  0, NULL, &amp;serviceBuffActual, BLUETOOTH_GATT_FLAG_NONE);
              // this function always retunr ERROR_NOT_SUPPORTED
  
              LocalFree(pInterfaceDetailData);
          }
      }
      SetupDiDestroyDeviceInfoList(hDevInfo);
  
      return result;
  }
  </code></pre>