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

BLE_GATTC_EVT_WRITE_RSP does not contain data

Hello,
I am using an nrf52840 with softdevice S140 (7.0.1) configured as GATT client.
I successfully write data to the GATT server (Led Button Service) to set the LED using a Write Request. (see snippet).

ble_gattc_write_params_t write_params = {
    .write_op = BLE_GATT_OP_WRITE_REQ,
    .flags = BLE_GATT_EXEC_WRITE_FLAG_PREPARED_WRITE,
    .handle = p_char->value_handle,
    .offset = 0,
    .len = len,
    .p_value = p_data
    };
    APP_ERROR_CHECK(sd_ble_gattc_write(conn_handle, &write_params);
When I receive the BLE_GATTC_EVT_WRITE_RSP both the 'handle' and 'write_op' are set correctly. However the fields 'offset', 'len' and 'data' are all zero:
(gdb) p/x *p_write_rsp $2 = {
  handle = 0x28,
  write_op = 0x1,
  offset = 0x0,
  len = 0x0,
  data = {0x0}
}

I expect both len and data[0] to be 1 (when enabling the LED).
I have checked on https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.s140.api.v7.0.1%2Fstructble__gattc__evt__write__rsp__t.html
I ensure that at least 412 bytes are available for the ble event as max MTU is 203.
Is my understanding correct that the write response should contain the data I have written?

Best regards,
Karel

Parents
  • The response event normally contains only data that exist in the response packet on air. For write response, it's only opcode actually, represented by ble_gattc_evt_write_rsp_t::write_op. The softdevice artificially populate handle as well, but not the other fields. The other fields will be populated for responses that contain corresponding data on air, for example for ATT_PREPARE_WRITE_RSP all fields will be populated.
Reply
  • The response event normally contains only data that exist in the response packet on air. For write response, it's only opcode actually, represented by ble_gattc_evt_write_rsp_t::write_op. The softdevice artificially populate handle as well, but not the other fields. The other fields will be populated for responses that contain corresponding data on air, for example for ATT_PREPARE_WRITE_RSP all fields will be populated.
Children
No Data
Related