Search code examples
uwpbluetooth-lowenergybluetooth-gatt

Uwp How to get the Human Interface Device(HID) service from BluetoothLEDevice


First of all, Sorry for my bad English. I'm studying about BluetoothLE under the UWP. Now, I can pair with my Bluetooth Low-Energy device and i can get services. And then, I want to get the all characteristics from my Bluetooth(LE) device.

I can get all service's characteristics except Human Interface Device(HID)'s characteristics. Below is the code get the characteristic( when change the service in combobox event)

private async void ServiceListCombo_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var service = (GattDeviceService)((ComboBoxItem)ServiceListCombo.SelectedItem)?.Tag;
            CharacteristicCombo.Items.Clear();

            IReadOnlyList<GattCharacteristic> characteristics = null;
            try
            {
                var accessStatus = await service.RequestAccessAsync();
                if(accessStatus == DeviceAccessStatus.Allowed)
                {
                    var result = await service.GetCharacteristicsAsync(BluetoothCacheMode.Uncached);
                    if(result.Status == GattCommunicationStatus.Success)
                    {
                        characteristics = result.Characteristics;
                    }
                    else
                    {
                        StatusTextBlock.Text = $"{result.Status.ToString()} // Failed";
                        characteristics = new List<GattCharacteristic>();
                    }
                }
                else
                {
                    StatusTextBlock.Text = $"{accessStatus.ToString()} // Failed2";
                    characteristics = new List<GattCharacteristic>();
                }
            }
            catch(Exception msg)
            {
                StatusTextBlock.Text = $"Exception : {msg.Message}";
                characteristics = new List<GattCharacteristic>();
            }
            foreach(GattCharacteristic c in characteristics)
            {
                CharacteristicCombo.Items.Add(new ComboBoxItem { Content = Helpers.GetCharacteristicName(c), Tag = c });
            }
            CharacteristicCombo.Visibility = Visibility.Visible;
        }

I can see all characteristics except HID ( Status : access denied by System )

So what I want to know, How can i get the characteristics in HID Service's characteristics.

I really appreicate ,if you let me know any idea or suggestion.

Thank you.


Solution

  • I can get all service's characteristics except Human Interface Device(HID)'s characteristics.

    Please check the document here. At Support for Bluetooth RFCOMM services part you will find Human Interface Device does not support, I'm afraid you can't get hid device characteristics within ble, if you do want this feature, please feel free post your requirement with Windows Feed Back Hub.