Bluetooth_Headset_Battery_Level icon indicating copy to clipboard operation
Bluetooth_Headset_Battery_Level copied to clipboard

Problem with Device is Offline error

Open mhkarimi1383 opened this issue 4 years ago • 13 comments

When I want to get my headphone battery I Get this error <Device MAC> is offline [Errno 16] Device or resource busy

And please update gnome extension for gnome 40

mhkarimi1383 avatar Apr 25 '21 04:04 mhkarimi1383

When I want to get my headphone battery I Get this error <Device MAC> is offline [Errno 16] Device or resource busy

And please update gnome extension for gnome 40

Does it work on the older gnome desktop, like 3.38. I faced the same error.

rds8rds avatar Jun 12 '21 20:06 rds8rds

Used to work for me as well, now I get this.

$ bluetoothctl info
Device E8:AB:FA:27:9F:49 (public)
	Name: iTeknic IK-BH002
	Alias: Black Noise-Cancelling (iTeknic IK-BH002)
	Class: 0x00240418
	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: Advanced Audio Distribu.. (0000110d-0000-1000-8000-00805f9b34fb)
	UUID: A/V Remote Control        (0000110e-0000-1000-8000-00805f9b34fb)
	UUID: Handsfree                 (0000111e-0000-1000-8000-00805f9b34fb)
	UUID: PnP Information           (00001200-0000-1000-8000-00805f9b34fb)
	Modalias: bluetooth:v000ApFFFFdFFFF

$ ~/src/git/Bluetooth_Headset_Battery_Level/bluetooth_battery.py E8:AB:FA:27:9F:49
E8:AB:FA:27:9F:49 is offline [Errno 111] Connection refused

barak avatar Jun 15 '21 10:06 barak

I think it's not compatible with some devices mine is Anker Sound buds lite

mhkarimi1383 avatar Jun 16 '21 11:06 mhkarimi1383

Used to work for me as well, now I get this.

$ bluetoothctl info
Device E8:AB:FA:27:9F:49 (public)
	Name: iTeknic IK-BH002
	Alias: Black Noise-Cancelling (iTeknic IK-BH002)
	Class: 0x00240418
	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: Advanced Audio Distribu.. (0000110d-0000-1000-8000-00805f9b34fb)
	UUID: A/V Remote Control        (0000110e-0000-1000-8000-00805f9b34fb)
	UUID: Handsfree                 (0000111e-0000-1000-8000-00805f9b34fb)
	UUID: PnP Information           (00001200-0000-1000-8000-00805f9b34fb)
	Modalias: bluetooth:v000ApFFFFdFFFF

$ ~/src/git/Bluetooth_Headset_Battery_Level/bluetooth_battery.py E8:AB:FA:27:9F:49
E8:AB:FA:27:9F:49 is offline [Errno 111] Connection refused

same here

mhkarimi1383 avatar Jun 16 '21 11:06 mhkarimi1383

Hi, try connecting to a different port. For example bluetooth_battery.py E8:AB:FA:27:9F:49.1 Try manually changing the numbers from 1 to 30 after period (.)

Kronodile avatar Jun 21 '21 10:06 Kronodile

@Kronodile That didn't help for me, but bluetoothctl disconnect E8:AB:FA:27:9F:49 followed by bluetooth_battery.py E8:AB:FA:27:9F:49 both got the battery level and reconnected it. And then it worked, and battery queries also worked.

barak avatar Jun 21 '21 14:06 barak

@Kronodile That didn't help for me, but bluetoothctl disconnect E8:AB:FA:27:9F:49 followed by bluetooth_battery.py E8:AB:FA:27:9F:49 both got the battery level and reconnected it. And then it worked, and battery queries also worked.

i also have this issue

jrvgr avatar Jul 29 '21 00:07 jrvgr

@Kronodile That didn't help for me, but bluetoothctl disconnect E8:AB:FA:27:9F:49 followed by bluetooth_battery.py E8:AB:FA:27:9F:49 both got the battery level and reconnected it. And then it worked, and battery queries also worked.

i also have this issue

same here, but the battery queries did not work afterwards

dark-dryu avatar Sep 13 '21 10:09 dark-dryu

@Kronodile That didn't help for me, but bluetoothctl disconnect E8:AB:FA:27:9F:49 followed by bluetooth_battery.py E8:AB:FA:27:9F:49 both got the battery level and reconnected it. And then it worked, and battery queries also worked.

This is what worked for me

lakinduakash avatar Sep 14 '21 23:09 lakinduakash

@Kronodile That didn't help for me, but bluetoothctl disconnect E8:AB:FA:27:9F:49 followed by bluetooth_battery.py E8:AB:FA:27:9F:49 both got the battery level and reconnected it. And then it worked, and battery queries also worked.

i also have this issue

This worked for me too

VanillaBase1lb avatar Oct 12 '21 05:10 VanillaBase1lb

I am observing the same problem after upgrading to Ubuntu 21.10. To be clear, the Gnome extension that uses this script — and, therefore, presumably, the script itself — used to work just fine with Ubuntu 21.04 up until I upgraded to Ubuntu 21.10.

Now, if I connect my Bluetooth headphones and run the script, it gives the following error:

[REDACTED] is offline [Errno 16] Device or resource busy

If I try manually specifying ports from 1 to 30, it gives the same error with port 4, and with any other port is gives the following error:

[REDACTED] is offline [Errno 111] Connection refused

If I disconnect the headphones and run the script, then it suddenly works! But, unlike reported by others above, this does not fix the issue for me. If I run the script while the headphones are disconnected, it successfully returns a charge level, and the headphones say, “Bluetooth disconnected,” and remain disconnected. It seems that the script briefly connects to the headphones, requests the charge level, and then disconnects. If I then reconnect the headphones, the script still gives the same error while the headphones are connected.

Interestingly, this problem appears to be somewhat intermittent: while testing again in order to write this comment, for a brief moment the script actually managed to work correctly and report the battery charge level while the headphones were connected! I wasn’t able to reproduce this, though; the scenario I described above is still the only thing that happens reliably.

VoidPhantom avatar Oct 18 '21 18:10 VoidPhantom

I also faced the problem, for some devices (my headphone atleast), it fails to establish a connection, I wrote this script to do the same, just disconnect for a moment, check battery, then connect back again (if you don't want to, edit it to add some, say a flag):

#!/usr/bin/python
import re
import sys
import os
from bluetooth_battery.bluetooth_battery import main
if __name__ == '__main__':
    os.system("bluetoothctl disconnect "+ sys.argv[1])
    sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
    main()
    os.system("bluetoothctl connect "+ sys.argv[1])

And save it as 'bluetooth_battery' in ~/.local/bin... done :D

adi-g15 avatar Oct 28 '21 07:10 adi-g15

Exactly the same issue.

image

The thing is you dont wanna disconnect from the headphones as you are listening to a music.

im-n1 avatar Nov 04 '21 15:11 im-n1