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.

Reply
  • 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.

Children
Related