wakaama icon indicating copy to clipboard operation
wakaama copied to clipboard

Json data format parsing when resource is of data type OPAQUE

Open boria8 opened this issue 7 years ago • 7 comments

Currently wakaama is parsing Resource data type OPAQUE as is (lwm2m_data_encode_opaque) while according to the TS If the Resource data type is opaque the string value holds the Base64 encoded representation of the Resource. i think that it will be not easy to implement since the parsing function needs data type information to choose correct parsing.

boria8 avatar Apr 20 '17 22:04 boria8

As stated in #263, my opinion is that the Object plugin should do the base64 decoding. The base64 decoding is required if, for an opaque resource, the lwm2m_data_t is of type LWM2M_TYPE_STRING.

dnav avatar Apr 21 '17 08:04 dnav

if so then why the encoding is done in the core? it could be the solution, but don't you think that parsing logic should stay in the core? i think that to achieve the parsing within the core(json_parse) the prv_convertRecord API should gain knowledge about resource type under parsing, and to perform the base64 conversion in case of string

boria8 avatar Apr 21 '17 09:04 boria8

The encoding is done in the core because the Object plugin sets the lwm2m_data_t::type to LWM2M_TYPE_OPAQUE. Then the core knows it has to base64 encode the data for JSON format.

For decoding, getting knowledge of the resource type would require each Object plugin to provide this information to the core and the core to maintain a database thus increasing the memory usage.

dnav avatar Apr 21 '17 10:04 dnav

the core is not necessary need to maintain database, we can for example define additional object api which retrieves resource type.

boria8 avatar Apr 21 '17 10:04 boria8

The SenML JSON encoding is aware of opaque values and does the decoding. The original JSON encoding does not allow for this and decoding must be done in the Object plugin.

sbertin-telular avatar Mar 07 '19 15:03 sbertin-telular

@sbertin-telular any thoughts on the way forward for this issue? Would like to reduce the number of open bugs...

qleisan avatar Feb 05 '21 08:02 qleisan

I always felt that lwm2m_data_decode_opaque() and lwm2m_data_decode_string() functions were missing to round out the set of functions in data.c. Maybe adding lwm2m_data_decode_opaque() that would just copy opaque data or base64 decode string data would resolve this.

sbertin-telular avatar Feb 05 '21 13:02 sbertin-telular