Search code examples
c#.netuwpbluetoothairpods

Exception from HRESULT: 0xD0000033 when trying to read battery of Airpod pro


I am trying to read my air pods pro battery life using UWP app and I get strange exception error Exception from HRESULT: 0xD0000033 without any more info. Below you can find the source:

private async Task GetBLDevices()
{
    DeviceInformationCollection ConnectedBluetoothDevices = await DeviceInformation.FindAllAsync(
                                                                    BluetoothDevice.GetDeviceSelectorFromConnectionStatus(BluetoothConnectionStatus.Connected));
    if (ConnectedBluetoothDevices == null || ConnectedBluetoothDevices.Count == 0)
        return;

    foreach (DeviceInformation connectedDevice in ConnectedBluetoothDevices)
    {
        if (connectedDevice.Name == "AirPods Pro")
            GetBatteryReport(connectedDevice.Id);
    }
}

private async void GetBatteryReport(string deviceId)
{
    try
    {
        // Create aggregate battery object
        var aggBattery = await Battery.FromIdAsync(deviceId);

        // Get report
        var report = aggBattery.GetReport();
    }
    catch (Exception ex)
    {

    }
}

Solution

  • Derive from official document, Battery.FromIdAsync is used to get a Battery object that represents an individual battery controller connected to the device. However, bluetooth Id does not represent a battery controller. And currently there is no such api that could use to get bluetooth battery level. If you do want this feature, please feel free post your requirement with windows feed back hub app.