net: lwm2m: setup data_ptr/len for OPAQUE resource when none given
OPAQUE resource type might/might not have data_ptr/data_len setup depending on the implementation. This introduce an issue that when OPAQUE resource is written from the server side, the ones w/ none setup will not be able to get the data at post_write_cb() Modify to setup data_ptr/data_len as incoming buffer and buffer size Signed-off-by: Robert Chou <robert.ch.chou@acer.com>
This commit is contained in:
parent
d9f5fe7455
commit
f6188fbce3
1 changed files with 7 additions and 0 deletions
|
@ -1707,6 +1707,13 @@ int lwm2m_write_handler(struct lwm2m_engine_obj_inst *obj_inst,
|
|||
data_ptr = res->data_ptr;
|
||||
data_len = res->data_len;
|
||||
|
||||
/* setup data_ptr/data_len for OPAQUE when it has none setup */
|
||||
if (obj_field->data_type == LWM2M_RES_TYPE_OPAQUE &&
|
||||
data_ptr == NULL && data_len == 0) {
|
||||
data_ptr = in->inbuf;
|
||||
data_len = in->insize;
|
||||
}
|
||||
|
||||
/* allow user to override data elements via callback */
|
||||
if (res->pre_write_cb) {
|
||||
data_ptr = res->pre_write_cb(obj_inst->obj_inst_id, &data_len);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue