我正在尝试使用 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/