net: lwm2m: support for reading OPAQUE resources with OMA TLV

The LwM2M stack would previously ignore all OPAQUE resources when
reading them. This meant that it was impossible to read them, even if
there was a custom read callback.

Signed-off-by: Göran Weinholt <goran.weinholt@endian.se>
This commit is contained in:
Göran Weinholt 2020-03-03 16:49:49 +01:00 committed by Jukka Rissanen
commit 32864ecbcc
2 changed files with 11 additions and 1 deletions

View file

@ -2106,8 +2106,10 @@ static int lwm2m_read_handler(struct lwm2m_engine_obj_inst *obj_inst,
switch (obj_field->data_type) {
/* do nothing for OPAQUE (probably has a callback) */
case LWM2M_RES_TYPE_OPAQUE:
engine_put_opaque(&msg->out, &msg->path,
(u8_t *)data_ptr,
data_len);
break;
case LWM2M_RES_TYPE_STRING:

View file

@ -559,6 +559,13 @@ static size_t put_bool(struct lwm2m_output_context *out,
return put_s8(out, path, value_s8);
}
static size_t put_opaque(struct lwm2m_output_context *out,
struct lwm2m_obj_path *path,
char *buf, size_t buflen)
{
return put_string(out, path, buf, buflen);
}
static size_t get_number(struct lwm2m_input_context *in, s64_t *value,
u8_t max_len)
{
@ -764,6 +771,7 @@ const struct lwm2m_writer oma_tlv_writer = {
.put_float32fix = put_float32fix,
.put_float64fix = put_float64fix,
.put_bool = put_bool,
.put_opaque = put_opaque,
};
const struct lwm2m_reader oma_tlv_reader = {