HRESULT 异常:尝试读取 Airpod pro 的电池时出现 0xD0000033
Exception from HRESULT: 0xD0000033 when trying to read battery of Airpod pro
我正在尝试使用 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
用于获取 Battery 对象,该对象表示连接到设备的单个电池控制器。然而,
蓝牙 Id 不代表电池控制器。目前还没有这样的 api 可以用来获取蓝牙电池电量。如果您确实需要此功能,请使用 windows 反馈中心应用 post 您的要求。
我正在尝试使用 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
用于获取 Battery 对象,该对象表示连接到设备的单个电池控制器。然而,
蓝牙 Id 不代表电池控制器。目前还没有这样的 api 可以用来获取蓝牙电池电量。如果您确实需要此功能,请使用 windows 反馈中心应用 post 您的要求。