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

Long writes from S120; how to?

I have a peripheral running the S110 stack, which presents a characteristic to which I want the central (running S120) to be able to do a long write. What I've been trying goes something like this:

  1. Split up the data into < 18 byte chunks.
  2. Create a ble_gattc_write_params_t for each chunk, with:
    • write_op set to BLE_GATT_OP_PREP_WRITE_REQ
    • handle set to the characteristic handle
    • flags set to 0
    • offset, len, and p_value set according to the chunk
  3. Create a final ble_gattc_write _params_t, with:
    • write_op set to BLE_GATT_OP_EXEC_WRITE_REQ
    • handle set to the characteristic handle
    • flags set to BLE_GATT_EXEC_WRITE_FLAG_PREPARED_WRITE
    • offset and len set to 0
    • p_value set to an unused buffer
  4. Send each ble_gattc_write_params_t, in order, with sd_ble_gattc_write(). Wait for a BLE_GATTC_EVT_WRITE_RSP event before sending the next.

Based on what I've read, this should work, but I never get the WRITE_RSP event. sd_ble_gattc_write() returns NRF_SUCCESS for the first call (it isn't called again).

A working example would be a great help, but I'll settle for informed speculation if that's what you can offer!

Kind Regards, Michael

Related