Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Please update "Queued Writes" landing page - nrf_ble_qwr_conn_handle_assign

I lost several hours trying to figure out why my implementation of Queued Writes wasn't responding to write requests.  Finally resorted to a line-by-line compare with the Experimental Queued Writes example and found what I was missing:

In main.c, the ble_evt_handler for case: BLE_GAP_EVT_CONNECTED needs to call nrf_ble_qwr_conn_handle_assign(&m_qwr, m_conn_handle).  Otherwise, the BLE events don't know that they should be redirected to the Queued Writes module.  My updated code is below for reference.

Please update the SDK documentation landing page for Queued Writes to include something like:

"Finally, update your ble_evt_handler for event BLE_GAP_EVT_CONNECTED to call nrf_ble_qwr_conn_handle_assign. "

        case BLE_GAP_EVT_CONNECTED:
            NRF_LOG_INFO("Connected.");
            err_code = bsp_indication_set(BSP_INDICATE_CONNECTED);
            APP_ERROR_CHECK(err_code);
            m_conn_handle = p_ble_evt->evt.gap_evt.conn_handle;
            err_code = nrf_ble_qwr_conn_handle_assign(&m_qwr, m_conn_handle); // This is important!
            break;

Related