1)Are you using low power modes in the code?
2)Please let us know how you are detecting the disconnection, if the stack event is not generating?
3)Have you made sure that the CyBle_ProcessEvents() once in every connection interval?
Hima, thank you very much for your answer.
1. Yes, I am using low power modes in the code. This could be related with the disconnections because when I remove the LowPowerImplementation (similar function to the Cypress examples which includes the CySysPmDeepSleep function) and put the device only in CySysPmSleep mode, then the disconnections are reduced dramatically... but there are still some.
2. The disconnections are detected using the CySmart tool and the dongle. I enable notifications and the device is working good. It sends correct data to the CySmart. After a while, could be a few minutes, it disconnects. If I do not enable the notifications, I do not notice disconnections.
3. I am sure that the CyBle_ProcessEvents() is called in every connection interval, unless I miss something. Main loop lasts 1ms. In the first 200-300us of this period, the processor executes processing. In the next 700-800us, the processor sleeps. The connection interval is min=30ms, max=40ms. The processor wakes up every 1ms, executes CyBle_ProcessEvents(), applies processing and then gets back to sleep. The CyBle_ProcessEvents() is called at least once per 1ms.
It seems that this error is an internal stack error or I cause with my code this error, I do not know.
Since disconnection event is not propagated, I have no knowledge of the status and I continue to send notifications. The CYBLE_API_RESULT_T return value of the CyBle_GattsNotification() function is CYBLE_ERROR_MEMORY_ALLOCATION_FAILED.
The above apiResult is also noticed sometimes before disconnection happens. But rarely. When disconnection happens it is returned continuously, which is reasonable since connection is dead.
I will try to reduce the transmission load, hoping to resolve the issue. Any other workaround?
Thank you in advance.