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