D
D
darked2020-09-03 15:43:11
Bluetooth
darked, 2020-09-03 15:43:11

Any options to get battery level of bluetooth headphones (C#, Delphi)?

Good afternoon.
I would like to write a utility to show the battery level of bluetooth headphones. I looked at UWP, there are the necessary APIs for working with bluetooth and battery power, but this does not work with bluetooth headphones. I do like this:

var devices = await DeviceInformation.FindAllAsync(
                BluetoothDevice.GetDeviceSelectorFromConnectionStatus(BluetoothConnectionStatus.Connected));

            foreach (DeviceInformation device in devices)
            {
                try
                {
                    // Create battery object
                    var battery = await Battery.FromIdAsync(device.Id); - тут происходит исключение

                    // Get report
                    var report = battery.GetReport();

                    // Update UI
                    //AddReportUI(BatteryReportPanel, report, battery.DeviceId);
                    ListBoxItemcColllections.Add(report.Status.ToString());
                }
                catch(Exception e)
                {
                    ErrorTextInfo = e.Message;
                }

            }

But an exception is thrown, I found this answer on SO -
Battery.FromIdAsync is used to get a Battery object that represents an individual battery controller connected to the device. However, bluetooth Id does not represent a battery controller. And currently there is no such api that could use to get bluetooth battery level.


This is where the question comes from - are there any options at all to get a headphone charge under Windows?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question