- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
We are trying to solve a problem with the BLE system randomly failing while the device is connected to a peripheral and sending data. Upon failure Cy_BLE_GATT_GetBusyStatus() returns CY_BLE_STACK_STATE_BUSY indefinitely. We have tried to reset the BLE system but it does not advertise or scan after the reset.
Solutions tested:
- Soft-resetting the BLE stack
- Called Cy_BLE_StackSoftReset(), the function returns CY_BLE_SUCCESS
- Checked the state of the stack by calling Cy_BLE_GetState(), the result was CY_BLE_STATE_ON
- The BLE did not behave as normal as it was not advertising or connecting to any other devices
- Hard resetting BLE system
- Called Cy_BLE_Stop() on CM4 with results being CY_BLE_SUCCESS
- Called Cy_BLE_Start() on CM0+ with results being CY_BLE_SUCCESS
- Called Cy_BLE_Start() on CM4 with results being CY_BLE_SUCCESS
- Checked the state of the stack by calling Cy_BLE_GetState(), the result was CY_BLE_STATE_INITIALIZING
- The BLE did not behave as normal as it was not advertising or connecting to any other devices
Note: Resetting BLE was tested independently of the busy stack issue by manually triggering the soft and hard resets.
Any clues as to why the stack is busy in the first place or why the resetting process is not working would be appreciated.
Solved! Go to Solution.
- Tags:
- ble
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @PratikshaV,
I tried running the code example on the evaluation kit and saw the same behaviour as in my project. The soft reset works but the device does not start advertising after the reset. It seems to be returning the invalid state error when Cy_BLE_GAPP_StartAdvertisement() is called after the reset.
From what I can tell, the soft reset API doesn't completely reset all BLE states as Cy_BLE_GAPP_StopAdvertisement() needs to be called before the reset to allow the device to start advertising afterwards.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @DaCh_1995281 ,
Please can you give us more information about how you are sending the data, at what point you are receiving the CY_BLE_STACK_STATE_BUSY or code snippet or if possible please attach your project so that we can understand the issue better.
Thanks & Regards
Pratiksha V
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Patrishka.
I am currently working with @DaCh_1995281 on the same project and debugging this specific issue. I was hoping to hotfix this issue by resetting the BLE stack rather than digging for the source of CY_BLE_STACK_STATE_BUSY. Is there any insights you can give me on why resetting the BLE stack is not working, independent of the busy-stack problem?
Edit: I have attached a screenshot of the function that is sending the data, which is where we ran into the busy stack issue.
Thank you,
Sepehr Z
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @DaCh_1995281 ,
Please can you add this below piece of code in your event handler and check if the issue resolves.
case CY_BLE_EVT_SOFT_RESET_COMPLETE:
(void)memset(&cy_ble_connState, 0, sizeof(cy_ble_connState));
break;
Thanks & Regards
Pratiksha V
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @PratikshaV,
I tried adding that piece of code but it didn't work. The device still isn't scanning or advertising after the BLE stack is soft reset.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @DaCh_1995281 ,
Please can you check the attached code example where I am triggering the soft reset using button switch.
Thanks & Regards,
Pratiksha V
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @PratikshaV,
I tried running the code example on the evaluation kit and saw the same behaviour as in my project. The soft reset works but the device does not start advertising after the reset. It seems to be returning the invalid state error when Cy_BLE_GAPP_StartAdvertisement() is called after the reset.
From what I can tell, the soft reset API doesn't completely reset all BLE states as Cy_BLE_GAPP_StopAdvertisement() needs to be called before the reset to allow the device to start advertising afterwards.