c# - HRESULT : 0xD0000033 when trying to read battery of Airpod pro 异常

标签 c# .net uwp bluetooth airpods

我正在尝试使用 UWP 应用程序读取我的 Air Pods Pro 电池生命周期,但出现奇怪的异常错误 Exception from HRESULT: 0xD0000033,没有任何更多信息。您可以在下面找到来源:

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

    }
}

最佳答案

源自官方document , Battery.FromIdAsync 用于获取表示连接到设备的单个电池 Controller 的 Battery 对象。然而, 蓝牙 ID 不代表电池 Controller 。目前还没有这样的API可以用来获取蓝牙电池电量。如果您确实需要此功能,请随时通过 Windows 反馈中心应用程序发布您的要求。

关于c# - HRESULT : 0xD0000033 when trying to read battery of Airpod pro 异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62451341/

相关文章:

uwp - 获得总体 CPU 百分比使用率的可能性有哪些

c# - 'MyUserControls.ComboBox 1' does not contain definition for ' ItemsSource'

c# - 在循环中一步步启动协程

c# - 多语言网站性能

xaml - 当文本变为粗体时防止内容调整大小

c# - 从 UWP 应用获取图标

C# 在委托(delegate)调用中等待

c# - 作为聚合异常抛出的自定义异常

c# - 坐标时区

c# - 使 C# 代码在 .NET < 4 中后期绑定(bind)的侵入性最小的方法是什么?