2

i would appreciate if someone can explain one issue i'm experiencing with Raspberry Pi 3 model B acting as a Central device on a BLE connection with a Peripheral device.

First, i successsfully connect both devices and enable notifications on the Central device using the folllowing hcitool/gatttool commands:

sudo hciconfig hci0 up
sudo gatttool --adapter=hci0 --device=XX:XX:XX:XX:XX:XX --adr_type=random --mtu=23 -I
[][LE]> connect
[][LE]> char-write-req 0x000c 0100

After that, i started receiving notifications on the Raspberry Pi3 model B, and using a BLE sniffer, i check that it receives 5 BLE packets with notified values per connection interval (that is OK), which is established by default to 54 (67,5ms). However, once both devices are connected, i update the connection parameters in order to modify the connection interval to, i.e. 24 (30ms) using the following hcitool command:

sudo hcitool lecup --handle=XX --min=24 --max=24

And the issue i found is that, once the connection parameters are updated, i checked that the Raspberry Pi3 model B starts receiving just 1 BLE packet per connection interval (That is not OK). The same behavioral is observed updating the conection parameters to higher values of connection interval, i.e. 800 (1s).

Could anyone give me an explanation of that issue? In addition, could anyone try to reproduce this procedure and check if the same issue is observed?

Thanks

1 Answers1

1

hcitool lecup uses hci_le_conn_update (http://elixir.free-electrons.com/linux/latest/source/net/bluetooth/hci_conn.c#L321) which sets the min_ce_len and max_ce_len to 0, which means it hints to the controller that the connection event length should be 0*0.625 ms. You don't want that. You want it to be as long as your connection interval if you would like to keep sending packets during the entire interval.

To test to set the CE length, use a raw command instead:

sudo hcitool cmd 0x08 0x13   0x40 0x00   0x18 0  0x18 0   0 0   0x60 0   0x30 0  0x30 0

This issues a connection parameter update request for handle 0x0040, with connection interval min/max=24*1.25 ms, slave latency=0, timeout=960ms, CE interval min/max=48*0.625 ms.

Emil
  • 16,784
  • 2
  • 41
  • 52
  • Hi @Emil, thanks a lot for your answer ... so where the default max and min values for the connection event length are set? ... it seems clear that these parameters are not initially set to 0 ... Thaaanks! – Mirada Veintitres Oct 24 '17 at 09:59
  • Hi. Did it work better with my command? If you see my referenced file, you see they are set to zero at cp.min_ce_len = cpu_to_le16(0x0000); cp.max_ce_len = cpu_to_le16(0x0000); – Emil Oct 24 '17 at 11:11
  • Hi @Emil, YES, it worked ok!. sorry not to comment it. i saw on the hci.c file from Bluez 5.47 (the distribution i am running on my RPi 3 model B to support BLE) that the hci_le_conn_update function sets the min_ce_len and max_ce_len values to 1. however, from the initial behavioral from the reported experiment, in which i received 5 packets per connection interval (set to 67,5ms) it seems obvious that the connection event max/min lenght are not initially set to those values. so where the default max and min values for the connection event are set?. Thanks – Mirada Veintitres Oct 24 '17 at 11:26
  • Now I get what you mean. The initial values of min/max ce len are set when the connection is created (hci_req_add_le_create_conn). – Emil Oct 24 '17 at 12:39
  • Hi @Emil. Thanks. just one final comment ... so in case i set the connection event length value to the same as the connection interval, and it is as high as, i.e. 67,5ms, which additional parameters would limit the max number of packets transferred per connection event length?. Thanks a lot for your helpful support. – Mirada Veintitres Oct 24 '17 at 20:32
  • If there is nothing stopping the two controllers then they should send packets back and forth during the whole connection event as long as there is data to send. If any controller has multiple active connections or scanning is active then it will probably end the connection event earlier to handle those overlapping events. If it's a wifi/bluetooth combo chip it might also stop earlier to do wifi stuff. – Emil Oct 24 '17 at 23:35
  • @Emil how can we set Min/Max CE length before a connection is established? I used to set Min/Max connection interval from a linux terminal using "echo 6 | sudo dd of=/sys/kernel/debug/bluetooth/hci0/conn_min_interval" and is used in the establishment of the connection. Is there something like that for CE length? – Mohamed Yacout Jan 16 '20 at 12:52