2 Replies Latest reply on Aug 18, 2017 5:35 AM by AnjanaM_61

    BLE Disconnects after Custom Characterisitic Write


      Device CYBL10563-56LQXI




      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.

        • 1. Re: BLE Disconnects after Custom Characterisitic Write

          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 :/

          • 2. Re: BLE Disconnects after Custom Characterisitic Write

            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,


            1 of 1 people found this helpful