maniacx / Bluetooth-Battery-Meter

A Gnome extension featuring indicator icons in system tray, serving as meter for Bluetooth device battery levels and providing detailed battery levels via icon/text in the Bluetooth quick settings menu.
https://extensions.gnome.org/extension/6670/bluetooth-battery-meter/
GNU General Public License v3.0
107 stars 11 forks source link

Add ability to ready Sony/Samsung battery levels #4

Closed Toxblh closed 10 months ago

maniacx commented 3 months ago

Hello @Toxblh

I trying to get multiple battery reporting working for the extension. But before I work on the GUI, i was looking at how to get L/R/Case information.

Do to this purely in Gjs may be quite complex.

https://github.com/TheWeirdDev/Bluetooth_Headset_Battery_Level

So I have trying this python script, just could not get is working with my jabra earbuds connected.

It only works when my earbud is disconnected.

I am guessing since pipewire is using this rfcomm port/channel hence the script cannot communicate.

I saw your script for sony and it seem to be based TheWeirdDev script.

Does it work when your sony earbuds are connected and streaming? Or do you have to disconnect sony earbuds, to get battery levels or change modes?

Let me know how did you workaround this problem.

Toxblh commented 1 month ago

After some time I found @steam3d expose his solution which provide strong backend for AirPods,Sony and etc headphones with enhanced ability

Diff branches for diff solutions: https://github.com/steam3d/MagicPodsCore - python https://github.com/steam3d/MagicPodsCore/tree/decky - steam deck implementation https://github.com/steam3d/MagicPodsCore/tree/sony - sony target

maniacx commented 1 month ago

Yes. I did find it few days back. It was written in c language. But whenever I ran it, it would disconnect the airpods and connected it back again. But it did gave all the information. Lately changed to python. I didn't try that. But looks promising.

Also I was trying to achieve communication with either rfcomm or l2cap purely in gjs. It think there is no way. I could not find a way to connect to bluetooth socket purely in gjs.

Do you have any idea about connecting to bluetooth socket in gjs?

steam3d commented 1 month ago

@maniacx It's an early version; we are discussing the API and structuring the backend. It will be used in MagicPodsDecky as an example of building a UI based on a Python backend.

https://github.com/steam3d/MagicPodsCore/issues/13

steam3d commented 1 month ago

It only works when my earbud is disconnected. @Toxblh

It's because when the headphones are connected, the system connects to the Hands-Free RFCOMM service. Classic Bluetooth allows only one active connection to a profile, so you need to disconnect Hands-Free if you want to get battery information from it. The microphone of the headphones will no longer work until the system reconnects to Hands-Free.

Toxblh commented 1 month ago

Do you have any idea about connecting to bluetooth socket in gjs?

We can write small dbus adapter and be possible have gjs. But will need a demon. Or integrate that to the bluez, and publish the data to dbus

vulpes2 commented 1 month ago

MagicPodsCore has been re-licensed to GPLv3 and it's currently being rewritten in Python. Once the project is in good shape, a daemon can be made that exposes a dbus interface to make it easy to access from GJS. BlueZ also provides the ability to register battery providers which might be worth looking into.

Sony and Samsung earbuds do not use the HFP RFCOMM channel for vendor app communication. Anything that requires HFP in-band communication will need to have the battery status support implemented in pipewire.