This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Getting the new updated value of a write long in the event handler

I'm getting an event when a write long is completed (the line with BLE_GATTS_OP_EXEC_WRITE_REQ_NOW):

static void on_write(ble_mlbx_t * p_mlbx, ble_evt_t * p_ble_evt)
{
  ble_gatts_evt_write_t * p_evt_write = &p_ble_evt->evt.gatts_evt.params.write;

  switch (p_evt_write->op)
  {
    case BLE_GATTS_OP_WRITE_REQ:
      if (p_evt_write->handle == p_mlbx->inbox_char_handles.value_handle)
      {
        if (p_mlbx->evt_handler != NULL)
        {
          memcpy(p_mlbx->inbox_entry_last.p_data, p_ble_evt->evt.gatts_evt.params.write.data, p_ble_evt->evt.gatts_evt.params.write.len);
          p_mlbx->inbox_entry_last.size = p_ble_evt->evt.gatts_evt.params.write.len;
          p_mlbx->evt_handler(p_mlbx);
        }
      }
      break;
    case BLE_GATTS_OP_EXEC_WRITE_REQ_NOW:
      if (p_mlbx->evt_handler != NULL)
      {
        memcpy(p_mlbx->inbox_entry_last.p_data, p_evt_write->data, p_evt_write->len);
        p_mlbx->inbox_entry_last.size = p_evt_write->len;
        p_mlbx->evt_handler(p_mlbx);
      }            
      break;
    default:
      break;
  }

}

The problem I'm having is that p_evt_write->data is empty and p_evt_write->len is 0. The user memory block that I passed into sd_ble_user_mem_reply contains all the written data though. Should p_evt_write->data contain the new value or is it expected that someone needs to manually parse the memory block to get the new value?

Related