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

Writing a long characteristic

Hi,

I'm having trouble writing a long characteristic. I'm using the pc-ble-windows code from https://github.com/NordicSemiconductor/pc-ble-driver. I've compiled this and the necessary Boost libraries for 32-bit Windows.

I tried sd_ble_gattc_write() using BLE_GATT_OP_WRITE_REQ for write with acknowledge. NRF_ERROR_DATA_SIZE or NRF_ERROR_TIMEOUT is returned depending on values used for offset and len in the ble_gattc_write_params_t structure.

I also tried prepared writes using BLE_GATT_OP_PREP_WRITE_REQ:

memset(&m_writeParams, 0, sizeof(m_writeParams));
m_writeParams.write_op = BLE_GATT_OP_PREP_WRITE_REQ; // Prepare write request
m_writeParams.handle = m_sn_char_handle + 1;
m_writeParams.p_value = newSn;
m_writeParams.offset = 0;
m_writeParams.len = 18;

err_code = sd_ble_gattc_write(m_adapter, m_connection_handle, &m_writeParams);

With this code, I get a BLE_GATTC_EVT_WRITE_RSP event with error code 0x010D (timeout).

I have a couple of questions. I read on a devzone article that it's possible to write with offsets to a long characteristic. Is there an example that shows how this is done? It would be great if this method worked since it is easier to understand the flow and is more efficient.

If I use prepared writes, is there some other setup that needs to happen before I can use prepared writes?

Thanks,

Michael

Parents
  • Hi Sigurd,

    We're using a custom device on the server side. I'd like to know if my NRF52-DK is set up correctly to send prepared writes. I'm sending a prepare write command as outlined above. Is that all that's necessary to send a prepare write request?

    Also, thanks for sending the link to the sequence diagram. It's not exactly what I'm doing though because all of the examples require authorization, and at this time, I'm not using authorization.

    Thanks,

    Michael

Reply
  • Hi Sigurd,

    We're using a custom device on the server side. I'd like to know if my NRF52-DK is set up correctly to send prepared writes. I'm sending a prepare write command as outlined above. Is that all that's necessary to send a prepare write request?

    Also, thanks for sending the link to the sequence diagram. It's not exactly what I'm doing though because all of the examples require authorization, and at this time, I'm not using authorization.

    Thanks,

    Michael

Children
Related