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

UART Streaming from central to peripheral

Hi,

I need to stream data from NUS UART Central Device to one peripheral, but the device always disconnects while trying to send second set of data. So I changed the write_req.params.gattc_write.write_op = BLE_GATT_OP_WRITE_CMD to BLE_GATT_OP_WRITE_REQ, and used "BLE_GATTC_EVT_WRITE_RSP" inside ble_nus_c_on_ble_evt(ble_evt_t const * p_ble_evt, void * p_context). After getting write response, the central sends next set of data.

But this also didn't work well, the nus_c_send_string() returns NRF_ERROR_INVALID_LENGTH.

I am using nRF52DK and nRF5_SDK_16.0.0_98a08e2\examples\ble_peripheral\ble_app_uart, and central device example, and sending 200 bytes of data at a time.

How can I continuously stream data from central to peripheral? (peripheral to central seems OK, where I used  BLE_NUS_EVT_TX_RDY to check peripheral ready to send next data set.

I changed back to BLE_GATT_OP_WRITE_CMD, this time the segger log shows (May not be resulted from nus_c_send_string call, because on this error the APP_ERROR_CHECK is not called)

nrf_ble_gq: SD GATT procedure (1) failed on connection handle 0 with error: 0x00000013.

In short the question is how I can safely send the next set of data or payload.

Parents
  • but the device always disconnects while trying to send second set of data. So I changed the write_req.params.gattc_write.write_op = BLE_GATT_OP_WRITE_CMD to BLE_GATT_OP_WRITE_REQ, and used "BLE_GATTC_EVT_WRITE_RSP" inside

     It would have been best to actually find out the reason for the disconnect and change the code so as to not to cause the disconnect.

    Why did you think that WRITE_REQ would be better than WRITE_CMD in this case? Just trying to understand the need for this change.

  • The disconnection was because the sender goes to the error loop (APP_ERROR_CHECK) while sending the next payload without ACK. I changed back to CMD as I described in the post, I was trying to get a confirmation before sending the next.

    Does the following help?

  • Sorry for the late response.

    from your log itself, it clearly says that

    procedure (1) NRF_BLE_GQ_REQ_GATTC_WRITE  failed due to 0x13 (NRF_ERROR_RESOURCES)

    I see, that is the reason you changed from using WRITE_REQ to WRITE_RSP. That makes sense

    using BLE_GATTC_EVT_WRITE_RSP looks correct, but why you got BLE_GATTC_EVT_WRITE_RSP is hard to tell without looking at your code.  Can you please post some code snippets.

Reply
  • Sorry for the late response.

    from your log itself, it clearly says that

    procedure (1) NRF_BLE_GQ_REQ_GATTC_WRITE  failed due to 0x13 (NRF_ERROR_RESOURCES)

    I see, that is the reason you changed from using WRITE_REQ to WRITE_RSP. That makes sense

    using BLE_GATTC_EVT_WRITE_RSP looks correct, but why you got BLE_GATTC_EVT_WRITE_RSP is hard to tell without looking at your code.  Can you please post some code snippets.

Children
Related