System.FromIdAsync(id)中的System .__ ComObject

时间:2017-10-13 09:12:21

标签: c# windows bluetooth battery comobject

我目前正在玩Windows.Devices.Power。

我为蓝牙设备创建了一个观察程序,并且已经检索了附近发现的设备。但问题是,当我尝试获取特定设备的电池电量时,我只是得到响应“System .__ ComObject”。

如何检索电池电量值?我做错了什么?

    private void DeviceWatcherOnAdded(DeviceWatcher sender, DeviceInformation device)
    {
        if (!deviceNamesArray.Contains(device.Name) && device.Pairing.IsPaired && device.IsEnabled)
        {
            deviceNamesArray.Add(device.Name);
            //Retrieves name of device with no problem
            Console.WriteLine(device.Name);

            //Returns System.__ComObject
            var battery = Battery.FromIdAsync(device.Id);

            //Returns null
            Console.WriteLine(battery.GetResults());
        }
    }

0 个答案:

没有答案