Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
poopman97 opened this issue Jun 12, 2022 · 6 comments
Open

Comments

@poopman97
Copy link

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!

@TheWeirdDev
Copy link
Owner

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

@ishmeet1995
Copy link

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?

@Kr3shnik
Copy link

Kr3shnik commented Sep 1, 2022

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

@AkechiShiro
Copy link

@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
Copy link

AkechiShiro commented Sep 30, 2023

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
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants