Skip to content
Commit 660ad979 authored by Benjamin Lindqvist's avatar Benjamin Lindqvist Committed by Jukka Rissanen
Browse files

net: lwm2m: Pack TLV integers more efficiently



Prior to this commit, the LwM2M stack would TLV-encode integers
depending on their internal storage size. An integer with value 5 stored
in an int8_t would be encoded with length 1, but an integer stored in an
int32_t would be encoded as "00 00 00 05" with length 4.

This commit checks if the value is castable to a smaller int and encodes
it as such if so. This is cascading, so even a 64 bit integer with value
5 will be encoded with length 1.

Note that this does not seem to be required by the specification, but
this is how Anjay and the other LwM2M stack seem to do it.

Signed-off-by: default avatarBenjamin Lindqvist <benjamin.lindqvist@endian.se>
parent 3c79b565
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment