IanHarvey / bluepy

Python interface to Bluetooth LE on Linux
Other
1.58k stars 490 forks source link

HCI Selection Failure #501

Open kg-meso opened 1 year ago

kg-meso commented 1 year ago

Hello, I have been really enjoying bluepy however I have came across an issue that is stopping me in my development. When setting the iface value to a string '0' or '1' in Peripheral() it fails to actually select one or the other and just defaults to hci0.

I have went into the btle.py file and added a print statement in _connect() to output 'hci'+str(iface) and it does correctly receive either a 0 or a 1. The reason I can tell which interface is being used is because I have hcidump open for both devices and can only see one every actually receiving hci commands no matter the value for iface.

Some things to note:

I would love to keep using bluepy but I need to get this issue fixed moving forward, I am happy to also work on a pull request to fix this once I get some help sorting out the actual issue! Thanks.

Here is some sample code from my project:

def initiate_peripheral(addr,type,hci): p = Peripheral() p.connect(addr,type,str(hci)) p.withDelegate(MyDelegate(p)) p.setMTU(251) return p

p = initiate_peripheral(args['macid'],'random',args['hci_id'])

kg-meso commented 1 year ago

A further note, using bluepy-helper and calling it with a 0 or a 1 at the end like so,

In this case, connecting with conn adding an hciX on the end still does not work. However, I can actually call scan and it will change which hci device being used depending on how I called ./bluepy-helper.