This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Toggle Notification Issues - NRF_ERROR_BUSY & Loss of Handles - Need Recommendations

Hi,

I wrote my codes to toggle notification on and off using a button using nRF25840-DK and sdk v15. The task looked a simple one; however, I hit some issues such as error 17 ( NRF_ERROR_BUSY) and the loss of handles. Attached screen capture showed the result after fixing the issues. I would like to share it and get comments from others to see if there is any smarter way to handle the issues. Remark: the battery levels were just adc measurements in mV without any voltage tied to the adc port and the values were insignificant to the issues.

In order to fix the busy issue, I had to retry enabling or disabling the notification at the coming write event according to other postings in DevZone. This issue could be easily solved when disabling notification. However, there was another big issue when I was enabling again after disabling notification because the event status stepped out of notification event and went to no where. After chopping my enabling operation into pieces in my program, I could enabling it again. I tried on my custom services first and implemented the same process in battery level notification. My custom service worked smoothly in re-enabling notification; however, I hit another issue of losing my handles in the battery re-enabling notification. The handles were re-initialized from zeros and could not be restored back to the previous ones. I solved this issue by saving the handles and restoring them when enabling the notification again. My custom service could re-stored the handles properly after they were re-initialized from zeros. The codes for cccd write in my custom service was different compared with the codes used in battery level notification.

I want to get comments from others below:

1. Did I do it right to handle the error busy issue by re-trying at write event?

2. Why was there no loss of handles in my custom service but battery notification had the loss during re-enabling notification? Is there any best way to restore the handles after they are lost?

Related