TheWeirdDev / Bluetooth_Headset_Battery_Level

A python script to get battery level from Bluetooth headsets
GNU General Public License v3.0
759 stars 80 forks source link

Connection refused for BLE_ATH-M50xBT #47

Open Vrizkag opened 3 years ago

Vrizkag commented 3 years ago

bluetooth_battery 00:0A:45:0B:5C:5C 00:0A:45:0B:5C:5C is offline [Errno 111] Connection refused

Then i tried this:

bluetooth_battery 00:0A:45:0B:5C:5C.1 00:0A:45:0B:5C:5C is offline [Errno 16] Device or resource busy

Before that, I went into bluetoothctl to get the correct address

[BLE_ATH-M50xBT]# info
Device 00:0A:45:0B:5C:5C (public)
    Name: BLE_ATH-M50xBT
    Alias: BLE_ATH-M50xBT
    Class: 0x00240418
    Icon: audio-card
    Paired: yes
    Trusted: yes
    Blocked: no
    Connected: yes
    LegacyPairing: no
TheWeirdDev commented 3 years ago

I'm not sure what's the reason. Disconnect your device first, then run the script again while disconnected. This works for some devices.

cheriimoya commented 3 years ago

did you try to rerun the script @Vrizkag? like in executing the same command twice? i.e.

$ bluetooth_battery 00:0A:45:XX:XX:XX
00:0A:45:XX:XX:XX is offline [Errno 111] Connection refused

$ bluetooth_battery 00:0A:45:XX:XX:XX
Battery level for 00:0A:45:XX:XX:XX is 80%
isalgueiro commented 3 years ago

Got the same problem using different device, let me know if you rather have a separate issue for this 876964 headset.

( 876964 is this headset model name :shrug: )

[876964]# info E9:08:EF:93:XX:XX
Device E9:08:EF:93:XX:XX (public)
        Name: 876964
        Alias: 876964
        Class: 0x00240404
        Icon: audio-card
        Paired: yes
        Trusted: yes
        Blocked: no
        Connected: yes
        LegacyPairing: no
        UUID: Headset                   (00001108-0000-1000-8000-00805f9b34fb)
        UUID: Audio Sink                (0000110b-0000-1000-8000-00805f9b34fb)
        UUID: A/V Remote Control Target (0000110c-0000-1000-8000-00805f9b34fb)
        UUID: A/V Remote Control        (0000110e-0000-1000-8000-00805f9b34fb)
        UUID: Handsfree                 (0000111e-0000-1000-8000-00805f9b34fb)

With the headset connected (script exits in less than 1s, it returns this error every time I run it):

╰─ bluetooth_battery E9:08:EF:93:XX:XX
E9:08:EF:93:XX:XX is offline [Errno 111] Connection refused

With the headset disconnected

╰─ bluetooth_battery E9:08:EF:93:XX:XX
Couldn't find the RFCOMM port number
E9:08:EF:93:XX:XX is offline [Errno 112] Host is down
oesst commented 3 years ago

+1 Same error with a Bose quietcomfort 35.

The command journalctl -f -o cat /usr/bin/gnome-shell prints out:

Bluetooth battery indicator: 28:11:XXXXXX is offline (16, 'Device or resource busy') Bluetooth` battery indicator: 28:11:XXXXXXis offline (111, 'Connection refused')

eqaderi commented 3 years ago

I have the same issue with my headset, I'm on Ubuntu 20.04.2

pipapu commented 2 years ago

I have the same issue on Ubuntu (5.4.0-89-generic #100-Ubuntu SMP) with a Bowers & Wilkins headphone. Battery level is reported correctly after a reboot, but after the first suspend I get the same behaviour ("Errno 111") as described above.

Oh, and I found these lines repeated over and over in /var/log/syslog: Oct 12 20:37:01 XXX gnome-shell[6989]: Usage of object.actor is deprecated for Indicator#012get@resource:///org/gnome/shell/ui/environment.js:287:29#012_refresh@/home/axel/.local/share/gnome-shell/extensions/bluetooth-battery@michalw.github.com/extension.js:80:13#012_runLoop@/home/pipapu/.local/share/gnome-shell/extensions/bluetooth-battery@michalw.github.com/extension.js:47:14 Oct 12 20:37:02 XXX gnome-shell[6989]: Bluetooth battery indicator: Battery level for B0:67:2F:1B:A9:6D is 100%

So, actually the battery level is correctly reported by the device. Perhaps the deprecate warning is not correctly interpreted by bluetooth_battery?

talhajunaidd commented 2 years ago

I can confirm that after a restart, battery status is reported correctly