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 :/
1 of 1 people found this helpful
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,