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

Connection fails "operation in process" to a peripheral device without pairing #32

Open
MacTuitui opened this issue May 9, 2019 · 7 comments

Comments

@MacTuitui
Copy link

I don't know it that's the right issue, but my peripheral device accepts connections without pairing, and complains if you actually want to pair.

I can connect to the device using bluetoothctl and everything works as expected, but when I try to connect with the code from the example (where only the name has been changed), it does not work. It tries to connect (it blocks) then it panics with an "operation in process" error message.

What could be the next steps to debug the issue?

I'm thinking it might be related to pairing as I also tried to connect with blurz and it works with that crate when I just connect - without pairing - to the device. Looking at your code on connect it does not look like you are trying to pair though...

@lschuermann
Copy link

lschuermann commented Jun 8, 2019

I've got the same issue here. Using connect XX:XX:XX:XX:XX:XX with bluetoothctl works just fine, but using the connect() method after having found the device results in a long wait and ends in either the "EINPROGRESS: Operation in progress", or sometimes "ECONNREFUSED: Connection refused" errors.
Would love to help debug this further if the author(s) could show me in the right direction.

My device is a BS444 scale, like the one used in this project: https://github.com/keptenkurk/BS440/

@lschuermann
Copy link

On connect I'm getting the following rumble debug output:

[2019-06-08T19:18:17Z DEBUG rumble::bluez::adapter::peripheral] created socket 5 to communicate with device
[2019-06-08T19:18:17Z DEBUG rumble::bluez::adapter::peripheral] bound to socket 5
[2019-06-08T19:18:17Z DEBUG rumble::bluez::adapter::peripheral] configured socket 5
[2019-06-08T19:18:17Z DEBUG rumble::bluez::adapter] got message HCICommand { command: LESetScanParameters, data: [0, 96, 0, 48, 0, 0, 1] }
[2019-06-08T19:18:17Z DEBUG rumble::bluez::adapter] got message HCICommandComplete(LESetScanParameters)
[2019-06-08T19:18:17Z DEBUG rumble::bluez::adapter] got message LEScanEnableCommand { enable: true, filter_duplicates: true }
[2019-06-08T19:18:17Z DEBUG rumble::bluez::adapter] got message HCICommandComplete(LESetScanEnabled { enabled: false })
[2019-06-08T19:19:00Z DEBUG rumble::bluez::util] got error EINPROGRESS: Operation now in progress
[2019-06-08T19:19:00Z DEBUG rumble::bluez::adapter::peripheral] Failed to connect (EINPROGRESS: Operation now in progress), closing socket 5

I'm therefore guessing that this happens in the setup_connection method of bluez/adapter/peripheral.rs. The error seems to be coming from bluez itself, which I find very strange. However, I'm in no means a BLE expert and haven't used bluez before, so that's all info I can provide.

@cbiffle
Copy link

cbiffle commented Jun 19, 2019

I'm interested in using this crate, but this happens to me whenever I talk to any BLE device. As in, I have not yet successfully connected to anything, even using the example code. There seems to be a serious bug in the way it's managing BlueZ's connection state. (The error it's reporting is the one BlueZ produces when you make two simultaneous connection requests, for what it's worth.)

@SamuelWAnderson45
Copy link

Cannot connect to any device as well. Also experiencing permissions errors unless I run as root, not sure if anyone else has run into that?

@visceralfield
Copy link

Experiencing the exact same here, including having to run as root (I believe that is due to permissions on the bluetooth central adapter)

@visceralfield
Copy link

@SamuelWAnderson45 the permission error can be fixed temporarily by running 'sudo setcap 'cap_net_raw,cap_net_admin+eip' /path/to/your/compiled/binary

@SamuelWAnderson45
Copy link

@Josh-Thompson already tried that. Didn't make a difference.

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