rumble icon indicating copy to clipboard operation
rumble copied to clipboard

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

Open MacTuitui opened this issue 5 years ago • 7 comments

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...

MacTuitui avatar May 09 '19 01:05 MacTuitui

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 avatar Jun 08 '19 19:06 lschuermann

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.

lschuermann avatar Jun 08 '19 19:06 lschuermann

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.)

cbiffle avatar Jun 19 '19 15:06 cbiffle

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?

SamuelWAnderson45 avatar Jun 20 '19 23:06 SamuelWAnderson45

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

visceralfield avatar Jun 24 '19 21:06 visceralfield

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

visceralfield avatar Jun 25 '19 13:06 visceralfield

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

SamuelWAnderson45 avatar Jun 25 '19 18:06 SamuelWAnderson45