BLE Disconnects after Custom Characterisitic Write

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

cross mob
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

Device CYBL10563-56LQXI

   

Hello,

   

I am trying to create an application where the user can put the BLE device to sleep for certain hours.

   

I have created a service which has two characteristics; 1. Sleep time and 2. SleepNowFlag.

   

The user enters the duration for which it wants the BLE device to sleep, and they write on to the SleepNowFlag when they want to put the BLE  to sleep.

   

After I write the sleep time; the BLE becomes unresponsive and it disconnects after few seconds.

0 Likes
1 Solution
AnjanaM_61
Moderator
Moderator
Moderator
5 comments on KBA First comment on KBA 5 questions asked

For a write request from the client, you have to send a write response from the server side.

I didn't see the same in your project. May be that was causing the problem. Call CyBle_GattsWriteRsp(cyBle_connHandle); in the CYBLE_EVT_GATTS_WRITE_REQ event after getting a write request.

Also please call CyBle_ProcessEvents(); regardless of an condition check in the main for loop.

Please test with write response and let us know if it helps to solve the issue.

Thanks & Regards,

Anjana

View solution in original post

4 Replies
Anonymous
Not applicable

Your BLE write request handler code seems fine, except that you are calling the CyBle_ProcessEvents() from inside the event handler. This will cause the device to try to handle more events while it is mid-processing of the event. Try moving the CyBle_ProcessEvents() calls to only be called from the main() loop. Changing both of those function calls in the BLE event handler should fix the unit locking up when you write data to it.

   

Edit: Also, you should wait until the user disconnects from the unit before putting the BLE into the deep sleep, otherwise it will immediately disconnect from the BLE connection and you can't finish writing service data, or will fail to go to deep sleep and will keep running until disconnected anyways 😕

0 Likes
AnjanaM_61
Moderator
Moderator
Moderator
5 comments on KBA First comment on KBA 5 questions asked

For a write request from the client, you have to send a write response from the server side.

I didn't see the same in your project. May be that was causing the problem. Call CyBle_GattsWriteRsp(cyBle_connHandle); in the CYBLE_EVT_GATTS_WRITE_REQ event after getting a write request.

Also please call CyBle_ProcessEvents(); regardless of an condition check in the main for loop.

Please test with write response and let us know if it helps to solve the issue.

Thanks & Regards,

Anjana

jennyjohn3
Level 1
Level 1
First reply posted Welcome!

I am very sorry to hear that you are experiencing this problem. This is something that we have been experiencing as well. It sounds like a problem with your BLE chip. If you have any other questions, I would be happy to assist further.  I will have to go to this site in order to find the best writer for help in my essay.

0 Likes

Thanks a lot for help!

0 Likes