Bluetooth_Headset_Battery_Level icon indicating copy to clipboard operation
Bluetooth_Headset_Battery_Level copied to clipboard

Couldn't find the RFCOMM port number. Perhaps the device is offline?

Open poopman97 opened this issue 3 years ago • 6 comments

When I do the command I get this error

bluetooth_battery 43:00:00:00:00:68  1 ✘  5s  Traceback (most recent call last): File "/usr/local/bin/bluetooth_battery", line 33, in <module> sys.exit(load_entry_point('bluetooth-battery==1.3.2', 'console_scripts', 'bluetooth_battery')()) File "/usr/lib/python3.10/site-packages/bluetooth_battery/bluetooth_battery.py", line 162, in main query = BatteryStateQuerier(*device.split(".")) File "/usr/lib/python3.10/site-packages/bluetooth_battery/bluetooth_battery.py", line 81, in __init__ self._bt_settings = bluetooth_mac, int(bluetooth_port or RFCOMMSocket.find_rfcomm_port(bluetooth_mac)) File "/usr/lib/python3.10/site-packages/bluetooth_battery/bluetooth_battery.py", line 60, in find_rfcomm_port raise bluetooth.BluetoothError("Couldn't find the RFCOMM port number. Perhaps the device is offline?") bluetooth.btcommon.BluetoothError: Couldn't find the RFCOMM port number. Perhaps the device is offline?

Tbh I don't know what to say more, hope this can get fixed!

poopman97 avatar Jun 12 '22 18:06 poopman97

What Bluetooth device do you have? Did you try the workarounds mentioned in the readme?

TheWeirdDev avatar Jun 13 '22 05:06 TheWeirdDev

Getting same error, @TheWeirdDev I am using Bluetooth Headset

Command - bluetooth_battery B4:0E:DE:95:7C:9C

Response - Traceback (most recent call last): File "/home/ishmeet1995/anaconda3/bin/bluetooth_battery", line 8, in <module> sys.exit(main()) File "/home/ishmeet1995/anaconda3/lib/python3.9/site-packages/bluetooth_battery/bluetooth_battery.py", line 162, in main query = BatteryStateQuerier(*device.split(".")) File "/home/ishmeet1995/anaconda3/lib/python3.9/site-packages/bluetooth_battery/bluetooth_battery.py", line 81, in __init__ self._bt_settings = bluetooth_mac, int(bluetooth_port or RFCOMMSocket.find_rfcomm_port(bluetooth_mac)) File "/home/ishmeet1995/anaconda3/lib/python3.9/site-packages/bluetooth_battery/bluetooth_battery.py", line 60, in find_rfcomm_port raise bluetooth.BluetoothError("Couldn't find the RFCOMM port number. Perhaps the device is offline?") bluetooth.btcommon.BluetoothError: Couldn't find the RFCOMM port number. Perhaps the device is offline?

ishmeet1995 avatar Jul 03 '22 12:07 ishmeet1995

it also happened to me. Im not entierly sure if this repo supports HCI bluetooth devices (another connection method similar to rfcomm). To check you can run hcitool dev. Note that this command doesnt always work.

You can also use udevadm monitor and during this command dissconnect and reconnect the device.

In my case it was: /devices/pci0000:00/0000:00:14.0/usb1/1-7/1-7:1.0/bluetooth/hci0/hci0:256

Kr3shnik avatar Sep 01 '22 20:09 Kr3shnik

@TheWeirdDev I'm running on this issue using a bluetooth keyboard Keychron K7, can you please help me, understand what I can do to fix either the script or find the out the battery level ?

AkechiShiro avatar Sep 30 '23 23:09 AkechiShiro

Here is what I found out by using hcitool :

Requesting information ...
	BD Address:  DC:2C:26:3A:64:00
	OUI Company: Iton Technology Limited (DC-2C-26)
	Device Name: Keychron K7
	LMP Version: 5.1 (0xa) LMP Subversion: 0x2304
	Manufacturer: Cypress Semiconductor (305)
	Features page 0: 0xbf 0x06 0x86 0x78 0x18 0x1e 0x59 0x87
		<3-slot packets> <5-slot packets> <encryption> <slot offset> 
		<timing accuracy> <role switch> <sniff mode> <RSSI> 
		<channel quality> <paging scheme> <power control> 
		<broadcast encrypt> <enhanced iscan> <interlaced iscan> 
		<interlaced pscan> <inquiry with RSSI> <AFH cap. perip.> 
		<AFH cls. perip.> <sniff subrating> <pause encryption> 
		<AFH cap. central> <AFH cls. central> <extended inquiry> 
		<simple pairing> <encapsulated PDU> <non-flush flag> <LSTO> 
		<inquiry TX power> <EPC> <extended features> 
	Features page 1: 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00
  • Inquiry TX power, I don't think that's what I need, it's probably the power needed to send a bluetooth packet or something like that ??
  • power control must mean that there could be a way to control the bluetooth device power from the host, I guess

AkechiShiro avatar Sep 30 '23 23:09 AkechiShiro

Okay so I confirmed the battery level can be reported : image

AkechiShiro avatar Sep 30 '23 23:09 AkechiShiro