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

sd_xxx() sometimes returns NRF_ERROR_INVALID_STATE when connection and disconnection are repeated alternately and quickly.

Hi,

I'm using SDK13.0.0 and softdevice S132 v.4.0.2.

I sometimes get NRF_ERROR_INVALID_STATE from sd_xxx() in the function registered to ble_evt_dispatch() when connection and disconnection are repeated alternately and quickly. I suspect that sd_xxx() is called when the connection is actually disconnected, because calling sd_xxx() is in the ble interruption context, the program cannot know the connection is disconnected.

Is this possible? If possible, how can I avoid this problem?

As stated in this post, I'm using ble_app_ancs_c project, and I sometimes get NRF_ERROR_INVALID_STATE from sd_ble_gattc_primary_services_discover() in the ble_db_discovery_start() in pm_evt_handler(), then program gets hung.

I suspect the post is related to this post.

What do you think?

Best Regards,

Related