Sometimes when I call sd_ble_gatts_hvx, it can take several ms to return. Most of the time it takes very little time (<1ms), but occassionally it takes up to 34ms, my connection interval is 15ms, I'm not sure if related. I time the call by taking a timer count with app_timer_cnt_get before and after the call and then logging the difference converted to ms. It is my understanding that sd_ble_gatts_hvx should simply add a notification to a queue and return, not wait for space etc. Are there any reasons why sd_ble_gatts_hvx should take so long? I'm using nRF SDK 17.0.2 with S132 7.2.0 on nRF52832.
The call is being made from the main loop (app scheduler). I did wonder if softdevice interrupts were occurring during processing. Sometimes I do get BLE_GATTS_HVN_TX_COMPLETE events during the call, but not always, and the delays only occur in sd_ble_gatts_hvx, not other function calls.