My application code running on nrf51822 calls sd_ble_gatts_value_set to update a control characteristic. After 16 times receiving NRF_ERROR_BUSY status from this function, I would like to ensure that the control characteristic succeeds before I proceed with other tasks. So I loop like this:
v = sd_ble_gatts_hvx
if (v == NRF_ERROR_BUSY)
busycount++
if (busycount >= 16)
do
nrf_delay_ms(5)
v = sd_ble_gatts_hvx
while(v != NRF_SUCCESS)
But it never exits the loop. Is there a better way to handle this? How do I make sd_ble_gatts_hvx succeed again?