• 赚钱入口【需求资源】限时招募流量主、渠道主,站长合作;【合作模式】CPS长期分成,一次推广永久有收益。主动打款,不扣量;

Exception from HRESULT: 0xD0000033

iOS cps12345 9个月前 (11-20) 212次浏览 0个评论

读取AirPods 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)
    {

    }
}

原因

源自官方文档,Battery.FromIdAsync用于获取Battery对象,该对象代表连接到设备的单个电池控制器。但是,蓝牙ID不代表电池控制器。并且目前没有这样的api可以用来获取蓝牙电池电量。

喜欢 (0)

您必须 登录 才能发表评论!