Android App disconnects from BLE

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

I am using CY8CKIT-042-BLE for android application development. My problem is the android app disconnects from BLE after 30 secs. I donot call BluetoothGatt.disconnect() anywhere in my code. I need to have a persistent connection throughout. Please help.@@@@@

0 Likes
1 Solution

Hello,

The event received seems very likely caused by the fact that the firmware did not treat some events. More likely the write you intend to do is not treated in the firmware and it causes the disconnect due to timeout. Unfortunately, I cannot figure out other reason in this moment. Get in touch with the firmware developer and ask about that characteristic you want to write. Again, this forum covers in general PSoC firmware questions and without knowing exactly what is happening in the firmware I personally do not have any more info.

Hope this helps.

View solution in original post

0 Likes
7 Replies
manusharian
Level 4
Level 4
25 replies posted 10 replies posted 10 questions asked

Hello,

I am not very sure what the problem may be but I can give you some hints from your description. I think the problem is on the PSoC firmware that you implemented. The 30 seconds is very likely to be a timeout cause by BLE connection from various reasons, the most common being: you try to write a characteristics, or a CCCD descriptor and the PSoC does not return a response. Again if you have some security enabled, such as a passkey, and you do not do the pairing properly this may result again in a timeout after 30s. Please be sure you treat the write events and pairing correctly on the PSoC firmware.

0 Likes
Anonymous
Not applicable

Thanks Marianemanuel, but I am not a firmware developer hence not aware about passkey. I write characteristics to firmware through Android App and also get the response. But when I try to write another characteristic to BLE I get "BLE DISCONNECTED EVENT: ERROR::0x13" and "idle state" error and disconnect happens automatically after around 30secs of pause.

0 Likes

Hello,

The event received seems very likely caused by the fact that the firmware did not treat some events. More likely the write you intend to do is not treated in the firmware and it causes the disconnect due to timeout. Unfortunately, I cannot figure out other reason in this moment. Get in touch with the firmware developer and ask about that characteristic you want to write. Again, this forum covers in general PSoC firmware questions and without knowing exactly what is happening in the firmware I personally do not have any more info.

Hope this helps.

0 Likes
Anonymous
Not applicable

If the device always disconnects instead of sending a second BLE response with the data for your read/write command, then it could be that the firmware handling the first read/write succeeds, but then crashes in code after handling it properly.

If the device only crashes on certain characteristics for read/write, then those specific characteristics aren't handled properly.

If the device only sometimes crashes on certain/random characteristics, then the firmware is mishandling an event, a timer, or some other (possibly unrelated) problem is occurring.

Without seeing the firmware for the project, or having more information, it would be mostly guesswork to figure out what is wrong.

0 Likes
Anonymous
Not applicable

Thanks Pratt and Marinemanuel,

I get error code 0x13 which means User terminated connection according to BluetoothGatt specification. Is it possible that the app disconnects due to Android supervision timeout?

0 Likes
Anonymous
Not applicable

See this related thread: Connection Terminated by Local Host (0x13) error - Bluetooth® low energy Forum - Bluetooth® low ener...

If there is a timeout for the android side telling it to disconnect when a command/request to the remote device fails, then the remote device is not replying to the command/request and the android application is timing out due to the Android supervision timeout.

THUS, in order to truly fix the issue, you would need the engineer who wrote the firmware code on the PSoC 4 to add more code for handling the events that are failing to respond to the android app. Or, change the android app to not use the commands/requests that fail.

An easy way to test this theory is to start with no commands/requests from the GATT database on connection with the PSoC 4, and then slowly add the commands/requests that you want to use in your android application one by one until you run into the same 30s disconnect window. Then you will know which commands/requests are failing and causing the timeout disconnection.

0 Likes
Anonymous
Not applicable

Thanks Pratt. I shall check this solution.

0 Likes