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

Is there a way to configure the connection interval, slave latency and supervisor timeout? (hcitool lecup) #117

Open
shailurie opened this issue Mar 21, 2016 · 12 comments

Comments

@shailurie
Copy link

No description provided.

@gonzob
Copy link

gonzob commented May 27, 2016

Hi. I'm not sure what the originator of this issue meant, but I'm trying to find a way of setting the above parameters from within BluePy.

I have successfully connected to a Yamaha BLE MIDI device (UDBT01) from a Raspberry Pi using BluePy. The UDBT01 is plugged in to my AKAI EWI-USB wind controller and it talks via Bluetooth to the synth running in my RPi. It works, but unless I re-configure the BLE connection parameters after the connection is made, the latency is terrible.

I run:
sudo hcitool lecup --handle $HANDLE --min 6 --max 7 --latency 0 --timeout 500
from within a bash shell ($HANDLE is the current connection handle), and the latency becomes acceptable.

So my question is: can the parameters be set in BluePy as part of the connection setup?

Ben

@cjntaylor
Copy link

Is there a way to get the connection handle integer from a peripheral, in the meantime? All you'd need is a way to get this identifier and you could run this using subprocess.Popen as a stopgap...

@IanHarvey
Copy link
Owner

The short answer is, I think, no. The connection handle (the thing you get out of the Connection Complete event) doesn't ever come out of the internals of the AF_BLUETOOTH socket, as far as I can tell.

@gonzob - you're getting the connection handle by looking at hcidump output, or something??

It's looking increasingly like I'm going to give up on BlueZ and write a whole stack just in Python, talking to a raw HCI socket.

@gonzob
Copy link

gonzob commented Feb 2, 2017

Hi Ian.
I use "hcitool con" to find the handle. I have it in a loop which checks every 5 secs that the last handle is still in place. If there's a new one (i.e. the connection failed and was re-started) it re-initialises the settings with hcitool as above.
My project site is here: http://projects.gonzos.net

Ben

@OrenLederman
Copy link

We had a similar issue in our project, and we ended up changing these files to control the connection intervals :

echo 16 > /sys/kernel/debug/bluetooth/hci0/conn_min_interval
echo 17 > /sys/kernel/debug/bluetooth/hci0/conn_max_interval

you only need to set the value once, which is easier than calling hcitool

(Credits go to Andrew Bartow)

@gonzob
Copy link

gonzob commented Feb 3, 2017

That looks great! However, on the two systems I have checked (ubuntu and raspbian) those files seem to be re-created each time the bluetooth connection comes up. Won't your values be overwritten?

Ben

@OrenLederman
Copy link

Actually, I never noticed that. My code sets these values every time anyway :)

@DingkunLiu
Copy link

According to my experience, the parameters set through such method would be reset when the computer restarts.

@yupeng-zglue
Copy link

echo 16 > /sys/kernel/debug/bluetooth/hci0/conn_min_interval
echo 17 > /sys/kernel/debug/bluetooth/hci0/conn_max_interval

My BLE master was sending a Connection Request with the correct interval values, after I had changed the above 2 files. However, it always accepts the Connection Parameters suggested by the slave.

Do you all know how to reject Connection Parameters Update Requests from the slave?

@pstanton
Copy link

i think i was observing the same as @yupeng-zglue so i worked out how to detect a new connection in python and then run the hcitool method from python. it's working well.

@yupeng-zglue
Copy link

yupeng-zglue commented Nov 30, 2017

@pstanton
"worked out how to detect a new connection"
By this do you mean detecting when the BLE slave tries to update the connection paramters?

@pstanton
Copy link

yes, specifically "PropertiesChanged" > "org.bluez.Device1" > "ServicesResolved"

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

8 participants