iOS is using queued writes to send data to my nRF52832 application. For some reason, on the third queued write reply (in nrf_ble_qwr.c) sd_ble_gatts_rw_authorize_reply returns NRF_ERROR_INVALID_STATE.
I modified nrf_ble_qwr.c to log every time it calls sd_ble_gatts_rw_authorize_reply anywhere. I am sure that my code is not calling it, as I also log everywhere I call it too. The log output looks like this:
Fullscreen
1
2
3
4
5
6
7
8
9
10
<debug> nrf_sdh_ble: BLE event: 0x1.
<debug> nrf_sdh_ble: BLE event: 0x51.
<info> app: prepare reply
<debug> nrf_sdh_ble: BLE event: 0x51.
<info> app: prepare reply
<debug> nrf_sdh_ble: BLE event: 0x51.
<info> app: prepare reply
<error> KFPAL: ERROR 8 [NRF_ERROR_INVALID_STATE] at ...KFPAL_Nordic_bluetooth.c:446
PC at: 0x000268F1
<error> KFPAL: End of error report
this occurs in the sd_ble_gatts_rw_authorize_reply call in on_prepare_write in nrf_ble_qwr.c. Unless sd_ble_gatts_rw_authorize_reply is being called by another nrf library, it is only being called from nrf_ble_qwr.c. I'm really struggling to understand why INVALID_STATE is being returned.