Android Bluetooth Low Energy connection timeout while BLE chip is computing

7.3k Views Asked by At

My BLE application requires computation on the server side (BLE chip) which takes time and results with disconnection.

Th flow is like this:

1- Android phone writes the characteristic value to the BLE chip. 2- The chip evaluates this value and starts computation. 3- The connection is lost soon after the computation has started.

What solution can I apply to prevent the disconnecton? I have two solutions in my mind:

1- Changing the connection interval: Currently Android uses 7.5 msec as connection interval. Since the computation on BLE chip takes time, packets are not sent or received during the computation. Increasing the connection interval will decrease the number of lost packets. However there is no guarantee that Android phone will accept the new connection parameters.

2- Running the computation in a separate thread: I dont think that BLE chips' SDK support multi-threading such that while there is a computation process going on, it will keep receiving and sending packets and prevent the disconnection. I use CSR chip and I think it doesnt support.

Please correct me if I am wrong at my points.

Do you have any other suggestions to solve the issue?

Thanks in advance.

2

There are 2 best solutions below

0
On

I don't know exactly if what i going to explain it's feasible under Android because I used BLE only with a low level applications, anyway if your problems are the connection parameters you can try to change the Slave_Latency.

It should be usefull since playing with this parameter, you can change the number of connection intervals in which the Central device can wait until it considers the connection lost.

The following equation is usefull to derive the connection parameters: Effective_Connection_Interval = (Connection_Interval)*(1+(Slave_Latency))

Remember that can exists some kind of Supervision_Timeout that can collide with your Effective_Connection_Interval

0
On

Thank you for the answers. I found out what the problem is after spending hours.

First of all, when Android gives error 133 or 129, it is most probably because of the remote device.

At the beginning I thought that the problem occurred because of the supervision timeout. Then I re-configured the connection parameters of the CSR chip but it didn't help.

There is a problem about CSR app development with xIDE (IDE of CSR). When there is run-time-error due to index overshoot or accessing some invalid pointers, then you would not receive any errors in xIDE. I finally found out the array problem and fixed it. Now it works perfect.

Thanks a lot!